platform-compat
platform-compat copied to clipboard
HttpClientHandler.AutomaticDecompression default changed from .NET Core 1.1 to .NET Core 2.0
On .NET Core 1.1, the default value for the HttpClientHandler.AutomaticDecompression
property was
DecompressionMethods.Deflate | DecompressionMethods.GZip
On .NET Core 2.0, the default is now:
DecompressionMethods.None;
This was changed so that it is now the same as .NET Framework.
If you need to change the default back to what it was in .NET Core 1.1, use the following code:
var handler = new HttpClientHandler();
handler.AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip;
var client = new HttpClient(handler);
That's interesting. The way the analyzer currently works is that issues are attached to an API. This is an instance where attaching it to the API that was changed wouldn't be useful because the lack of setting the property would be problematic, not the actual use.
We could associate a warning with the HttpClientHandler
ctor, but this might result in excessive reporting. Alternatively, I could create a separate analyzer that tries to detect the pattern where a type is instantiated while a specific property wasn't set and the default varies across platforms. But I only want to do this if there more types in that category, i.e. the effort is actually worth it.
Thoughts?
/cc @karelz
Are there potentially negative implications, performance or otherwise, of defaulting to DEFLATE/GZIP that you are aware of? Or would you say this is strictly about compatibility with .NET Framework?
I would say it is primarily about compatibility with .NET Framework, not about perf. For perf questions, the best answer is: Measure it and judge if it matters for your scenario :)