-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Fix incorrect Content-Length for swagger-ui and Redoc static assets #3488
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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;
Content-Lengthheader.Fixes #3486 and #3487.