Skip to content

Serve single byte ranges with If-Range and 416 handling - #54

Draft
billf wants to merge 1 commit into
mainfrom
bill/feat/single-range-serving
Draft

billf wants to merge 1 commit into
mainfrom
bill/feat/single-range-serving

Conversation

@billf

@billf billf commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Stack: #49 → #54 → #55 → #56.

Serves a single byte range for static assets, so audio and video can seek, with If-Range and 416 handling.

What this PR contains

  • parseByteRange in src/mime/mime.ts parses one bytes= range in open-ended, bounded and suffix forms, clamped to the file size. Range unit names are case-insensitive (RFC 9110 §14.1). Multi-range and malformed headers are ignored, which RFC 9110 §14.2 allows. An inverted range is answered 416.
  • ifRangeMatches: a Range applies only when If-Range is a strong match for the current ETag (RFC 9110 §13.1.5). Otherwise the full body is served.
  • blobResponse answers 206 with Content-Range, 416 for an unsatisfiable range, and sends Accept-Ranges: bytes on full and partial responses.
  • Range errors (416) are Cache-Control: no-store and keep the ETag and X-Content-Type-Options: nosniff. An out-of-bounds response for a hashed asset is never cached as immutable.
  • The app-owned storage-URL route forwards a single Range to storage and passes 206 through. Multi-range headers are not forwarded. A storage 416 gets the same no-store policy.
  • Tests: parser edge cases, If-Range, 416 caching, and component and app-owned Range responses.

Not in this PR

🤖 Generated with Claude Code

@pkg-pr-new

pkg-pr-new Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/convex/static-hosting/@convex-dev/static-hosting@54

commit: e41a4e1

@billf

billf commented Nov 10, 2026

Copy link
Copy Markdown
Contributor Author

@billf billf changed the title Support single byte ranges for static assets Serve single byte ranges with If-Range and 416 handling Nov 10, 2026
@billf billf self-assigned this Nov 10, 2026
@billf
billf changed the base branch from bill/fix/mime-types to main November 10, 2026 20:49
Preserve conditional range handling and storage response headers.

Co-authored-by: Claude Haiku 5.5 <noreply@anthropic.com>
Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
@billf
billf force-pushed the bill/feat/single-range-serving branch from 89e72b4 to e41a4e1 Compare November 11, 2026 00:15
@billf
billf requested a review from ianmacartney November 11, 2026 00:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant