-
Notifications
You must be signed in to change notification settings - Fork 1
Add HTTP Range header support for partial static file serving #62
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
Conversation
- Add Range header parsing for static files - Support three range types: start-end, start-, and -suffix - Return 206 Partial Content with Content-Range header - Return 416 Range Not Satisfiable for invalid ranges - Add Accept-Ranges: bytes header to all static responses - Only process ranges for uncompressed files (COMPRESS_METHOD_NONE) - HEAD requests bypass Range logic as expected - Fully backward compatible with non-Range requests Co-authored-by: L3P3 <4629449+L3P3@users.noreply.github.com>
- Add comment clarifying only single ranges are supported (not multipart) - Remove redundant range_start < 0 validation check - Add error handling for file streams to prevent crashes - Multi-range requests now gracefully fall back to full file (200 OK) Co-authored-by: L3P3 <4629449+L3P3@users.noreply.github.com>
|
@copilot I dont like the code duplication after the |
Use conditional object for createReadStream options instead of
separate if/else branches. Pass {start, end} when is_range_request
is true, otherwise pass empty object.
Co-authored-by: L3P3 <4629449+L3P3@users.noreply.github.com>
Done! Merged the duplicate code paths using a conditional object |
| const stream = fs.createReadStream(path_real_send); | ||
| const stream = fs.createReadStream( | ||
| path_real_send, | ||
| is_range_request ? {start: range_start, end: range_end} : {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why dont u send undefined? maybe a little faster?
Implementation Plan for Partial Static Files (HTTP Range Support)
Implementation Complete and Reviewed!
Features Added:
bytes=0-999- specific byte rangebytes=1000-- from byte to end of filebytes=-500- last N bytes (suffix range)Testing Results:
All test scenarios passed including:
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.