[英]HttpResponseMessage missing headers while using HttpClient but fiddler finds it
I am making a simple HttpClient
call like this: 我正在像这样进行一个简单的HttpClient
调用:
Uri basePath = new Uri("https://my-host.com/");
string path = "api/my-path";
using (HttpClient httpClient = new HttpClient())
{
httpClient.BaseAddress = basePath;
HttpResponseMessage response = await httpClient.GetAsync(path);
if (response.IsSuccessStatusCode)
{
response.Headers.Select(header => header.Key).Dump();
}
}
I am looking for a custom auth-header on the response but it is missing when I iterate over Headers
collection. 我正在寻找响应中的自定义auth-header,但是当我遍历Headers
集合时却找不到它。
However, same Http request caught by Fiddler
shows the header. 但是, Fiddler
捕获的相同Http请求显示了标头。 If I make same request on Postman
or any browser, I see the header. 如果我在Postman
或任何浏览器上发出相同的请求, Postman
看到标题。
Wondering what am I missing here. 想知道我在这里想念什么。
[Update] [更新]
Raw Headers captured on Fiddler
by executing same code above: 通过执行上面相同的代码在Fiddler
捕获原始标头:
HTTP/1.1 302 Found
Cache-Control: no-cache
Pragma: no-cache
Expires: -1
Location: <redacted>
Server: Microsoft-IIS/8.0
WWW-Authenticate-Test: <redacted>
X-AspNet-Version: 4.0.30319
Set-Cookie: <redacted>
X-UA-Compatible: IE=edge
Date: Sat, 11 Nov 2017 23:15:19 GMT
Content-Length: 0
Headers printed by above code: 上面代码打印的标题:
Pragma
Strict-Transport-Security
X-Content-Type-Options
X-Frame-Options
x-ms-request-id
Cache-Control
P3P
Set-Cookie
Server
X-Powered-By
Date
I would like to capture the header WWW-Authenticate-Test
which is somehow filtered out while it goes through the HttpClient
magic. 我想捕获标头WWW-Authenticate-Test
,它通过HttpClient
魔术时以某种方式被过滤掉了。
它可能是一个内容标头 :
response.Content.Headers.Select(header => header.Key).Dump();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.