Does .NET's HttpWebResponse uncompress automatically GZiped and Deflated responses?

前端 未结 4 1953
囚心锁ツ
囚心锁ツ 2020-11-28 10:40

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

var request = (HttpWebRequest)HttpWebRequest.Create(requestUri);
request.Headers.Add(HttpReque         


        
4条回答
  •  攒了一身酷
    2020-11-28 11:00

    I found the answer.

    You can change the code to:

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

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

提交回复
热议问题