Skip to content

Commit

Permalink
chore: update format and accept docs
Browse files Browse the repository at this point in the history
updating example to match SHOULD from specs
ipfs/specs#478
  • Loading branch information
lidel committed Jul 8, 2024
1 parent fe522fe commit f0ca64a
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions docs/reference/http/gateway.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,28 +60,28 @@ This mode of operation removes the need for trusting gateway returns correct dat

#### Example: fetching an entire DAG as a CAR stream from a public gateway

Using `Accept` HTTP header with [application/vnd.ipld.car](https://www.iana.org/assignments/media-types/application/vnd.ipld.car) type:
To request [application/vnd.ipld.car](https://www.iana.org/assignments/media-types/application/vnd.ipld.car) response type:

```bash
$ curl -H "Accept: application/vnd.ipld.car" "https://ipfs.io/ipfs/bafybeiakou6e7hnx4ms2yangplzl6viapsoyo6phlee6bwrg4j2xt37m3q" > dag.car
$ curl -H "Accept: application/vnd.ipld.car" "https://ipfs.io/ipfs/bafybeiakou6e7hnx4ms2yangplzl6viapsoyo6phlee6bwrg4j2xt37m3q?format=car" -L > dag.car
$ ipfs dag import dag.car
```

::: tip

An alternative is to pass `?format=car` URL parameter:
A Client SHOULD include the [`format` query parameter](https://specs.ipfs.tech/http-gateways/trustless-gateway/#format-request-query-parameter) in the request URL, ideally in addition to the [`Accept` header](https://specs.ipfs.tech/http-gateways/trustless-gateway/#accept-request-header). This provides the best interoperability and ensures consistent HTTP cache behavior across various gateway implementations.

<https://ipfs.io/ipfs/bafybeiakou6e7hnx4ms2yangplzl6viapsoyo6phlee6bwrg4j2xt37m3q?format=car>

:::
:::

::: tip Verify CAR without running full IPFS node

CAR verification does not require running IPFS node. Clients can leverage standalone tools and libraries such as [ipfs-car](https://www.npmjs.com/package/ipfs-car):

```bash
$ npm i -g ipfs-car
$ curl "https://ipfs.io/ipfs/bafybeiakou6e7hnx4ms2yangplzl6viapsoyo6phlee6bwrg4j2xt37m3q?format=car" | ipfs-car
$ curl "https://ipfs.io/ipfs/bafybeiakou6e7hnx4ms2yangplzl6viapsoyo6phlee6bwrg4j2xt37m3q?format=car" -L | ipfs-car
$ ls ./bafybeiakou6e7hnx4ms2yangplzl6viapsoyo6phlee6bwrg4j2xt37m3q/
1007 - Sustainable - alt.txt
1007 - Sustainable - transcript.txt
Expand All @@ -92,18 +92,17 @@ $ ls ./bafybeiakou6e7hnx4ms2yangplzl6viapsoyo6phlee6bwrg4j2xt37m3q/

#### Example: fetching a single raw block from a public gateway

Using `Accept` HTTP header with [application/vnd.ipld.raw](https://www.iana.org/assignments/media-types/application/vnd.ipld.raw) type:
To request [application/vnd.ipld.raw](https://www.iana.org/assignments/media-types/application/vnd.ipld.raw) response type:

```bash
$ curl -H "Accept: application/vnd.ipld.raw" "https://ipfs.io/ipfs/bafybeigdyrzt5sfp7udm7hu76uh7y26nf3efuylqabf3oclgtqy55fbzdi" > raw-block.bin
$ curl -H "Accept: application/vnd.ipld.raw" "https://ipfs.io/ipfs/bafybeigdyrzt5sfp7udm7hu76uh7y26nf3efuylqabf3oclgtqy55fbzdi?format=raw" -L > raw-block.bin
$ ipfs block put raw-block.bin
bafybeigdyrzt5sfp7udm7hu76uh7y26nf3efuylqabf3oclgtqy55fbzdi
```


::: tip

An alternative is to pass `?format=raw` URL parameter:
A Client SHOULD include the [`format` query parameter](https://specs.ipfs.tech/http-gateways/trustless-gateway/#format-request-query-parameter) in the request URL, ideally in addition to the [`Accept` header](https://specs.ipfs.tech/http-gateways/trustless-gateway/#accept-request-header). This provides the best interoperability and ensures consistent HTTP cache behavior across various gateway implementations.

<https://ipfs.io/ipfs/bafybeigdyrzt5sfp7udm7hu76uh7y26nf3efuylqabf3oclgtqy55fbzdi?format=raw>

Expand Down

0 comments on commit f0ca64a

Please sign in to comment.