Implements HTTP Range requests (RFC 7233) for static routes in Bun.serve(),
enabling partial content delivery for better streaming and download resumption.
Features:
- Parse Range header with support for:
- Single ranges: "bytes=200-1000"
- Open ranges: "bytes=200-"
- Suffix ranges: "bytes=-500"
- Generate appropriate Content-Range response headers
- Return 206 Partial Content for valid ranges
- Return 416 Range Not Satisfiable for invalid ranges
- Add Accept-Ranges: bytes header to indicate range support
- Preserve ETag validation with If-None-Match
- Comprehensive test coverage
Implementation includes:
- New ContentRange.zig module with parsing and validation logic
- Integration with StaticRoute.zig for seamless range handling
- PendingRangeResponse for async streaming of large ranges
- Fallback to full content for unsupported scenarios (multipart ranges)
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>