Add support for HEAD endpoints; add example accepting Range:
header
#776
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Several examples of running
curl
against the example with-i
to show the headers the server returns are below.Normal request; fetch all data:
Ask for just 20 bytes starting at offset 20:
Ask for all bytes starting from offset 100 (this matches the way curl resumes downloads via
-C -
, which also works with this example but I'm not showing explicitly here):Ask for the last 100 bytes:
We can repeat any of the above requests with
-I
to send anHTTP HEAD
; we should get back identical headers but no body content; e.g., asking for all bytes starting from offset 100:Asking for too many bytes (e.g., "the last 500 bytes") fails:
as does asking for multiple ranges (which is legal but I think very unusual?):
Interestingly, asking for an explicit range that goes past the end of the file succeeds:
This is because http-range-header clamps the end position. I'm having a hard time finding anything in RFC 7233 to confirm that's the correct behavior, but I imagine it is?