Skip to content

Http Request Compression#130082

Merged
iremyux merged 22 commits into
dotnet:mainfrom
iremyux:46944-request-compression
Jul 15, 2026
Merged

Http Request Compression#130082
iremyux merged 22 commits into
dotnet:mainfrom
iremyux:46944-request-compression

Conversation

@iremyux

@iremyux iremyux commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Adds built-in support for compressing HTTP request content by introducing three new HttpContent types: GZipCompressedContent, BrotliCompressedContent, and ZstandardCompressedContent.

Each type wraps an inner HttpContent, sets the appropriate Content-Encoding, clears Content-Length, and compresses the body as it is serialized. Shared header-copying, validation, and serialization logic is factored into an internal CompressedContentCore helper.

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

Copilot AI review requested due to automatic review settings July 1, 2026 14:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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, and ZstandardCompressedContent public HttpContent types.
  • Factors common header/serialization logic into an internal CompressedContentCore.
  • Updates System.Net.Http source/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.

Comment thread src/libraries/System.Net.Http/src/System/Net/Http/CompressedContentCore.cs Outdated
Comment thread src/libraries/System.Net.Http/src/System/Net/Http/CompressedContentCore.cs Outdated
Comment thread src/libraries/System.Net.Http/src/System/Net/Http/CompressedContentCore.cs Outdated
Comment thread src/libraries/System.Net.Http/src/System/Net/Http/CompressedContentCore.cs Outdated
Comment thread src/libraries/System.Net.Http/src/System/Net/Http/CompressedContentCore.cs Outdated
Copilot AI review requested due to automatic review settings July 7, 2026 11:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.

Comment thread src/libraries/System.Net.Http/src/System/Net/Http/CompressedContentCore.cs Outdated
Copilot AI review requested due to automatic review settings July 7, 2026 21:06

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Comment thread src/libraries/System.Net.Http/src/System/Net/Http/CompressedContentCore.cs Outdated
Comment thread src/libraries/System.Net.Http/ref/System.Net.Http.cs
@iremyux
iremyux marked this pull request as ready for review July 8, 2026 18:16
Copilot AI review requested due to automatic review settings July 8, 2026 18:16

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 7 comments.

Comment thread src/libraries/System.Net.Http/src/System/Net/Http/CompressedContentCore.cs Outdated
Comment thread src/libraries/System.Net.Http/src/System/Net/Http/BrotliCompressedContent.cs Outdated
Comment thread src/libraries/System.Net.Http/src/System/Net/Http/ZstandardCompressedContent.cs Outdated
Comment thread src/libraries/System.Net.Http/tests/FunctionalTests/CompressedContentTest.cs Outdated
Comment thread src/libraries/System.Net.Http/tests/FunctionalTests/CompressedContentTest.cs Outdated
Comment thread src/libraries/System.Net.Http/tests/FunctionalTests/CompressedContentTest.cs Outdated
Comment thread src/libraries/System.Net.Http/ref/System.Net.Http.cs

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.

Comment thread src/libraries/System.Net.Http/src/System/Net/Http/GZipCompressedContent.cs Outdated
Comment thread src/libraries/System.Net.Http/src/System/Net/Http/BrotliCompressedContent.cs Outdated
Comment thread src/libraries/System.Net.Http/src/System/Net/Http/ZstandardCompressedContent.cs Outdated
Copilot AI review requested due to automatic review settings July 14, 2026 12:09

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.

Comment thread src/libraries/System.Net.Http/ref/System.Net.Http.cs

@ManickaP ManickaP left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!
:shipit:

@MihaZupan MihaZupan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good as-is, but we could also relatively easily avoid the couple extra allocations for the helper

Comment thread src/libraries/System.Net.Http/src/System/Net/Http/CompressedContentCore.cs Outdated
Copilot AI review requested due to automatic review settings July 15, 2026 09:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.

Comment thread src/libraries/System.Net.Http/ref/System.Net.Http.cs
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 15, 2026 09:39

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.

Comment thread src/libraries/System.Net.Http/ref/System.Net.Http.cs
Comment thread src/libraries/System.Net.Http/ref/System.Net.Http.cs
@MihaZupan MihaZupan added this to the 11.0.0 milestone Jul 15, 2026
@iremyux
iremyux merged commit 5c202f2 into dotnet:main Jul 15, 2026
85 of 88 checks passed
@dotnet-milestone-bot dotnet-milestone-bot Bot modified the milestones: 11.0.0, 11.0-preview7 Jul 16, 2026
rzikm added a commit that referenced this pull request Jul 20, 2026
…0802)

Follow-up on #130082 (I didn't get
a notification about that one so I didn't comment in time).

cc @iremyux

Open Question: What do we for user-provided
`ZstandardCompressionOptions`? should we prevent users from creating
non-compliant content?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants