Skip to content

Commit 638c265

Browse files
committed
Trustless gateway spec/path gateways spec: update with probe-path comments
1 parent 9af8efd commit 638c265

File tree

2 files changed

+49
-45
lines changed

2 files changed

+49
-45
lines changed

src/http-gateways/path-gateway.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,8 @@ The request succeeded.
296296

297297
If the HTTP method was `GET`, then data is transmitted in the message body.
298298

299+
If the HTTP method was `HEAD`, then no body should be sent.
300+
299301
### `206` Partial Content
300302

301303
Partial Content: range request succeeded.
@@ -310,7 +312,9 @@ The new, canonical URL is returned in the [`Location`](#location-response-header
310312

311313
### `400` Bad Request
312314

313-
A generic client error returned when it is not possible to return a better one
315+
A generic client error returned when it is not possible to return a better
316+
one. For example, this can be used when the CID is malformed or its codec is
317+
unsupported.
314318

315319
### `404` Not Found
316320

@@ -641,9 +645,15 @@ Optional, present in certain response types:
641645

642646
### `Retry-After` (response header)
643647

644-
Gateway returns this header with error responses such as [`429 Too Many Requests`](#429-too-many-requests) or [`504 Gateway Timeout`](#504-gateway-timeout).
648+
Gateway SHOULD return this header with error responses such as [`429 Too Many Requests`](#429-too-many-requests), [`504 Gateway Timeout`](#504-gateway-timeout) or `503` (server maintainance).
649+
650+
The "Retry-After" header indicates how long the user agent ought to wait before making a follow-up request. It uses the following syntax:
645651

646-
The "Retry-After" header indicates how long the user agent ought to wait before making a follow-up request.
652+
```
653+
Retry-After: <http-date>
654+
// or
655+
Retry-After: <delay-seconds>
656+
```
647657

648658
See Section 10.2.3 of :cite[rfc9110].
649659

src/http-gateways/trustless-gateway.md

Lines changed: 36 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -39,24 +39,6 @@ The minimal implementation means:
3939

4040
A subset of "HTTP API" of :cite[path-gateway].
4141

42-
## `GET /ipfs/bafkqaaa`
43-
44-
`bafkqaaa` is the identity empty CID. This endpoint can be used to probe that that the endpoint corresponds to a trustless gateway.
45-
46-
For block requests (`?format=raw`), when supported, it must return `200 OK` and an empty body.
47-
48-
For CAR requests (`?format=car`), when supported, it must return `200 OK` and CAR file with root set to `bafkqaaa` and a single `bafkqaaa` block (which is empty).
49-
50-
We recommend supporting only this specific identity CID and not random identity CIDs.
51-
52-
## `HEAD /ipfs/bafkqaaa`
53-
54-
`bafkqaaa` is the identity empty CID. This endpoint can be used to probe that that the endpoint corresponds to a trustless gateway that correctly supports `HEAD` requests.
55-
56-
It must return `200 OK` in all cases.
57-
58-
We recommend supporting only this specific identity CID and not random identity CIDs.
59-
6042
## `GET /ipfs/{cid}[/{path}][?{params}]`
6143

6244
Downloads verifiable, content-addressed data for the specified **immutable** content path.
@@ -65,10 +47,14 @@ Optional `path` is permitted for requests that specify CAR format (`?format=car`
6547

6648
For block requests (`?format=raw` or `Accept: application/vnd.ipld.raw`), only `GET /ipfs/{cid}[?{params}]` is supported.
6749

50+
It is RECOMMENDED to additionally implement the [`GET` probe path](#dedicated-probe-paths).
51+
6852
## `HEAD /ipfs/{cid}[/{path}][?{params}]`
6953

7054
Same as GET, but does not return any payload.
7155

56+
It is RECOMMENDED to additionally implement the [`HEAD` probe path](#dedicated-probe-paths).
57+
7258
## `GET /ipns/{key}[?{params}]`
7359

7460
Downloads data at specified IPNS Key. Verifiable :cite[ipns-record] can be requested via `?format=ipns-record` or `Accept: application/vnd.ipfs.ipns-record`.
@@ -251,22 +237,7 @@ In case both are present in the request, the value from the [`Accept`](#accept-r
251237

252238
# HTTP Response
253239

254-
Below MUST be implemented **in addition** to "HTTP Response" of :cite[path-gateway].
255-
256-
## Status codes
257-
258-
Trustless gateways MUST return reasonable status codes.
259-
260-
* `200` for successful requests.
261-
* `4xx` for client errors.
262-
* `5xx` for server errors, server unavailability.
263-
264-
For example:
265-
266-
* A CID non retrievable from this gateway SHOULD return `404`
267-
* A blocked CID SHOULD return `410` or `451`.
268-
* A request with a malformed or unsupported CID SHOULD return `400`.
269-
* No `5xx` status should be used for client errors, like requesting an unexistent path under a CID.
240+
Below MUST be implemented **in addition** to "HTTP Response" of :cite[path-gateway], with special attention to the section relative to Response Status Codes.
270241

271242
## Response Headers
272243

@@ -290,14 +261,6 @@ Same as in :cite[path-gateway], SHOULD be returned when Trustless Gateway
290261
supports more than a single response format and the `format` query parameter is
291262
missing or does not match well-known format from `Accept` header.
292263

293-
### `Retry-After` (response header)
294-
295-
In conjuction with status code `429` (for rate limiting) and `503` (maintenance), the `Retry-After` header can be used to signal how long the user agent should wait before making a follow-up request. This is a [standard response header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After) with the following syntax:
296-
297-
```
298-
Retry-After: <http-date>
299-
Retry-After: <delay-seconds>
300-
```
301264

302265
# Block Responses (application/vnd.ipld.raw)
303266

@@ -480,3 +443,34 @@ returned as [application/vnd.ipfs.ipns-record](https://www.iana.org/assignments/
480443
A Client MUST confirm the record signature match `libp2p-key` from the requested IPNS Name.
481444

482445
A Client MUST [perform additional record verification according to the IPNS specification](https://specs.ipfs.tech/ipns/ipns-record/#record-verification).
446+
447+
# Notes for implementers
448+
449+
## Dedicated Probe Paths
450+
451+
Trustless gateways SHOULD provide probing endpoints as described below.
452+
453+
### `GET /ipfs/bafkqaaa`
454+
455+
`bafkqaaa` is the identity empty CID. This endpoint can be used to probe that
456+
that the endpoint corresponds to a trustless gateway.
457+
458+
For block requests (`?format=raw`), when supported, it must return `200 OK`
459+
and an empty body.
460+
461+
For CAR requests (`?format=car`), when supported, it must return `200 OK` and
462+
CAR file with root set to `bafkqaaa` and a single `bafkqaaa` block (which is
463+
empty).
464+
465+
We recommend supporting only this specific identity CID and not random
466+
identity CIDs.
467+
468+
### `HEAD /ipfs/bafkqaaa`
469+
470+
`bafkqaaa` is the identity empty CID. If this endpoint is enabled, the gateway
471+
MUST support [`HEAD` requests](#head-ipfs-cid-path-params).
472+
473+
It must return `200 OK` in all cases.
474+
475+
We recommend supporting only this specific identity CID and not random
476+
identity CIDs.

0 commit comments

Comments
 (0)