Http Request Compression#130082
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds new public HttpContent wrappers in System.Net.Http that compress the request body using gzip, Brotli, or Zstandard, with a shared internal helper to handle header copying and serialization.
Changes:
- Introduces
GZipCompressedContent,BrotliCompressedContent, andZstandardCompressedContentpublicHttpContenttypes. - Factors common header/serialization logic into an internal
CompressedContentCore. - Updates
System.Net.Httpsource/ref projects and ref surface to include the new APIs and compression dependencies.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/libraries/System.Net.Http/src/System/Net/Http/BrotliCompressedContent.cs | New HttpContent wrapper that applies Brotli request compression. |
| src/libraries/System.Net.Http/src/System/Net/Http/CompressedContentCore.cs | Internal helper for header initialization and (a)synchronous serialization via compression streams. |
| src/libraries/System.Net.Http/src/System/Net/Http/GZipCompressedContent.cs | New HttpContent wrapper that applies gzip request compression. |
| src/libraries/System.Net.Http/src/System/Net/Http/ZstandardCompressedContent.cs | New HttpContent wrapper that applies Zstandard request compression. |
| src/libraries/System.Net.Http/src/System.Net.Http.csproj | Includes the new source files in the build. |
| src/libraries/System.Net.Http/ref/System.Net.Http.csproj | Adds ref-time dependencies on compression ref projects needed by the new public API signatures. |
| src/libraries/System.Net.Http/ref/System.Net.Http.cs | Adds the new public API surface for the three compressed content types. |
MihaZupan
reviewed
Jul 2, 2026
MihaZupan
reviewed
Jul 2, 2026
This was referenced Jul 9, 2026
This was referenced Jul 13, 2026
Open
MihaZupan
approved these changes
Jul 14, 2026
MihaZupan
left a comment
Member
There was a problem hiding this comment.
Looks good as-is, but we could also relatively easily avoid the couple extra allocations for the helper
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
MihaZupan
approved these changes
Jul 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds built-in support for compressing HTTP request content by introducing three new
HttpContenttypes:GZipCompressedContent,BrotliCompressedContent, andZstandardCompressedContent.Each type wraps an inner
HttpContent, sets the appropriateContent-Encoding, clearsContent-Length, and compresses the body as it is serialized. Shared header-copying, validation, and serialization logic is factored into an internalCompressedContentCorehelper.Each type offers two constructors:
•
(HttpContent content, CompressionLevel compressionLevel = CompressionLevel.Optimal): the high-level speed/size knob; the level is validated up front so an invalid value fails fast at construction rather than during send.•
(HttpContent content, <Algorithm>CompressionOptions compressionOptions): for fine-grained tuning.Implements #46944