Croll
Croll

Reputation: 3791

How to decompress GZipped HTTP response in WinRT

In usual .NET environment we have a property AutomaticDecompression in class HttpWebRequest.

httpRequest.AutomaticDecompression = 
    (DecompressionMethods.GZip | DecompressionMethods.Deflate);

Problem is that i am on WinRT, and here is no such property in HttpWebRequest class. And what i have? I have GZip-compressed response stream...

Upvotes: 0

Views: 678

Answers (1)

John Koerner
John Koerner

Reputation: 38077

Use the HttpClientHandler, as it supports the AutomaticDecompression:

System.Net.Http.HttpClientHandler hc = new System.Net.Http.HttpClientHandler();
hc.AutomaticDecompression = System.Net.DecompressionMethods.GZip;

System.Net.Http.HttpClient client = new System.Net.Http.HttpClient(hc);

var result = await client.GetAsync(uri)

Upvotes: 1

Related Questions