|
| 1 | +--- |
| 2 | +title: "IPIP-0425: Signaling Features on HTTP Gateways" |
| 3 | +date: 2023-07-06 |
| 4 | +ipip: proposal |
| 5 | +editors: |
| 6 | + - name: Marcin Rataj |
| 7 | + github: lidel |
| 8 | + url: https://lidel.org/ |
| 9 | +relatedIssues: |
| 10 | + - https://github.com/ipfs/specs/pull/402#pullrequestreview-1396116569 |
| 11 | + - https://github.com/ipfs/specs/pull/412#pullrequestreview-1427137365 |
| 12 | +order: 425 |
| 13 | +tags: ['ipips'] |
| 14 | +--- |
| 15 | + |
| 16 | +## Summary |
| 17 | + |
| 18 | +Add ability to query HTTP Gateway for an explicit list of supported features. |
| 19 | + |
| 20 | +## Motivation |
| 21 | + |
| 22 | +A Gateway always ships with an opinionated set of supported hash functions and |
| 23 | +IPLD codecs, and the differences between implementations will grow over time. |
| 24 | + |
| 25 | +For example, some legacy gateways may not support newly added features like |
| 26 | +`dag-scope` and `entity-bytes` from :cite[ipip-0402] or the ability to get some |
| 27 | +block ordering guarantees introduced in :cite[ipip-0412]. Future IPIPs may add |
| 28 | +more features and response formats. |
| 29 | + |
| 30 | +We need a light mechanism for clients to detect which gateway supports partial CARs |
| 31 | + |
| 32 | +## Detailed design |
| 33 | + |
| 34 | +This IPIP introduces a set of HTTP headers returned in response to `OPTIONS` request: |
| 35 | + |
| 36 | +The `Ipfs-Gateway-Features` header is used for signalling support for specific Gateway features to the client. |
| 37 | + |
| 38 | +The lack of the header, or missing key-value pair within the header means support status is unknown. |
| 39 | + |
| 40 | +Initial list of key-value pairs is documented in `Ipfs-Gateway-Features` section of :cite[path-gateway] |
| 41 | + |
| 42 | +## Design rationale |
| 43 | + |
| 44 | +There is a good prior art for this in web browsers where HTTP `OPTIONS` method |
| 45 | +is used in [CORS Preflight request](https://developer.mozilla.org/en-US/docs/Glossary/Preflight_request) |
| 46 | +that checks if the CORS protocol is understood and a server is aware using |
| 47 | +specific methods and headers. |
| 48 | + |
| 49 | +The `OPTIONS` request if often sent by web browser anyway, so we would not be |
| 50 | +introducing much overhead. |
| 51 | + |
| 52 | +### User benefit |
| 53 | + |
| 54 | +Reduced cost for both client and gateway. Sending `OPTIONS` request will be |
| 55 | +very inexpensive, especially when compared with current status quo where a |
| 56 | +client has to send at least one request to probe a specific feature like |
| 57 | +support forp Blake3 hash function or `dag-scope` or `entity-bytes`. |
| 58 | + |
| 59 | +This translates to decreased latency and ability to choose the best retrieval |
| 60 | +strategy faster. |
| 61 | + |
| 62 | +### Compatibility |
| 63 | + |
| 64 | +This IPIP is fully backward-compatible with browsers and existing IPFS |
| 65 | +ecosystem. Gateways already return CORS headers with `OPTIONS` responses, we |
| 66 | +will simply return additional headers with the same responses. |
| 67 | + |
| 68 | +:::issue |
| 69 | + |
| 70 | +For JavaScript running on web pages to be able to read `Ipfs-Gateway-Features` |
| 71 | +header it MUST be safelisted via `Access-Control-Expose-Headers`. |
| 72 | + |
| 73 | +::: |
| 74 | + |
| 75 | +### Security |
| 76 | + |
| 77 | +This IPIP does not introduce any new security concerns. Probing gateway for |
| 78 | +supported features and hash functions is already possible via regular `GET` |
| 79 | +requests. |
| 80 | + |
| 81 | +### Alternatives |
| 82 | + |
| 83 | +- Exposing the list of suported features via `GET /.well-known/ipfs/gateway/features-TBD` would also work, but: |
| 84 | + - 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 |
| 85 | + |
| 86 | +## Test fixtures |
| 87 | + |
| 88 | +TODO |
| 89 | + |
| 90 | +### Copyright |
| 91 | + |
| 92 | +Copyright and related rights waived via [CC0](https://creativecommons.org/publicdomain/zero/1.0/). |
0 commit comments