-
-
Couldn't load subscription status.
- Fork 1.3k
Fix Accept-Encoding parsing
#3492
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
Fix `Accept-Encoding` parsing when there are multiple values or the value includes a quality. See #3486 (comment).
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 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 severalAccept-Encodingheader permutations. - Updated
IsGZipAcceptedto rely on typed headers (GetTypedHeaders().AcceptEncoding) instead of raw string comparison. - Iterates header values properly to detect
gzipoffers.
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. |
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 #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
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:
|
Updated [swashbuckle.aspnetcore.cli](https://github.com/domaindrivendev/Swashbuckle.AspNetCore) from 9.0.3 to 9.0.6. <details> <summary>Release notes</summary> _Sourced from [swashbuckle.aspnetcore.cli's releases](https://github.com/domaindrivendev/Swashbuckle.AspNetCore/releases)._ ## 9.0.6 ## What's Changed * Bump redoc from 2.5.0 to 2.5.1 by @dependabot in domaindrivendev/Swashbuckle.AspNetCore#3587 * Bump swagger-ui from 5.29.1 to 5.29.2 by @dependabot in domaindrivendev/Swashbuckle.AspNetCore#3595 **Full Changelog**: domaindrivendev/Swashbuckle.AspNetCore@v9.0.5...v9.0.6 ## 9.0.5 ## What's Changed * .NET 10 preparation by @martincostello in domaindrivendev/Swashbuckle.AspNetCore#3565 * Update NuGet packages by @martincostello in domaindrivendev/Swashbuckle.AspNetCore#3573 * Fix anchors by @martincostello in domaindrivendev/Swashbuckle.AspNetCore#3577 * Bump swagger-ui-dist from 5.27.1 to 5.29.1 **Full Changelog**: domaindrivendev/Swashbuckle.AspNetCore@v9.0.4...v9.0.5 ## 9.0.4 ## What's Changed * Fix incorrect `ETag` values by @martincostello in domaindrivendev/Swashbuckle.AspNetCore#3490 * Fix `Accept-Encoding` parsing by @martincostello in domaindrivendev/Swashbuckle.AspNetCore#3492 * Check `Accept-Encoding` quality by @martincostello in domaindrivendev/Swashbuckle.AspNetCore#3493 * Update xunit packages by @martincostello in domaindrivendev/Swashbuckle.AspNetCore#3500 * Add release notes configuration by @martincostello in domaindrivendev/Swashbuckle.AspNetCore#3502 * Simplify release workflow by @martincostello in domaindrivendev/Swashbuckle.AspNetCore#3503 * Bump xunit dependencies by @martincostello in domaindrivendev/Swashbuckle.AspNetCore#3508 * Update NuGet dependencies by @martincostello in domaindrivendev/Swashbuckle.AspNetCore#3513 * Remove `WebHost` usage from tests by @martincostello in domaindrivendev/Swashbuckle.AspNetCore#3517 * Fix typos by @martincostello in domaindrivendev/Swashbuckle.AspNetCore#3520 * Sign-off commits by @martincostello in domaindrivendev/Swashbuckle.AspNetCore#3526 * Add zizmor by @martincostello in domaindrivendev/Swashbuckle.AspNetCore#3528 * Fix permissions by @martincostello in domaindrivendev/Swashbuckle.AspNetCore#3529 * Bump zizmor by @martincostello in domaindrivendev/Swashbuckle.AspNetCore#3535 * Add default `$type` discriminator for `[JsonPolymorphic]` by @lilinus in domaindrivendev/Swashbuckle.AspNetCore#3496 * Update NuGet dependencies by @martincostello in domaindrivendev/Swashbuckle.AspNetCore#3545 ## New Contributors * @lilinus made their first contribution in domaindrivendev/Swashbuckle.AspNetCore#3496 **Full Changelog**: domaindrivendev/Swashbuckle.AspNetCore@v9.0.3...v9.0.4 Commits viewable in [compare view](domaindrivendev/Swashbuckle.AspNetCore@v9.0.3...v9.0.6). </details> [](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) </details> Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Fix
Accept-Encodingparsing when there are multiple values or the value includes a quality.See #3486 (comment).