You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/http-gateways/path-gateway.md
+1-5Lines changed: 1 addition & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -595,11 +595,7 @@ The following response types require an explicit opt-in, can only be requested w
595
595
- Raw Block (`?format=raw`)
596
596
- Opaque bytes, see [application/vnd.ipld.raw](https://www.iana.org/assignments/media-types/application/vnd.ipld.raw).
597
597
- CAR (`?format=car`)
598
-
- A CAR file or a stream that contains all blocks required to trustlessly verify the requested content path query, see [application/vnd.ipld.car](https://www.iana.org/assignments/media-types/application/vnd.ipld.car) and :cite[trustless-gateway].
599
-
-**Note:** by default, block order in CAR response is not deterministic,
600
-
blocks can be returned in different order, depending on implementation
601
-
choices (traversal, speed at which blocks arrive from the network, etc).
602
-
An opt-in ordered CAR responses MAY be introduced in a future IPIP.
598
+
- A CAR file or a stream that contains all blocks required to trustlessly verify the requested content path query, see [application/vnd.ipld.car](https://www.iana.org/assignments/media-types/application/vnd.ipld.car) and Section 5 (CAR Responses) at :cite[trustless-gateway].
603
599
- TAR (`?format=tar`)
604
600
- Deserialized UnixFS files and directories as a TAR file or a stream, see :cite[ipip-0288].
@@ -25,31 +29,31 @@ The minimal implementation means:
25
29
26
30
- response type is always fully verifiable: client can decide between a raw block or a CAR stream
27
31
- no UnixFS/IPLD deserialization
28
-
- for CAR files:
29
-
- the behavior is identical to :cite[path-gateway]
30
32
- for raw blocks:
31
33
- data is requested by CID, only supported path is `/ipfs/{cid}`
32
34
- no path traversal or recursive resolution
35
+
- for CAR files:
36
+
- the pathing behavior is identical to :cite[path-gateway]
33
37
34
38
# HTTP API
35
39
36
40
A subset of "HTTP API" of :cite[path-gateway].
37
41
38
42
## `GET /ipfs/{cid}[/{path}][?{params}]`
39
43
40
-
Downloads verifiable data for the specified **immutable** content path.
44
+
Downloads verifiable, content-addressed data for the specified **immutable** content path.
41
45
42
-
Optional `path` is permitted for requests that specify CAR format (`application/vnd.ipld.car`).
46
+
Optional `path` is permitted for requests that specify CAR format (`?format=car` or `Accept: application/vnd.ipld.car`).
43
47
44
-
For RAW requests, only `GET /ipfs/{cid}[?{params}]` is supported.
48
+
For block requests (`?format=raw` or `Accept: application/vnd.ipld.raw`), only `GET /ipfs/{cid}[?{params}]` is supported.
45
49
46
50
## `HEAD /ipfs/{cid}[/{path}][?{params}]`
47
51
48
52
Same as GET, but does not return any payload.
49
53
50
54
## `GET /ipns/{key}[?{params}]`
51
55
52
-
Downloads data at specified IPNS Key. Verifiable :cite[ipns-record] can be requested via `?format=ipns-record`
56
+
Downloads data at specified IPNS Key. Verifiable :cite[ipns-record] can be requested via `?format=ipns-record` or `Accept: application/vnd.ipfs.ipns-record`.
53
57
54
58
## `HEAD /ipns/{key}[?{params}]`
55
59
@@ -63,17 +67,26 @@ Same as in :cite[path-gateway], but with limited number of supported response ty
63
67
64
68
### `Accept` (request header)
65
69
66
-
This HTTP header is required when running in a strict, trustless mode.
70
+
A Client SHOULD send this HTTP header to leverage content type negotiation
71
+
based on section 12.5.1 of :cite[rfc9110].
72
+
73
+
Below response types MUST be supported:
67
74
68
-
Below response types MUST to be supported:
69
-
-[application/vnd.ipld.raw](https://www.iana.org/assignments/media-types/application/vnd.ipld.raw) – requests a single, verifiable raw block to be returned
-[application/vnd.ipld.car](https://www.iana.org/assignments/media-types/application/vnd.ipld.car) – disables IPLD/IPFS deserialization, requests a verifiable CAR stream to be returned
73
-
-[application/vnd.ipfs.ipns-record](https://www.iana.org/assignments/media-types/application/vnd.ipfs.ipns-record) – requests a verifiable :cite[ipns-record] (multicodec `0x0300`).
78
+
Below response types SHOULD be supported:
74
79
75
-
Gateway SHOULD return HTTP 400 Bad Request when running in strict trustless
76
-
mode (no deserialized responses) and `Accept` header is missing.
field MUST match the `version` parameter returned in `Content-Type` header.
210
225
211
-
####CAR roots
226
+
## CAR roots
212
227
213
228
The behavior associated with the
214
229
[`CarV1Header.roots`](https://ipld.io/specs/transport/car/carv1/#header) field
215
230
is not currently specified.
216
231
217
-
Clients MAY ignore it.
232
+
The lack of standard here means a client MUST assume different Gateways could return a different value.
233
+
234
+
A Client SHOULD ignore this field.
218
235
219
236
:::issue
220
237
221
238
As of 2023-06-20, the behavior of the `roots` CAR field remains an [unresolved item within the CARv1 specification](https://web.archive.org/web/20230328013837/https://ipld.io/specs/transport/car/carv1/#unresolved-items).
222
239
223
240
:::
224
241
225
-
#### CAR determinism
242
+
## CAR `order` (content type parameter)
243
+
244
+
The `order` parameter allows clients to specify the desired block order in the
order, enables streaming responses with minimal memory usage.
249
+
-`unk` (or missing): Unknown order, which serves as the implicit default when the `order`
250
+
parameter is unspecified. In this case, the client cannot make any assumptions
251
+
about the block order: blocks may arrive in a random order or be a result of
252
+
a custom DAG traversal algorithm.
253
+
254
+
A Gateway SHOULD always return explicit `order` in CAR's `Content-Type` response header.
255
+
256
+
A Gateway MAY skip `order` in CAR response if no order was explicitly requested
257
+
by the client and the default order is unknown.
258
+
259
+
A Client MUST assume implicit `order=unk` when `order` is missing, unknown, or empty.
260
+
261
+
## CAR `dups` (content type parameter)
262
+
263
+
The `dups` parameter specifies whether duplicate blocks (the same block
264
+
occurring multiple times in the requested DAG) will be present in the CAR
265
+
response. Useful when a deterministic block order is used.
266
+
267
+
It accepts two values:
268
+
-`y`: Duplicate blocks MUST be sent every time they occur during the DAG walk.
269
+
-`n`: Duplicate blocks MUST be sent only once.
270
+
271
+
When set to `y`, light clients are able to discard blocks after
272
+
reading them, removing the need for caching in-memory or on-disk.
273
+
274
+
Setting to `n` allows for more efficient data transfer of certain types of
275
+
data, but introduces additional resource cost on the receiving end, as each
276
+
block needs to be kept around in case its CID appears again.
277
+
278
+
If the `dups` parameter is absent from the `Accept` request header, the
279
+
behavior is unspecified. In such cases, a Gateway should respond with `dups=n`
280
+
if it has control over the duplicate status, or without `dups` parameter if it
281
+
does not.
282
+
Defaulting to the inclusion of duplicate blocks (`dups=y`) SHOULD only be
283
+
implemented by Gateway systems that exclusively support `dups=y` and do not
284
+
support any other behavior.
285
+
286
+
A Client MUST not assume any implicit behavior when `dups` is missing.
287
+
288
+
If the `dups` parameter is absent from the `Content-Type` response header, the
289
+
behavior is unspecified, and the CAR response includes an arbitrary list of
290
+
blocks. In this unknown state, the client MUST assume duplicates are not sent,
291
+
but also MUST ignore duplicates and other unexpected blocks if they are present.
292
+
293
+
A Gateway MUST always return `dups` in `Content-Type` response header
294
+
when the duplicate status is known at the time of processing the request.
295
+
A Gateway SHOULD not return `dups` if determining the duplicate status is not
296
+
possible at the time of processing the request.
297
+
298
+
A Gateway MUST NOT include virtual blocks identified by identity CIDs
299
+
(multihash with `0x00` code) in CAR responses. This exclusion applies regardless
300
+
of their presence in the DAG or the value assigned to the "dups" parameter, as
301
+
the raw data is already present in the parent block that links to the identity
302
+
CID.
226
303
227
-
The default CAR header and block order in a CAR response is not specified and is non-deterministic.
304
+
## CAR format parameters and determinism
305
+
306
+
The default header and block order in a CAR format is not specified by IPLD specifications.
228
307
229
308
Clients MUST NOT assume that CAR responses are deterministic (byte-for-byte identical) across different gateways.
230
309
231
310
Clients MUST NOT assume that CAR includes CIDs and their blocks in the same order across different gateways.
232
311
312
+
Clients MUST assume block order and duplicate status only if `Content-Type` returned with CAR responses includes optional `order` or `dups` parameters, as specified by :cite[ipip-0412].
313
+
314
+
A Gateway SHOULD support some aspects of determinism by implementing content type negotiation and signaling via `Accept` and `Content-Type` headers.
315
+
233
316
:::issue
234
317
235
-
In controlled environments, clients MAY choose to rely on undocumented CAR determinism,
236
-
subject to the agreement of the following conditions between the client and the
237
-
gateway:
318
+
In controlled environments, clients MAY choose to rely on implicit and
319
+
undocumented CAR determinism, subject to the agreement of the following
320
+
conditions between the client and the gateway:
238
321
- CAR version
239
322
- content of [`CarV1Header.roots`](https://ipld.io/specs/transport/car/carv1/#header) field
240
-
- order of blocks
241
-
- status of duplicate blocks
323
+
- order of blocks (`order` from :cite[ipip-0412])
324
+
- status of duplicate blocks (`dups` from :cite[ipip-0412])
242
325
243
-
In the future, there may be an introduction of a convention to indicate aspects
244
-
of determinism in CAR responses. Please refer to
245
-
[IPIP-412](https://github.com/ipfs/specs/pull/412) for potential developments
246
-
in this area.
326
+
Mind this is undocumented behavior, and MUST NOT be used on public networks.
247
327
248
328
:::
329
+
330
+
### CAR format signaling in Request
331
+
332
+
Content type negotiation is based on section 12.5.1 of :cite[rfc9110].
333
+
334
+
Clients MAY indicate their preferred block order by sending an `Accept` header in
335
+
the HTTP request. The `Accept` header format is as follows:
Gateway implementations SHOULD decide on the implicit default ordering or
366
+
other parameters, and use it in responses when client did not explicitly
367
+
specify any matching preference.
368
+
369
+
A Gateway MAY choose to implement only some parameters and return HTTP
370
+
400 Bad Request or 406 Not Acceptable when a client requested a response with
371
+
unsupported content type variant.
372
+
373
+
A Client MUST verify `Content-Type` returned with CAR response before
374
+
processing the payload, as the legacy gateway may not support optional content
375
+
type parameters like `order` an `dups` and return plain
376
+
`application/vnd.ipld.car`.
377
+
378
+
# IPNS Record Responses (application/vnd.ipfs.ipns-record)
379
+
380
+
An opaque bytes matching the [Signed IPNS Record](https://specs.ipfs.tech/ipns/ipns-record/#ipns-record)
381
+
for the requested [IPNS Name](https://specs.ipfs.tech/ipns/ipns-record/#ipns-name)
382
+
returned as [application/vnd.ipfs.ipns-record](https://www.iana.org/assignments/media-types/application/vnd.ipfs.ipns-record).
383
+
384
+
A Client MUST confirm the record signature match `libp2p-key` from the requested IPNS Name.
385
+
386
+
A Client MUST [perform additional record verification according to the IPNS specification](https://specs.ipfs.tech/ipns/ipns-record/#record-verification).
0 commit comments