Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support HEAD requests #170

Open
juliangruber opened this issue Feb 18, 2025 · 7 comments
Open

Support HEAD requests #170

juliangruber opened this issue Feb 18, 2025 · 7 comments

Comments

@juliangruber
Copy link

From https://specs.ipfs.tech/http-gateways/trustless-gateway/#head-ipfs-cid-path-params:

1.2 HEAD /ipfs/{cid}[/{path}][?{params}]
Same as GET, but does not return any payload.

@juliangruber
Copy link
Author

Blocks CheckerNetwork/frisbii-on-fly#3

@rvagg
Copy link
Member

rvagg commented Feb 18, 2025

What use-case is this going to serve for you? Since Frisbii takes a no-buffering approach I think the utility would be limited to finding out if the first block is available or not. Is that all you need from it? I know Boxo takes a different approach and does a bunch of up-front buffering before it starts serving so can deal with a few other classes of errors but I'm not very keen on that approach.

@juliangruber
Copy link
Author

We're currently using a deployed Frisbii instance as an SP we can rely on, in automated tests. Therefore for us it would be sufficient if the HEAD request just always got a 200 response, for example. It also doesn't need to have any headers. Since our use case is limited, I think we could also live off a fork (I have a very basic HEAD implementation ready locally). Wdyt?

@lidel
Copy link

lidel commented Feb 19, 2025

@rvagg doing "quick root block presence check" for HEAD is sensible.

Boxo and Storacha already do that as optimization for HEAD /ipfs/cid?format=raw – we check the root block, nothing more, and return 200 if block is present:

$ curl "https://dag.w3s.link/ipfs/QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR?format=raw" -I
HTTP/2 200

$ curl "https://ipfs.io/ipfs/QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR?format=raw" -I
HTTP/2 200

Implementation wise, HEAD does not have to fetch entire payload nor return any extra headers GET does based on payload (RFC uses SHOULD, but not MUST). This enables us to return HTTP 200/404 fast. Our focus is on application/vnd.ipld.raw responses but I think it is fine to apply this optimization to deserialized responses too.

FYSA HEAD is basic presence check will improve performance of HTTP retrieval, we started work across IPFS ecosystem:

@rvagg
Copy link
Member

rvagg commented Feb 19, 2025

Thanks for all the details @lidel, this is helpful. I did see ipfs/specs#491 pass by but how much of a limbo is that in? Is it likely to land roughly as is or should I wait and watch progress on that?

@hsanjuan
Copy link

hsanjuan commented Feb 19, 2025

@rvagg it will land :) I hate to work on things that don't land. (and it will not change much).

@bajtos
Copy link

bajtos commented Feb 19, 2025

This issue where @hsanjuan requested Spark to check HEAD retrievals can offer some additional context:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants