Skip to content

Commit 824cf89

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 ebf5e86 commit 824cf89

File tree

2 files changed

+69
-1
lines changed

2 files changed

+69
-1
lines changed

src/http-gateways/path-gateway.md

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

258258
When both `Accept` HTTP header and `format` query parameter are present,
259-
`Accept` SHOULD take precedence.
259+
`format` SHOULD take precedence.
260260

261261
:::note
262262

src/ipips/ipip-0523.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
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.
59+
60+
## Test fixtures
61+
62+
Implementers can either write own test that prefers the format query param over
63+
any present Accept header, or run the [gateway-conformance](https://github.com/ipfs/gateway-conformance/)
64+
test suite, which includes tests for this scenario since [gateway-conformance/pull/252](https://github.com/ipfs/gateway-conformance/pull/252).
65+
66+
### Copyright
67+
68+
Copyright and related rights waived via [CC0](https://creativecommons.org/publicdomain/zero/1.0/).

0 commit comments

Comments
 (0)