Skip to content

fix: handle Range header in HEAD requests#114

Merged
alukach merged 5 commits into
mainfrom
fix/head-range-request
Mar 5, 2026
Merged

fix: handle Range header in HEAD requests#114
alukach merged 5 commits into
mainfrom
fix/head-range-request

Conversation

@alukach

@alukach alukach commented Mar 5, 2026

Copy link
Copy Markdown
Contributor

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

  • 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

alukach and others added 2 commits March 5, 2026 05:52
…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>
Comment thread src/utils/core.rs Outdated
Comment thread src/utils/core.rs Outdated
@alukach

alukach commented Mar 5, 2026

Copy link
Copy Markdown
Contributor Author

@gadomski good suggestions, simplified now.

@gadomski gadomski left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reads much cleaner 🙇🏼

@alukach alukach merged commit 24323a0 into main Mar 5, 2026
@alukach alukach deleted the fix/head-range-request branch March 5, 2026 23:06
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants