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
Trustless gateways, particularly non-recursive ones serving from a local block
118
+
store, are well-suited for :cite[path-gateway]'s `Cache-Control: only-if-cached`
119
+
request header. When received, gateway SHOULD return HTTP 412 if the root block
120
+
is not immediately available.
121
+
111
122
## Request Query Parameters
112
123
113
124
### :dfn[`format`] (request query parameter)
@@ -123,15 +134,19 @@ A Client SHOULD include the `format` query parameter in the request URL, in
123
134
addition to the `Accept` header. This provides the best interoperability and
124
135
ensures consistent HTTP cache behavior across various gateway implementations.
125
136
137
+
When both the `Accept` header and `format` parameter are present, a specific
138
+
`Accept` value (e.g., `application/vnd.ipld.raw`) SHOULD take precedence over
139
+
`format`. Wildcards (e.g., `*/*`, `application/*`) are not specific and do not
140
+
take precedence (as specified in :cite[path-gateway]).
141
+
126
142
:::
127
143
128
144
### :dfn[`dag-scope`] (request query parameter)
129
145
130
146
Optional, `dag-scope=(block|entity|all)` with default value `all`, only available for CAR requests.
131
147
132
148
Describes the shape of the DAG fetched the terminus of the specified path whose blocks
133
-
are included in the returned CAR file after the blocks required to traverse
134
-
path segments.
149
+
are included in the returned CAR stream after the blocks required to traverse path segments.
135
150
136
151
-`block` - Only the root block at the end of the path is returned after blocks
137
152
required to verify the specified path segments.
@@ -248,6 +263,34 @@ Below MUST be implemented **in addition** to "HTTP Response" of
248
263
:cite[path-gateway], with special attention to the "Response Status Codes" and
249
264
the "Recursive vs non-recursive gateways" sections.
250
265
266
+
## Response Status Codes
267
+
268
+
Trustless Gateways MUST follow the response status codes defined in :cite[path-gateway], including:
269
+
270
+
### `404 Not Found`
271
+
272
+
A Trustless Gateway MUST return `404 Not Found` when the **root block** (the CID in the request path) is not available in the gateway's storage.
273
+
274
+
This applies to:
275
+
- HEAD requests for any CID
276
+
- GET requests for raw blocks (`application/vnd.ipld.raw`)
277
+
- GET requests for CAR streams (`application/vnd.ipld.car`) when the root block is missing
278
+
279
+
For non-recursive Trustless Gateways (such as those serving from a local block store), this definitively signals that the requested content is not part of the gateway's dataset.
280
+
281
+
### Streaming and Missing Child Blocks
282
+
283
+
For CAR responses, once a gateway begins streaming (after successfully loading the root block), it has committed to HTTP `200 OK`. If a child block is encountered as missing during DAG traversal:
284
+
285
+
- The gateway SHOULD terminate the stream (potentially with an incomplete CAR)
286
+
- Clients MUST verify CAR completeness and handle incomplete streams as retrieval failures
287
+
288
+
This follows the streaming principle stated in the [`entity-bytes`](#entity-bytes-request-query-parameter) section above.
289
+
290
+
### `500 Internal Server Error`
291
+
292
+
A Trustless Gateway SHOULD return `500 Internal Server Error` only for genuine server errors, not for content unavailability. Examples include storage backend failures, resource exhaustion, or unexpected internal errors.
293
+
251
294
## Response Headers
252
295
253
296
### `Content-Type` (response header)
@@ -264,12 +307,33 @@ If a CAR stream was requested:
264
307
265
308
MUST be returned and set to `attachment` to ensure requested bytes are not rendered by a web browser.
266
309
310
+
When no custom `filename` is provided:
311
+
- CAR responses should use `filename="<cid>.car"`
312
+
- Raw block responses should use `filename="<cid>.bin"`
313
+
267
314
### `Content-Location` (response header)
268
315
269
316
Same as in :cite[path-gateway], SHOULD be returned when Trustless Gateway
270
317
supports more than a single response format and the `format` query parameter is
271
318
missing or does not match well-known format from `Accept` header.
272
319
320
+
### `Etag` (response header)
321
+
322
+
MUST be returned and follow the recommendations in :cite[path-gateway].
323
+
324
+
:::note
325
+
326
+
**Implementation Variance**: Etag generation for CAR responses is
327
+
implementation-specific. Different gateways may generate different Etags for
328
+
identical requests due to variations in what parameters are included (e.g.,
329
+
`order`, `dups`) and how they are encoded in the Etag calculation.
330
+
331
+
As a result, `If-None-Match` conditional requests may not work across different
332
+
gateway implementations. Clients SHOULD NOT assume Etags are portable between
333
+
gateways.
334
+
335
+
:::
336
+
273
337
# Block Responses (application/vnd.ipld.raw)
274
338
275
339
An opaque bytes matching the requested block CID
@@ -466,7 +530,7 @@ that the endpoint corresponds to a trustless gateway.
466
530
For block requests (signaled by `?format=raw` and `Accept: application/vnd.ipld.raw`), when supported, it MUST return `200 OK`
467
531
and an empty body.
468
532
469
-
For CAR requests (signaled by `?format=car` and `Accept: application/vnd.ipld.car`), when supported, it MUST return `200 OK` and a valid CAR file with CAR Header `roots` set to `bafkqaaa`. Identity block MAY be skipped in the CAR Data section.
533
+
For CAR requests (signaled by `?format=car` and `Accept: application/vnd.ipld.car`), when supported, it MUST return `200 OK` and a valid CAR with CAR Header `roots` set to `bafkqaaa`. Identity block MAY be skipped in the CAR Data section.
470
534
471
535
This specific identity CID is special for probing. Other random
0 commit comments