Skip to content

Instantly share code, notes, and snippets.

@glennc
Created June 21, 2018 16:56
Show Gist options
  • Save glennc/f426d880b6f79b5c3e6cb7ff96f7e649 to your computer and use it in GitHub Desktop.
Save glennc/f426d880b6f79b5c3e6cb7ff96f7e649 to your computer and use it in GitHub Desktop.
AutomaticDecompression
services.AddHttpClient("test")
.ConfigurePrimaryHttpMessageHandler(() =>
{
var handler = new HttpClientHandler();
handler.AutomaticDecompression = System.Net.DecompressionMethods.Deflate;
return handler;
});
@steveoh
Copy link

steveoh commented Jun 21, 2018

            services.AddHttpClient("default", client =>
            {
                client.Timeout = new TimeSpan(0, 0, 15);
            }).ConfigurePrimaryHttpMessageHandler(() => {
                var handler = new HttpClientHandler();
                if (handler.SupportsAutomaticDecompression)
                {
                    handler.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
                }

                return handler;
            });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment