是否.NET的HttpWebResponse uncom preSS自动GZi​​ped和放气的反应?反应、放气、uncom、HttpWebResponse

2023-09-02 01:35:33 作者:柠檬不萌らRose°

我想这样做,接受COM pressed响应的请求

I am trying to do a request that accepts a compressed response

var request = (HttpWebRequest)HttpWebRequest.Create(requestUri);
request.Headers.Add(HttpRequestHeader.AcceptEncoding, "gzip,deflate");

我不知道当我添加第二行,我将不得不手动处理DECOM pression。

I wonder if when I add the second line I will have to handle the decompression manually.

推荐答案

我找到了答案。

您可以更改code到:

You can change the code to:

var request = (HttpWebRequest)HttpWebRequest.Create(requestUri);
request.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;

和您将有自动DECOM pression。无需更改的code中的其余部分。

And you will have automatic decompression. No need to change the rest of the code.