THRIFT-4893 Enable automatic content encoding handling for gzip,deflate in the HTTP client
Client: netstd
Patch: Jens Geyer
This closes #1818
diff --git a/lib/netstd/Thrift/Transport/Client/THttpTransport.cs b/lib/netstd/Thrift/Transport/Client/THttpTransport.cs
index 982e91e..21cc409 100644
--- a/lib/netstd/Thrift/Transport/Client/THttpTransport.cs
+++ b/lib/netstd/Thrift/Transport/Client/THttpTransport.cs
@@ -139,6 +139,7 @@
{
var handler = new HttpClientHandler();
handler.ClientCertificates.AddRange(_certificates);
+ handler.AutomaticDecompression = System.Net.DecompressionMethods.Deflate | System.Net.DecompressionMethods.GZip;
var httpClient = new HttpClient(handler);
@@ -149,7 +150,10 @@
httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/x-thrift"));
httpClient.DefaultRequestHeaders.UserAgent.TryParseAdd(UserAgent);
-
+
+ httpClient.DefaultRequestHeaders.AcceptEncoding.Add(new StringWithQualityHeaderValue("deflate"));
+ httpClient.DefaultRequestHeaders.AcceptEncoding.Add(new StringWithQualityHeaderValue("gzip"));
+
if (customRequestHeaders != null)
{
foreach (var item in customRequestHeaders)