Skip to content

Tighten HTTP content negotiation semantics#161

Merged
alganet merged 1 commit into
Respect:masterfrom
alganet:accept-routines
Mar 17, 2026
Merged

Tighten HTTP content negotiation semantics#161
alganet merged 1 commit into
Respect:masterfrom
alganet:accept-routines

Conversation

@alganet

@alganet alganet commented Mar 17, 2026

Copy link
Copy Markdown
Member

Modernize the Accept* negotiation layer so it behaves more like HTTP clients expect while keeping the implementation centralized and small.

Changes:

  • make missing Accept, Accept-Language, Accept-Charset, and Accept-Encoding headers permissive by default
  • normalize negotiated header tokens before matching so parameterized media types like application/json; charset=utf-8 match cleanly
  • merge Vary metadata across chained negotiators instead of overwriting it
  • keep extension-based negotiation strict to the request URI while allowing wildcard fallback for normal header-based provisions
  • replace deprecated SplObjectStorage::contains() lookups with offsetExists() in negotiation routines
  • add regression tests for permissive missing Accept headers, parameterized Accept matching, merged Vary headers, and real 406 failures

Verification:

  • composer qa

Modernize the Accept* negotiation layer so it behaves more like HTTP
clients expect while keeping the implementation centralized and small.

Changes:
- make missing Accept, Accept-Language, Accept-Charset, and
  Accept-Encoding headers permissive by default
- normalize negotiated header tokens before matching so parameterized
  media types like application/json; charset=utf-8 match cleanly
- merge Vary metadata across chained negotiators instead of overwriting it
- keep extension-based negotiation strict to the request URI while allowing
  wildcard fallback for normal header-based provisions
- replace deprecated SplObjectStorage::contains() lookups with offsetExists()
  in negotiation routines
- add regression tests for permissive missing Accept headers, parameterized
  Accept matching, merged Vary headers, and real 406 failures

Verification:
- composer qa
@alganet alganet marked this pull request as ready for review March 17, 2026 21:29
@alganet alganet merged commit 77b5025 into Respect:master Mar 17, 2026
3 checks passed
@alganet alganet deleted the accept-routines branch March 17, 2026 21:33
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.34884% with 2 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (master@ef30510). Learn more about missing BASE report.
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
src/Routines/AbstractAccept.php 94.87% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##             master     #161   +/-   ##
=========================================
  Coverage          ?   96.13%           
  Complexity        ?      411           
=========================================
  Files             ?       27           
  Lines             ?     1010           
  Branches          ?        0           
=========================================
  Hits              ?      971           
  Misses            ?       39           
  Partials          ?        0           

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants