зеркало из https://github.com/microsoft/mwt-ds.git
Switch to using Dictionary initializer, and add check for SupportsHeaders
This commit is contained in:
Родитель
6bf6201cad
Коммит
139a42521a
|
@ -117,18 +117,23 @@ namespace Microsoft.DecisionService.Crawl
|
|||
catch (WebException we)
|
||||
{
|
||||
HttpWebResponse httpResponse = we.Response as HttpWebResponse;
|
||||
if (we.Status == WebExceptionStatus.ServerProtocolViolation)
|
||||
if (we.Status == WebExceptionStatus.ServerProtocolViolation && we.Response != null)
|
||||
{
|
||||
// Get a little more telemetry about what is going on here.
|
||||
IDictionary<string, string> traceData = new Dictionary<string, string>();
|
||||
traceData["Response.SupportsHeaders"] = we.Response.SupportsHeaders.ToString();
|
||||
IDictionary<string, string> traceData = new Dictionary<string, string>()
|
||||
{
|
||||
{ "Response.SupportsHeaders", we.Response.SupportsHeaders.ToString() }
|
||||
};
|
||||
|
||||
if (we.Response.SupportsHeaders)
|
||||
{
|
||||
for (int i = 0; i < we.Response.Headers.Count; i++)
|
||||
{
|
||||
string headerName = we.Response.Headers.GetKey(i);
|
||||
string headerValue = we.Response.Headers.Get(i);
|
||||
traceData[$"Response.Headers.{headerName}"] = headerValue;
|
||||
}
|
||||
}
|
||||
|
||||
if (httpResponse != null)
|
||||
{
|
||||
|
|
Загрузка…
Ссылка в новой задаче