chore: adds Content-Range and Content-Length - #1328
Open
ErikSin wants to merge 2 commits into
Open
Conversation
RangerMauve
requested changes
Sep 3, 2026
RangerMauve
left a comment
Contributor
There was a problem hiding this comment.
Lets use https://www.npmjs.com/package/range-parser instead so we don't need to maintiain this code or worry about edge cases
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.
towards 2109 in comapeo mobile
iOS uses AVPlayer (via Expo-Audio) to play audio within Comapeo-Mobile. The Audio returned by the fastify server was not playing at all.
The blob download route (GET /projects/:projectId/blob/...) never sent Content-Length, and didn't support Range requests. Without a known content length iOS's AVPlayer can't determine a video's duration and treats it as an indefinite live stream, which stalls forever instead of playing.
Adds a parseRangeHeader helper that parses a single Range: bytes=start-end header (including open-ended and suffix forms, e.g. bytes=500-, bytes=-500), the only form clients like AVPlayer send.
When a valid Range header is present, the route now reads only the requested byte span from the blob store, responds 206 Partial Content with Content-Range and Content-Length, and always advertises Accept-Ranges: bytes. Full responses now also get an explicit Content-Length.
Threads start/length through to blobStore.createReadStreamFromEntry, which already forwarded its options straight to Hyperblobs' createReadStream — just needed the JSDoc updated to declare the two new option fields.
A missing/malformed/unsatisfiable Range header falls back to serving the full resource, matching standard HTTP semantics.