且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

IIS提供对Chrome Postman的压缩(gzip)响应,但不提供对.NET HttpClient的响应

更新时间:2023-12-06 08:07:40

因此,我使用Fiddler和lo监视了HTTP流量,并发现使用HttpClient时实际上压缩了服务器响应(Postman收到的字节数是等于HttpClient接收的字节数)并发送了相应的Content-Encoding: gzip标头!我猜想HttpClient在自动解压缩模式下会通过删除Content-Encoding: gzip标头来尝试变得聪明.这在任何地方都有记录吗?

So, I monitored the HTTP traffic using Fiddler and lo and behold the server response was in fact compressed when using the HttpClient (the number bytes received by Postman was the same as the number of bytes received by HttpClient) and had sent the corresponding Content-Encoding: gzip header! I guess that the HttpClient is trying to be smart by removing the Content-Encoding: gzip header when it is in automatic decompression mode. Is this documented anywhere?