-
Notifications
You must be signed in to change notification settings - Fork 233
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ipip-425: Signaling Features on HTTP Gateways
Initial version to kick-off discussion
- Loading branch information
Showing
2 changed files
with
132 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
--- | ||
title: "IPIP-0425: Signaling Features on HTTP Gateways" | ||
date: 2023-07-06 | ||
ipip: proposal | ||
editors: | ||
- name: Marcin Rataj | ||
github: lidel | ||
url: https://lidel.org/ | ||
relatedIssues: | ||
- https://github.com/ipfs/specs/pull/402#pullrequestreview-1396116569 | ||
- https://github.com/ipfs/specs/pull/412#pullrequestreview-1427137365 | ||
order: 425 | ||
tags: ['ipips'] | ||
--- | ||
|
||
## Summary | ||
|
||
Add ability to query HTTP Gateway for an explicit list of supported features. | ||
|
||
## Motivation | ||
|
||
A Gateway always ships with an opinionated set of supported hash functions and | ||
IPLD codecs, and the differences between implementations will grow over time. | ||
|
||
For example, some legacy gateways may not support newly added features like | ||
`dag-scope` and `entity-bytes` from :cite[ipip-0402] or the ability to get some | ||
block ordering guarantees introduced in :cite[ipip-0412]. Future IPIPs may add | ||
more features and response formats. | ||
|
||
We need a light mechanism for clients to detect which gateway supports partial CARs | ||
|
||
## Detailed design | ||
|
||
This IPIP introduces a set of HTTP headers returned in response to `OPTIONS` request: | ||
|
||
The `Ipfs-Gateway-Features` header is used for signalling support for specific Gateway features to the client. | ||
|
||
The lack of the header, or missing key-value pair within the header means support status is unknown. | ||
|
||
Initial list of key-value pairs is documented in `Ipfs-Gateway-Features` section of :cite[path-gateway] | ||
|
||
## Design rationale | ||
|
||
There is a good prior art for this in web browsers where HTTP `OPTIONS` method | ||
is used in [CORS Preflight request](https://developer.mozilla.org/en-US/docs/Glossary/Preflight_request) | ||
that checks if the CORS protocol is understood and a server is aware using | ||
specific methods and headers. | ||
|
||
The `OPTIONS` request if often sent by web browser anyway, so we would not be | ||
introducing much overhead. | ||
|
||
### User benefit | ||
|
||
Reduced cost for both client and gateway. Sending `OPTIONS` request will be | ||
very inexpensive, especially when compared with current status quo where a | ||
client has to send at least one request to probe a specific feature like | ||
support forp Blake3 hash function or `dag-scope` or `entity-bytes`. | ||
|
||
This translates to decreased latency and ability to choose the best retrieval | ||
strategy faster. | ||
|
||
### Compatibility | ||
|
||
This IPIP is fully backward-compatible with browsers and existing IPFS | ||
ecosystem. Gateways already return CORS headers with `OPTIONS` responses, we | ||
will simply return additional headers with the same responses. | ||
|
||
:::issue | ||
|
||
For JavaScript running on web pages to be able to read `Ipfs-Gateway-Features` | ||
header it MUST be safelisted via `Access-Control-Expose-Headers`. | ||
|
||
::: | ||
|
||
### Security | ||
|
||
This IPIP does not introduce any new security concerns. Probing gateway for | ||
supported features and hash functions is already possible via regular `GET` | ||
requests. | ||
|
||
### Alternatives | ||
|
||
- Exposing the list of suported features via `GET /.well-known/ipfs/gateway/features-TBD` would also work, but: | ||
- introduces surface for path-related deployment bugs, where Nginx is only exposing `/ipfs` namespace – in such case signaling endpoint would not be exposed to the public internet | ||
|
||
## Test fixtures | ||
|
||
TODO | ||
|
||
### Copyright | ||
|
||
Copyright and related rights waived via [CC0](https://creativecommons.org/publicdomain/zero/1.0/). |