[release/10.0] Write gzip footer for resource-collection.js.gz - #66647
Merged
Conversation
Backport of dotnet#66242 The GZipStream must be fully disposed (not just flushed) before reading the underlying MemoryStream, otherwise the gzip footer is missing and the output is an incomplete gzip payload. Use a using block to ensure proper disposal. Added test to verify the gzip endpoint returns a complete, decompressible payload matching the uncompressed content endpoint. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Backports a fix to ensure the generated resource-collection.js.gz payload is a valid, complete gzip stream by guaranteeing the gzip trailer/footer is written before the bytes are cached and served.
Changes:
- Dispose
GZipStreambefore reading the underlyingMemoryStreamto ensure the gzip footer is written. - Add an endpoint test that requests the
.js.gzendpoint, decompresses the response, and verifies it matches the uncompressed.jspayload.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/Components/Endpoints/src/Builder/ResourceCollectionUrlEndpoint.cs | Fixes gzip byte generation by disposing GZipStream before calling ToArray(). |
| src/Components/Endpoints/test/Builder/ResourceCollectionUrlEndpointTest.cs | Adds coverage validating the .js.gz endpoint produces a decompressible payload matching the uncompressed endpoint. |
javiercn
approved these changes
May 11, 2026
lewing
approved these changes
May 11, 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.
Backport of #66242 to release/10.0
Description
The generated
resource-collection.js.gzpayload was read beforeGZipStreamdisposal completed, so the gzip footer was omitted and some clients/tools rejected the response as truncated.Update
CreateGzipBytesto disposeGZipStreambefore reading the underlyingMemoryStream. This ensures the final gzip trailer is written before the endpoint caches and serves the compressed bytes.Fixes #66218
Customer Impact
Some clients/tools rejected the response as truncated. See #66218
Regression?
[If yes, specify the version the behavior has regressed from]
Risk
We're just ensuring the gzip trailer is correctly written as expected.
Verification
Added unit test.
Packaging changes reviewed?