HttpClient的响应使我认为,直到我按照this answer的建议使用Fiddler检查响应之前,响应才被压缩。
我正在使用blog post进行简单的复制:
nloptr
以下是调试时看到的var handler = new HttpClientHandler();
if (handler.SupportsAutomaticDecompression)
{
handler.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
}
var client = new HttpClient(handler);
HttpResponseMessage response = await client.GetAsync("http://google.com");
string content = await response.Content.ReadAsStringAsync();
Console.WriteLine(content);
:
response.Content.Headers