Add DecompressionMethods.Zstandard for HTTP automatic decompression#123531
Add DecompressionMethods.Zstandard for HTTP automatic decompression#123531stephentoub merged 6 commits intomainfrom
Conversation
Co-authored-by: rzikm <32671551+rzikm@users.noreply.github.com>
Co-authored-by: rzikm <32671551+rzikm@users.noreply.github.com>
Co-authored-by: rzikm <32671551+rzikm@users.noreply.github.com>
src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/DecompressionHandler.cs
Show resolved
Hide resolved
|
Tagging subscribers to this area: @karelz, @dotnet/ncl |
There was a problem hiding this comment.
Pull request overview
Adds Zstandard (zstd) support to HttpClientHandler/SocketsHttpHandler automatic response decompression by extending DecompressionMethods and wiring the new encoding into the existing decompression pipeline (mirroring the Brotli pattern).
Changes:
- Extended
System.Net.DecompressionMethodswithZstandard = 0x8(and updated reference assembly). - Added
zstdhandling inDecompressionHandlerand enabled it inSocketsHttpHandler’s supported decompression mask. - Added
System.IO.Compression.Zstandarddependency and expanded decompression/Accept-Encoding functional tests to cover Zstandard.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/libraries/System.Net.Primitives/src/System/Net/DecompressionMethods.cs | Adds DecompressionMethods.Zstandard enum value. |
| src/libraries/System.Net.Primitives/ref/System.Net.Primitives.cs | Updates public ref API to include Zstandard. |
| src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/SocketsHttpHandler.cs | Includes Zstandard in SupportedDecompressionMethods. |
| src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/DecompressionHandler.cs | Adds zstd Accept-Encoding emission and ZstandardStream-based decompression. |
| src/libraries/System.Net.Http/src/System.Net.Http.csproj | Adds project reference to System.IO.Compression.Zstandard. |
| src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.Decompression.cs | Adds Zstandard test coverage for decompression and Accept-Encoding behaviors. |
src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/DecompressionHandler.cs
Outdated
Show resolved
Hide resolved
|
@jkotas raised a good point in a related issue about trimming. #123532 (comment) I believe the same argument would apply here. |
Yes and no. If you use AutomaticDecompression, then regardless of which compression algorithms you specify, you'll root them all. But if you don't set AutomaticDecompression, the whole compression support becomes trimmable. @eerhardt did that a few years ago in #78198. |
Co-authored-by: MihaZupan <25307628+MihaZupan@users.noreply.github.com>
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/DecompressionHandler.cs
Outdated
Show resolved
Hide resolved
…andler/DecompressionHandler.cs Co-authored-by: Jan Kotas <jkotas@microsoft.com>
|
/ba-g Test failures are unrelated |
Description
Adds Zstandard compression support to
DecompressionMethodsfor automatic HTTP response decompression, matching the API proposal. Follows the established pattern from Brotli support.Changes
API Surface
Zstandard = 0x8toDecompressionMethodsenum in System.Net.PrimitivesImplementation
DecompressionHandler: Added "zstd" encoding support withZstandardEnabledproperty andZstandardDecompressedContentclass usingZstandardStreamDecompressionHandler: Optimized Accept-Encoding header construction to useSpan<string?>instead ofList<string?>for better performance and reduced heap allocationsSocketsHttpHandler: UpdatedSupportedDecompressionMethodsto include ZstandardSystem.IO.Compression.ZstandardTests
HttpClientHandlerTest.Decompression.cscovering decompression, empty bodies, Accept-Encoding headers, and quality weightingsUsage
Notes
System.IO.Compression.Zstandardwhich is already availableSpan<string?>to avoid heap allocationsOriginal prompt
DecompressionMethods.Zstdfor web requests #112075💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.