Answered by:
Does HttpClient add header 'Acept-Encoding' is 'gzip, deflate' automatically?

Question
-
Hi there,
I using HttpClient to get data from a web server which enabling gzip response data. My code is very simple:
using (HttpClient httpClient = new HttpClient()) { // To do httpResponseMsg = await httpClient.SendRequestAsync(myPOSTRequestMessage); .... }
I use a tool to capture http trafiic on my PC, it is Fiddler. And here is what I see:
So does the HttpClient auto add 'Acept-Encoding' header?
Thanks,
Vu
Vu Tran
- Edited by Vu_Tran Saturday, April 4, 2015 3:44 AM Edit title more meaning
Saturday, April 4, 2015 3:43 AM
Answers
-
Hi Vu Tran,
The answer can be found from the documentation Can Bilgin provided, see the remark section of AutomaticDecompression | automaticDecompression property and the default value is true
When this property is set to true, the Accept-Encoding header is added to the headers and set to allow gzip and compress.
That means the accept-encoding is add automatically by HttpClient.
--James
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click HERE to participate the survey.- Proposed as answer by Jamles HezModerator Wednesday, April 15, 2015 9:03 AM
- Marked as answer by Jamles HezModerator Friday, April 17, 2015 1:10 AM
Wednesday, April 15, 2015 9:03 AMModerator -
It is just the platform letting the server know about the fact that it can handle decompression. It was not supported on win phone 7 and Silverlight, but on Winrt 8 decompression is supporter. On .NET, you had a flag to set the AutomaticDecompression. On Windows Runtime, the property is moved to the filters https://msdn.microsoft.com/en-us/library/windows/apps/windows.web.http.filters.httpbaseprotocolfilter.automaticdecompression.aspx?f=255&MSPPError=-2147217396. Notice the default value is set to true.
Can Bilgin
Blog Samples CompuSight- Proposed as answer by Jamles HezModerator Wednesday, April 15, 2015 9:03 AM
- Marked as answer by Jamles HezModerator Friday, April 17, 2015 1:10 AM
Saturday, April 4, 2015 5:27 AM
All replies
-
It is just the platform letting the server know about the fact that it can handle decompression. It was not supported on win phone 7 and Silverlight, but on Winrt 8 decompression is supporter. On .NET, you had a flag to set the AutomaticDecompression. On Windows Runtime, the property is moved to the filters https://msdn.microsoft.com/en-us/library/windows/apps/windows.web.http.filters.httpbaseprotocolfilter.automaticdecompression.aspx?f=255&MSPPError=-2147217396. Notice the default value is set to true.
Can Bilgin
Blog Samples CompuSight- Proposed as answer by Jamles HezModerator Wednesday, April 15, 2015 9:03 AM
- Marked as answer by Jamles HezModerator Friday, April 17, 2015 1:10 AM
Saturday, April 4, 2015 5:27 AM -
It is just the platform letting the server know about the fact that it can handle decompression. It was not supported on win phone 7 and Silverlight, but on Winrt 8 decompression is supporter. On .NET, you had a flag to set the AutomaticDecompression. On Windows Runtime, the property is moved to the filters https://msdn.microsoft.com/en-us/library/windows/apps/windows.web.http.filters.httpbaseprotocolfilter.automaticdecompression.aspx?f=255&MSPPError=-2147217396. Notice the default value is set to true.
Can Bilgin
Blog Samples CompuSightHi Can Bilgin,
Thanks for your info.
Yes, I knew about the AutomaticDecompression property. I just want to know HttpClient has default header 'Acept-Encoding' gzip or not?
Thanks,
Vu
Vu Tran
Saturday, April 4, 2015 6:16 AM -
Hi Vu Tran,
The answer can be found from the documentation Can Bilgin provided, see the remark section of AutomaticDecompression | automaticDecompression property and the default value is true
When this property is set to true, the Accept-Encoding header is added to the headers and set to allow gzip and compress.
That means the accept-encoding is add automatically by HttpClient.
--James
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click HERE to participate the survey.- Proposed as answer by Jamles HezModerator Wednesday, April 15, 2015 9:03 AM
- Marked as answer by Jamles HezModerator Friday, April 17, 2015 1:10 AM
Wednesday, April 15, 2015 9:03 AMModerator