Skip to content

Conversation

@martincostello
Copy link
Collaborator

  • Fix incorrect length value being stored when embedded resources are not served compressed.
  • Extend integration tests to verify that the stream is the same length as the Content-Length header.

Fixes #3486 and #3487.

Extend integration tests to verify that the stream is the same length as the `Content-Length` header.

Relates to #3486.
Fix incorrect length value being stored when embedded resources are not served compressed.

Fixes #3486.
@martincostello martincostello added this to the v9.0.3 milestone Jul 8, 2025
@codecov
Copy link

codecov bot commented Jul 8, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.91%. Comparing base (577db5f) to head (413e3e0).

✅ 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           
Flag Coverage Δ
Linux 93.91% <100.00%> (ø)
Windows 93.91% <100.00%> (ø)
macOS 93.91% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@martincostello martincostello marked this pull request as ready for review July 8, 2025 13:52
Copilot AI review requested due to automatic review settings July 8, 2025 13:52
@martincostello martincostello merged commit 9eaf909 into master Jul 8, 2025
12 checks passed
@martincostello martincostello deleted the gh-3486 branch July 8, 2025 13:53
Copy link

Copilot AI left a 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 EmbeddedResourceProvider to set DecompressedLength correctly
  • Add assertions in Swagger UI and ReDoc integration tests to verify Content-Length matches 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 DecompressedLength should use decompressed.Length (the full uncompressed size) to aid future maintainers in understanding this assignment.
            entry.DecompressedLength = decompressed.Length;

This was referenced Jul 28, 2025
This was referenced Oct 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

2 participants