fix: handle Range header in HEAD requests#114
Merged
Conversation
…rsing The HEAD handler was ignoring Range headers entirely, always returning 200 OK with the full Content-Length. This caused clients issuing `HEAD -H "Range: bytes=0-1023"` to receive incorrect responses missing 206 status, Content-Range, and Accept-Ranges headers. Changes: - Extract range parsing into `parse_range_str`/`parse_range_header` in utils/core.rs with comprehensive unit tests (13 test cases) - Update HEAD handler to return 206 Partial Content with correct Content-Range and Content-Length when a Range header is present - Refactor GET handler to use the same shared parsing logic Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
gadomski
reviewed
Mar 5, 2026
Contributor
Author
|
@gadomski good suggestions, simplified now. |
alukach
pushed a commit
that referenced
this pull request
Mar 9, 2026
🤖 I have created a release *beep* *boop* --- ## [1.1.0](v1.0.4...v1.1.0) (2026-03-05) ### Features * Indicate range request support with Accept-Ranges header ([#104](#104)) ([4c6737a](4c6737a)) ### Bug Fixes * handle Range header in HEAD requests ([#114](#114)) ([24323a0](24323a0)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: deprecated-source-coop-release[bot] <187876225+deprecated-source-coop-release[bot]@users.noreply.github.com>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What I'm changing
The HEAD handler was ignoring Range headers entirely, always returning 200 OK with the full Content-Length. This caused clients issuing
HEAD -H "Range: bytes=0-1023"to receive incorrect responses missing 206 status, Content-Range, and Accept-Ranges headers.How I did it
parse_range_str/parse_range_headerin utils/core.rs with comprehensive unit tests (13 test cases)