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,11 +29,12 @@ 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]
37
+
33
38
34
39
# HTTP API
35
40
@@ -63,13 +68,14 @@ Same as in :cite[path-gateway], but with limited number of supported response ty
63
68
64
69
### `Accept` (request header)
65
70
66
-
This HTTP header is required when running in a strict, trustless mode.
71
+
A Client SHOULD sent this HTTP header to leverage content type negotiation
72
+
based on section 12.5.1 of :cite[rfc9110].
67
73
68
74
Below response types MUST to be supported:
69
75
-[application/vnd.ipld.raw](https://www.iana.org/assignments/media-types/application/vnd.ipld.raw) – requests a single, verifiable raw block to be returned
70
76
71
77
Below response types SHOULD to be supported:
72
-
-[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, implementations MAY support optional parameters (:cite[ipip-0412])
78
+
-[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, implementations MAY support optional CAR content type parameters (:cite[ipip-0412])
73
79
-[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`).
74
80
75
81
Gateway SHOULD return HTTP 400 Bad Request when running in strict trustless
@@ -175,28 +181,29 @@ For example: `Content-Type: application/vnd.ipld.car; version=1`
175
181
176
182
MUST be returned and set to `attachment` to ensure requested bytes are not rendered by a web browser.
order, enables streaming responses with minimal memory usage.
227
+
-`unk` or missing: Unknown order, which serves as the implicit default when the `order`
228
+
parameter is missing. In this case, the client cannot make any assumptions
229
+
about the block order: blocks may arrive in a random order or be a result of
230
+
a custom DAG traversal algorithm.
231
+
232
+
A Gateway SHOULD always return explicit `order` in CAR's `Content-Type` response header.
233
+
234
+
A Gateway MAY skip `order` in CAR response if no order was explicitly requested
235
+
by the client and the default order is unknown.
236
+
237
+
A Client MUST assume implicit `order=unk` when `order` is missing, unknown, or empty.
238
+
239
+
## CAR `dups` (content type parameter)
240
+
241
+
The `dups` parameter specifies whether duplicate blocks (the same block
242
+
occurring multiple times in the requested DAG) will be present in the CAR
243
+
response. Useful when a deterministic block order is used.
244
+
245
+
It accepts two values:
246
+
-`y`: Duplicate blocks MUST be sent every time they occur during the DAG walk.
247
+
-`n`: Duplicate blocks MUST be sent only once.
248
+
249
+
When set to `y`, light clients are able to discard blocks after
250
+
reading them, removing the need for caching in-memory or on-disk.
251
+
252
+
Setting to `n` allows for more efficient data transfer of certain types of
253
+
data, but introduces additional resource cost on the receiving end, as each
254
+
block needs to be kept around in case its CID appears again.
255
+
256
+
A Client MUST not assume any implicit behavior when `dups` is missing.
257
+
258
+
If the `dups` parameter is not present in the `Content-Type` header, the
259
+
behavior is unspecified, and the CAR response includes an arbitrary list of
260
+
blocks. In this unknown state, the client MUST assume `n` as the default, but
261
+
also MUST ignore duplicates if they are present.
262
+
263
+
A Gateway MUST return always return `dups` in `Content-Type` response header
264
+
when the duplicate status is known at the time of response.
265
+
266
+
A Gateway MAY skip `dups` if it was not present in `Accept` header sent by the
267
+
client or if it is not possible to tell the duplicate status.
268
+
269
+
:::warning
270
+
271
+
The specified parameter does not apply to virtual blocks identified by identity
272
+
CIDs. CAR responses MUST never include these virtual blocks. The parameter in
273
+
question is meant to control the behavior of non-virtual blocks in the
274
+
response. Therefore, it does not have any effect on virtual blocks, and they
275
+
should never be included in the CAR response, no matter if present, or what
276
+
value is set.
277
+
278
+
:::
279
+
280
+
281
+
## CAR parameters and determinism
214
282
215
-
The default CAR header and block order in a CAR response is not specified and is non-deterministic.
283
+
The default header and block order in a CAR format is not specified by IPLD specifications.
216
284
217
285
Clients MUST NOT assume that CAR responses are deterministic (byte-for-byte identical) across different gateways.
218
286
219
287
Clients MUST NOT assume that CAR includes CIDs and their blocks in the same order across different gateways.
220
288
289
+
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].
290
+
291
+
A Gateway SHOULD support some aspects of determinism by implementing content type negotiation and signaling via `Accept` and `Content-Type` headers.
292
+
221
293
:::issue
222
294
223
-
In controlled environments, clients MAY choose to rely on undocumented CAR determinism,
224
-
subject to the agreement of the following conditions between the client and the
225
-
gateway:
295
+
In controlled environments, clients MAY choose to rely on implicit and
296
+
undocumented CAR determinism, subject to the agreement of the following
297
+
conditions between the client and the gateway:
226
298
- CAR version
227
299
- content of [`CarV1Header.roots`](https://ipld.io/specs/transport/car/carv1/#header) field
228
-
- order of blocks
229
-
- status of duplicate blocks
300
+
- order of blocks (`order` from :cite[ipip-0412])
301
+
- status of duplicate blocks (`dups` from :cite[ipip-0412])
230
302
231
-
In the future, there may be an introduction of a convention to indicate aspects
232
-
of determinism in CAR responses. Please refer to
233
-
[IPIP-412](https://github.com/ipfs/specs/pull/412) for potential developments
234
-
in this area.
303
+
Mind this is undocumented behavior, and MUST NOT be used on public networks.
235
304
236
305
:::
306
+
307
+
### CAR format signaling in Request
308
+
309
+
Content type negotiation is based on section 12.5.1 of :cite[rfc9110].
310
+
311
+
Clients MAY indicate their preferred block order by sending an `Accept` header in
312
+
the HTTP request. The `Accept` header format is as follows:
Gateway implementations SHOULD decide on the implicit default ordering or
343
+
other parameters, and use it in responses when client did not explicitly
344
+
specify any matching preference.
345
+
346
+
A Gateway MAY choose to implement only some of the parameters and return HTTP
347
+
400 Bad Request or 406 Not Acceptable when client requested a response with
348
+
unsupported content type variant.
349
+
350
+
A Client MUST verify `Content-Type` returned with CAR response before
351
+
processing the payload, as the legacy gateway may not support optional content
352
+
type parameters like `order` an `dups` and return plain
353
+
`application/vnd.ipld.car`.
354
+
355
+
356
+
# IPNS Record Responses (application/vnd.ipfs.ipns-record)
357
+
358
+
An opaque bytes matching the [Signed IPNS Record](https://specs.ipfs.tech/ipns/ipns-record/#ipns-record)
359
+
for the requested [IPNS Name](https://specs.ipfs.tech/ipns/ipns-record/#ipns-name)
360
+
returned as [application/vnd.ipfs.ipns-record](https://www.iana.org/assignments/media-types/application/vnd.ipfs.ipns-record).
361
+
362
+
A Client MUST confirm the record signature match `libp2p-key` from the requested IPNS Name.
363
+
364
+
A Client MUST [perform additional record verification according to the IPNS specification](https://specs.ipfs.tech/ipns/ipns-record/#record-verification).
0 commit comments