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

Test HEAD requests before GET #104

Open
hsanjuan opened this issue Jan 24, 2025 · 7 comments
Open

Test HEAD requests before GET #104

hsanjuan opened this issue Jan 24, 2025 · 7 comments
Assignees

Comments

@hsanjuan
Copy link

The Trustless Gateway Spec requires supporting HEAD requests.

I have observed providers with HTTP-endpoint that return 500 on HEAD requests, while returning content with GET requests for the same URL.

It is important that HEAD requests are supported as it allows opportunistic content discovery without causing unnecessary load on the providers.

For example, in general we can use HEAD to test if multiple providers have the content they are announcing. We can then use GET to fetch according to latency measurements, or any scoring mechanism.

In the context of Spark, we can expand tests by checking the presence of many more CIDs and randomly picking which ones to fully retrieve.

@bajtos
Copy link
Member

bajtos commented Jan 24, 2025

Thank you for the suggestion, @hsanjuan.

As I understand it, you would like to add a third check to the existing two we have in place:

  1. The CID advertised to IPNI.
  2. [NEW] If the protocol is HTTP, the provider responds with 200 for a HEAD request.
  3. The root block of the content identified by CID can be retrieved and matches the hash in CID.

Is that correct?

@bajtos
Copy link
Member

bajtos commented Jan 24, 2025

To maintain backward compatibility, it may be better to run the HEAD check only if the retrieval check passes and also to report the outcome of HEAD checks as a new metric distinct from RSR.

@hsanjuan
Copy link
Author

Yes, that'd work. Thanks!

@juliangruber
Copy link
Member

Added as a candidate to CheckerNetwork/roadmap#219

@juliangruber
Copy link
Member

@hsanjuan is a 3xx also a success for this HEAD request, or only a 2xx?

@hsanjuan
Copy link
Author

Which 3xx ? I'm guessing a redirection should be followed until the final location is tested...

@juliangruber
Copy link
Member

juliangruber commented Feb 13, 2025

Good question, redirects will be followed, the HTTP response code of the final response will be reported. Then only 2xx makes sense.

@bajtos bajtos moved this to 🏗 in progress in Space Meridian Feb 14, 2025
juliangruber added a commit to CheckerNetwork/spark-api that referenced this issue Feb 17, 2025
juliangruber added a commit that referenced this issue Feb 21, 2025
* Add HEAD request. #104

* clean up

* todo

* style

* add passing tests

* Update test/integration.js

Co-authored-by: Miroslav Bajtoš <oss@bajtos.net>

* add Accept header

* fix lint

---------

Co-authored-by: Miroslav Bajtoš <oss@bajtos.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 🏗 in progress
Development

No branches or pull requests

3 participants