Skip to content

Conversation

martincostello
Copy link
Collaborator

Fix Accept-Encoding parsing when there are multiple values or the value includes a quality.

See #3486 (comment).

Fix `Accept-Encoding` parsing when there are multiple values or the value includes a quality.

See #3486 (comment).
@martincostello martincostello added this to the v9.0.4 milestone Jul 8, 2025
@Copilot Copilot AI review requested due to automatic review settings July 8, 2025 22:19
@martincostello martincostello enabled auto-merge (rebase) July 8, 2025 22:19
Copy link

@Copilot 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 fixes how the middleware and its tests handle Accept-Encoding headers when there are multiple encoding values or quality parameters.

  • Expanded the integration test to use a [Theory] with several Accept-Encoding header permutations.
  • Updated IsGZipAccepted to rely on typed headers (GetTypedHeaders().AcceptEncoding) instead of raw string comparison.
  • Iterates header values properly to detect gzip offers.

Reviewed Changes

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

File Description
test/Swashbuckle.AspNetCore.IntegrationTests/ReDocIntegrationTests.cs Converted the single-case test to a parameterized theory and added multiple Accept-Encoding scenarios.
src/Shared/EmbeddedResourceProvider.cs Switched to typed headers for Accept-Encoding and updated the IsGZipAccepted method to loop through parsed values.

Copy link

codecov bot commented Jul 8, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.88%. Comparing base (525a8a3) to head (3912061).
Report is 1 commits behind head on master.

✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3492      +/-   ##
==========================================
- Coverage   93.91%   93.88%   -0.03%     
==========================================
  Files         110      110              
  Lines        3811     3812       +1     
  Branches      723      724       +1     
==========================================
  Hits         3579     3579              
- Misses        232      233       +1     
Flag Coverage Δ
Linux 93.88% <100.00%> (-0.03%) ⬇️
Windows 93.88% <100.00%> (-0.03%) ⬇️
macOS 93.88% <100.00%> (-0.03%) ⬇️

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 merged commit 3bff9ad into master Jul 8, 2025
11 of 12 checks passed
@martincostello martincostello deleted the fix-accept-encoding-handling branch July 8, 2025 22:23
This was referenced Aug 27, 2025
This was referenced Sep 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant