WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Conversation

@lidel
Copy link
Member

@lidel lidel commented Dec 1, 2025

this change simplifies precedence rules by making the ?format= URL query parameter always take priority over the Accept HTTP header when both are present.

in practice, this is largely compatible with existing browser use cases since browsers send Accept headers with wildcards which were already treated as non-specific. prioritizing ?format= also ensures deterministic HTTP caching behavior, protecting against CDNs that commingle different response types under the same cache key.

the only breaking change is for edge cases where a client sends both a specific Accept header and a different ?format= value. previously Accept would win, now ?format= wins. this scenario is rare and arguably represents client misconfiguration. when detected, gateway returns HTTP 400 to signal the ambiguity.

TODO

…pt header

this change simplifies precedence rules by making the ?format= URL query
parameter always take priority over the Accept HTTP header when both are
present.

in practice, this is largely compatible with existing browser use cases
since browsers send Accept headers with wildcards which were already
treated as non-specific. prioritizing ?format= also ensures deterministic
HTTP caching behavior, protecting against CDNs that comingle different
response types under the same cache key.

the only breaking change is for edge cases where a client sends both a
specific Accept header and a different ?format= value. previously Accept
would win, now ?format= wins. this scenario is rare and arguably
represents client misconfiguration. when detected, gateway returns HTTP
400 to signal the ambiguity.

specs: ipfs/specs#523
tests: ipfs/gateway-conformance#252
@lidel lidel requested review from a team and achingbrain December 1, 2025 23:38
@codecov
Copy link

codecov bot commented Dec 1, 2025

Codecov Report

❌ Patch coverage is 92.85714% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 61.14%. Comparing base (23312e7) to head (e5b1562).

Files with missing lines Patch % Lines
gateway/handler_car.go 71.42% 1 Missing and 1 partial ⚠️

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1074      +/-   ##
==========================================
+ Coverage   61.10%   61.14%   +0.03%     
==========================================
  Files         264      264              
  Lines       26215    26231      +16     
==========================================
+ Hits        16019    16039      +20     
+ Misses       8519     8516       -3     
+ Partials     1677     1676       -1     
Files with missing lines Coverage Δ
gateway/handler.go 78.62% <100.00%> (+0.71%) ⬆️
gateway/handler_car.go 79.71% <71.42%> (-1.45%) ⬇️

... and 9 files with indirect coverage changes

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

lidel added a commit to ipfs/kubo that referenced this pull request Dec 2, 2025
update boxo to ipfs/boxo#1074 and gateway-conformance tests
to ipfs/gateway-conformance#252 for testing IPIP-523 changes
where ?format= URL query parameter takes precedence over
Accept HTTP header
lidel added a commit to ipfs/kubo that referenced this pull request Dec 2, 2025
update boxo to ipfs/boxo#1074 and gateway-conformance tests
to ipfs/gateway-conformance#252 for testing IPIP-523 changes
where ?format= URL query parameter takes precedence over
Accept HTTP header
remove HTTP 400 error for conflicting ?format and Accept values.
instead, ?format silently takes precedence, which is simpler and
less breaking for browser clients that send Accept headers automatically.
lidel added a commit to ipfs/kubo that referenced this pull request Dec 2, 2025
update boxo to ipfs/boxo#1074 and gateway-conformance tests
to ipfs/gateway-conformance#252 for testing IPIP-523 changes
where ?format= URL query parameter takes precedence over
Accept HTTP header
Copy link
Member Author

@lidel lidel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI with end-to-end tests at

are green.

AFAIK this PR is a low risk change (see Compatibility section in IPIP-523)

@lidel lidel marked this pull request as ready for review December 2, 2025 01:02
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