HttpClient and Compression

Topics: Web Api
Nov 23, 2010 at 3:17 PM

If I enable compression in IIS, does the HttpClient support this?

 

Coordinator
Nov 23, 2010 at 4:50 PM
It should as we build on HttpWebRequest which supports compression. Haven't tested though.

On Nov 23, 2010, at 8:18 AM, "mpapas" <notifications@codeplex.com> wrote:

From: mpapas

If I enable compression in IIS, does the HttpClient support this?

Read the full discussion online.

To add a post to this discussion, reply to this email (wcf@discussions.codeplex.com@discussions.codeplex.com)

To start a new discussion for this project, email wcf@discussions.codeplex.com@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com

Nov 24, 2010 at 4:24 PM

Nice.  This seems to do the trick:

var client = new HttpClient();
...

client.DefaultHeaders.AcceptEncoding.AddString("gzip,deflate");
client.TransportSettings.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
Nov 24, 2010 at 4:27 PM

Oh I should mention that using Fiddler, I noticed that compression seems to work only on responses to GET.  Any content included as the response to a POST doesn't get compressed.

However, I'm not sure if this is an HTTP thing, IIS configuration thing, or an HttpClient thing :-)