Support Http Range header on request for Files
Is your feature request related to a problem? Please describe.
The Range HTTP request header indicates the part of a document that the server should return. Several parts can be requested with one Range header at once, and the server may send back these ranges in a multipart document.
Describe the solution you'd like
Example requesting 3 ranges from files -
Range: bytes=200-1000, 2000-6576, 19000-
Send only those parts of the document in Response.
Describe alternatives you've considered
Currently, the range is hardcoded as follows -
ctx.write(new DefaultFileRegion(raf.getChannel, 0, fileLength))
Manipulate the positions as per request headers instead.
Additional context
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Range
/bounty $250
@jdegoes Does all zio bounties are reserved to @987Nabil?
/attempt #709
/attempt #709
/attempt #709 I'm gonna modify the Handler.scala and Body.scala to create a response from a file
/attempt #709
/attempt #709
Implementation Plan
I'll implement HTTP Range request support (RFC 7233) with the following approach:
-
Create Range Parser (
zio/http/headers/Range.scala) - ParseRange: bytes=headers into typed models supporting single ranges (bytes=0-499), suffix ranges (bytes=-500), and multiple ranges (bytes=0-499,1000-1499) -
Create RangeSupport Handler (
zio/http/RangeSupport.scala) - Core logic to:- Detect Range header in requests
- Validate ranges against file size
- Return 206 Partial Content with Content-Range for single ranges
- Return 206 with multipart/byteranges for multiple ranges
- Return 416 Range Not Satisfiable for invalid ranges
-
Add Header Types - Define Range, Content-Range, and Accept-Ranges headers in the headers package
-
Replace DefaultFileRegion - Update existing file serving code to use RangeSupport.serveFile() instead of hardcoded
DefaultFileRegion(raf.getChannel, 0, fileLength) -
Add Tests - Comprehensive test suite covering all range types, error cases, and multipart responses
This enables features like video seeking, resume downloads, and parallel chunk fetching while maintaining backward compatibility (requests without Range headers get full file with 200 OK).
Hey, apologies for jumping the process. This is my first bounty attempt and I got ahead of myself. I should have posted /attempt #709 with my plan before submitting the PR!
That said, PR #3889 is fully green and implements the complete RFC 9110 Range spec: single ranges, multi-ranges (multipart/byteranges), suffix ranges, If-Range/ETag validation, and >2GB file support. Demo GIF is in the PR.
Happy to address any feedback. Will follow the process properly next time!
🎉🎈 @987Nabil has been awarded $250 by ZIO! 🎈🎊
Excuse me
Hope this doesn't mean someone else earned my claimed bounty?
@987Nabil how is your forks solutionmaterially different from my solution?
Why wasn't I awarded the bounty?
@Michael-A-Kuykendall Sorry, taking a look again at your PR, it actually did not look that bad. Please forgive me, I took a look at some of the other PRs for this issue and also many other PRs in the zio org that where garbage and might have been a little biased when I took a look. What I can offer you is, that if you find an open issue or bug you would like to fix, even without bounty, I can get you an exclusive bounty. Best would be you ping me on Discord if you are interested.
I will run this past Algora and see what they say about users creating bounties, waiting until someone does the work, then stealing a PR and my clear bounty.
This was just theft, plain and simple.
@Michael-A-Kuykendall Sorry, taking a look again at your PR, it actually did not look that bad. Please forgive me, I took a look at some of the other PRs for this issue and also many other PRs in the zio org that where garbage and might have been a little biased when I took a look. What I can offer you is, that if you find an open issue or bug you would like to fix, even without bounty, I can get you an exclusive bounty. Best would be you ping me on Discord if you are interested.
I'll not be doing further work for Zio to steal again, thx
Let's be perfectly clear; you took (stole completely) one PR and got the bounty yourself, and canceled my other PR without really checking it correctly.
Did I read this series of events correctly?
From what I can see, I did the work, the maintainer accepted it and claimed the bounty
Last protest comment: @987Nabil clearly took my fork and claimed it for bounty. Love to have this ethically resolved.
Timeline: Jan 16, 01:21:15Z - I create PR #3889 (complete implementation, green CI, demo GIF) Jan 17, 21:02:12Z - 987Nabil creates PR #3897 (1.75 days LATER) Jan 18, 08:41:39Z - 987Nabil's PR gets MERGED Jan 18 - Your PR #3889 gets CLOSED with comment "Already on master"
The Maintainer Privilege Abuse: 987Nabil was ASSIGNED to issue #709 from the beginning (maintainer/contributor status)
He had direct access to reviewers (jdegoes, kyri-petrou, vigoo)
His PR got fast-tracked despite being submitted 1.75 days after mine
My complete, working PR was dismissed as "Already on master" From the issue comments, 987Nabil admitted: "I did not even take a look at your PR before I opened mine. I did not steal anything."