1

Closed

HttpClient duplicates Accept-Encoding values when used in Windows Authentication+Gzip scenario

description

I'm hosting an ASP.NET WebApi application in IIS 7.5 (Express) with Windows Authentication enabled and try to access it with HttpClient (version 2.0.20710.0 from NuGet). The server has been configured to perform gzip compression on JSON responses via applicationHost.config and I'm setting the AutomaticDecompression property on the client to Gzip.

As the request needs to go through challenge-response authentication, multiple requests are performed between IIS and my client. After looking at the requests through Fiddler, it seems that the Accept-Encoding header value is duplicated with each request (see attached screenshots):

Request 1: Accept-Encoding: gzip
Request 2: Accept-Encoding: gzip, gzip
Request 3: Accept-Encoding: gzip, gzip, gzip

Please note that despite this, the request completes successfully and HttpClient automatically decompresses the gzipped result.

Here's my client code:
var clientHandler = new HttpClientHandler
                    {
                        AutomaticDecompression = DecompressionMethods.GZip, 
                        Credentials = CredentialCache.DefaultCredentials
                    };
                var httpClient = new HttpClient(clientHandler) { BaseAddress = new Uri("http://machinename:8888") };
                httpClient.GetStringAsync("api/version").Wait();

file attachments

Closed Apr 6 at 6:22 AM by HongmeiG
I have filed the issue against the correct owner.

comments

HongmeiG wrote Apr 6 at 5:54 AM

It looks like the bug is with HttpClientHandler, which is not part of this project. I will let the owner know about this.