Skip to content

Commit 8c22f1a

Browse files
committed
IPIP-0523: Prefer format request param over Accept header
Browsers will always send an Accept header so if present the format request param should take priority, not the other way round as the spec currently says.
1 parent 0a3d8e3 commit 8c22f1a

File tree

2 files changed

+84
-1
lines changed

2 files changed

+84
-1
lines changed

src/http-gateways/path-gateway.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ These are the equivalents:
240240
- `format=ipns-record``Accept: application/vnd.ipfs.ipns-record`
241241

242242
When both `Accept` HTTP header and `format` query parameter are present,
243-
`Accept` SHOULD take precedence.
243+
`format` SHOULD take precedence.
244244

245245
A Client SHOULD include the `format` query parameter in the request URL, in
246246
addition to the `Accept` header. This provides the best interoperability and

src/ipips/ipip-0523.md

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
---
2+
title: "IPIP-0523: Prefer format request param over Accept header"
3+
date: 2025-11-26
4+
ipip: proposal
5+
editors:
6+
- name: Alex Potsides
7+
github: achingbrain
8+
url: https://achingbrain.net
9+
affiliation:
10+
name: Shipyard
11+
url: https://ipshipyard.com
12+
relatedIssues:
13+
- https://github.com/ipfs/specs/issues/521
14+
order: 523
15+
tags: ['ipips']
16+
---
17+
18+
## Summary
19+
20+
Prefer the `format` request param over the Accept header
21+
22+
## Motivation
23+
24+
The [Accept](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Accept)
25+
header can be sent with an HTTP request to provide a prioritized list of
26+
response formats the client will accept for a given resource.
27+
28+
The [format](https://specs.ipfs.tech/http-gateways/path-gateway/#format-request-query-parameter)
29+
request query parameter can also be sent to an IPFS HTTP Gateway to provide the
30+
same information, and is typically done when sending an HTTP header is difficult
31+
or impractical, for example in a browser.
32+
33+
The existing [Path Gateway](https://specs.ipfs.tech/http-gateways/path-gateway/#format-request-query-parameter) and [Trustless Gateway](https://specs.ipfs.tech/http-gateways/trustless-gateway/#format-request-query-parameter) specs say:
34+
35+
> When both the Accept header and format parameter are present, a specific Accept value (e.g., application/vnd.ipld.raw) SHOULD take precedence over format.
36+
37+
This makes it impossible for browsers to use the `format` request query
38+
parameter, since they will always send an `Accept` header which would then cause
39+
the `format` request query parameter to be ignored.
40+
41+
## Detailed design
42+
43+
The priority of `format` vs `Accept` should be reversed, so as to always prefer
44+
`format` over `Accept` if it is present.
45+
46+
## Design rationale
47+
48+
Browsers will always send an `Accept` header that contains specific values so it
49+
cannot be allowed to take priority over the `format` request query parameter.
50+
51+
### User benefit
52+
53+
Users will be able to use the `format` request query parameter to control the
54+
response type of requests made from browser address bars.
55+
56+
### Compatibility
57+
58+
This is a breaking change, though several implementations implement this part of
59+
the spec incorrectly, already favouring `format` over `Accept` so the impact
60+
should be minimal.
61+
62+
### Security
63+
64+
It is highly advised to implement validation conformance tests using the fixtures
65+
included at the end of this IPIP.
66+
67+
### Alternatives
68+
69+
None.
70+
71+
## Test fixtures
72+
73+
:::note
74+
75+
Implementers can either write own test that prefers the format query param over
76+
any present Accept header, or run the [gateway-conformance](https://github.com/ipfs/gateway-conformance/)
77+
test suite, which includes tests for this scenario since [gateway-conformance/pull/252](https://github.com/ipfs/gateway-conformance/pull/252).
78+
79+
:::
80+
81+
### Copyright
82+
83+
Copyright and related rights waived via [CC0](https://creativecommons.org/publicdomain/zero/1.0/).

0 commit comments

Comments
 (0)