Skip to content

Commit

Permalink
trustless gateway spec: add probing path (identity cid).
Browse files Browse the repository at this point in the history
Add section about status codes.

Add section about Retry-After.
  • Loading branch information
hsanjuan committed Feb 12, 2025
1 parent f504d04 commit 9af8efd
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions src/http-gateways/trustless-gateway.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,24 @@ The minimal implementation means:

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

## `GET /ipfs/bafkqaaa`

`bafkqaaa` is the identity empty CID. This endpoint can be used to probe that that the endpoint corresponds to a trustless gateway.

For block requests (`?format=raw`), when supported, it must return `200 OK` and an empty body.

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).

We recommend supporting only this specific identity CID and not random identity CIDs.

## `HEAD /ipfs/bafkqaaa`

`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.

It must return `200 OK` in all cases.

We recommend supporting only this specific identity CID and not random identity CIDs.

## `GET /ipfs/{cid}[/{path}][?{params}]`

Downloads verifiable, content-addressed data for the specified **immutable** content path.
Expand Down Expand Up @@ -235,6 +253,21 @@ In case both are present in the request, the value from the [`Accept`](#accept-r

Below MUST be implemented **in addition** to "HTTP Response" of :cite[path-gateway].

## Status codes

Trustless gateways MUST return reasonable status codes.

* `200` for successful requests.
* `4xx` for client errors.
* `5xx` for server errors, server unavailability.

For example:

* A CID non retrievable from this gateway SHOULD return `404`
* A blocked CID SHOULD return `410` or `451`.
* A request with a malformed or unsupported CID SHOULD return `400`.
* No `5xx` status should be used for client errors, like requesting an unexistent path under a CID.

## Response Headers

### `Content-Type` (response header)
Expand All @@ -257,6 +290,15 @@ Same as in :cite[path-gateway], SHOULD be returned when Trustless Gateway
supports more than a single response format and the `format` query parameter is
missing or does not match well-known format from `Accept` header.

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

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:

```
Retry-After: <http-date>
Retry-After: <delay-seconds>
```

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

An opaque bytes matching the requested block CID
Expand Down

0 comments on commit 9af8efd

Please sign in to comment.