Fix incorrect Content-Length for swagger-ui and Redoc static assets#3488
Merged
martincostello merged 2 commits intomasterfrom Jul 8, 2025
Merged
Fix incorrect Content-Length for swagger-ui and Redoc static assets#3488martincostello merged 2 commits intomasterfrom
martincostello merged 2 commits intomasterfrom
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
✅ All tests successful. No failed tests found. Additional details and impacted files@@ Coverage Diff @@
## master #3488 +/- ##
=======================================
Coverage 93.91% 93.91%
=======================================
Files 110 110
Lines 3810 3810
Branches 723 723
=======================================
Hits 3578 3578
Misses 232 232
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull Request Overview
This PR ensures the Content-Length header reflects the actual length of embedded static assets by fixing the provider logic and adding test assertions.
- Update
EmbeddedResourceProviderto setDecompressedLengthcorrectly - Add assertions in Swagger UI and ReDoc integration tests to verify
Content-Lengthmatches the returned stream length
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerUIIntegrationTests.cs | Added Assert.Equal(response.Content.Headers.ContentLength, actual.Length) to both decompressed and GZip tests |
| test/Swashbuckle.AspNetCore.IntegrationTests/ReDocIntegrationTests.cs | Added Assert.Equal(response.Content.Headers.ContentLength, actual.Length) to both decompressed and GZip tests |
| src/Shared/EmbeddedResourceProvider.cs | Changed entry.DecompressedLength to use decompressed.Length instead of content.Length |
Comments suppressed due to low confidence (1)
src/Shared/EmbeddedResourceProvider.cs:154
- [nitpick] Add a brief comment explaining why
DecompressedLengthshould usedecompressed.Length(the full uncompressed size) to aid future maintainers in understanding this assignment.
entry.DecompressedLength = decompressed.Length;
test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerUIIntegrationTests.cs
Show resolved
Hide resolved
This was referenced Jul 28, 2025
This was referenced Feb 23, 2026
Open
Open
Open
Open
Bump Swashbuckle.AspNetCore from 5.6.3 to 10.1.4
vnikolaiev/skills-secure-repository-supply-chain#10
Open
Bump Swashbuckle.AspNetCore from 5.6.3 to 10.1.4
yewaleajay/skills-secure-repository-supply-chain#10
Open
Open
Open
Open
Open
Open
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.
Content-Lengthheader.Fixes #3486 and #3487.