Fixed a few bugs in both WinHttpHandler and SocketsHttpHandler regarding the behavior of
'Accept-Encoding' request headers and automatic decompression of response body content.
On Windows 7, native WinHTTP doesn't support automatic decompression. That also means it doesn't automatically append 'Accept-Encoding' request headers. WinHttpHandler was relying on WinHTTP to add those headers. But it wasn't happening on Windows 7. So, now WinHttpHandler will make sure those headers are added if not already present. WinHttpHandler was also always decompressing content even when the encodings in the .AutomaticDecompression property didn't match.
SocketsHttpHandler had a different bug. It would make sure that the 'Accept-Encoding' headers were
present when .AutomaticDecompression was being used. But it wouldn't check for existing headers and duplicate encodings would be present in the outbound 'Accept-Encoding' request header. I.e., it would end up with "Accept-Encoding: gzip, gzip".
In addition to fixing these bugs, I added more tests to both Http Functional and WinHttpHandler Unit
tests (which can simulate running on Windows 7 using the existing mocks).
Fixesdotnet/corefx#29747Fixesdotnet/corefx#26991
Commit migrated from https://github.com/dotnet/corefx/commit/40ce4cb20270f731d7d826291e1edce8d1ce2c37
We have Brotli_DecompressesResponse_Success which just uses a loopback server. I'd added Brotli_External_DecompressesResponse_Success as a way to test against another Brotli implementation, but that's not really something we need to do in the System.Net.Http tests; rather, it's up to the System.IO.Compression.Brotli tests to ensure compliance. Given that, and this tests ends up causing failures when httpbin.org goes down, I'm just deleting it.
Commit migrated from https://github.com/dotnet/corefx/commit/e85573f9b778ba65925f17da6fc485bb43d2c055