-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Open
Labels
docsImprovements or additions to documentationImprovements or additions to documentation
Description
What is the type of issue?
Example code is not working
What is the issue?
bun/docs/runtime/http/routing.mdx
Lines 219 to 233 in a305e99
| Bun.serve({ | |
| fetch(req) { | |
| // parse `Range` header | |
| const [start = 0, end = Infinity] = req.headers | |
| .get("Range") // Range: bytes=0-100 | |
| .split("=") // ["Range: bytes", "0-100"] | |
| .at(-1) // "0-100" | |
| .split("-") // ["0", "100"] | |
| .map(Number); // [0, 100] | |
| // return a slice of the file | |
| const bigFile = Bun.file("./big-video.mp4"); | |
| return new Response(bigFile.slice(start, end)); | |
| }, | |
| }); |
The HTTP range header is end-inclusive, so the last line should probably use end + 1 to be correct. I think the ["Range: bytes", "0-100"] comment is likely misleading too, presumably it's supposed to be ["bytes", "0-100"].
Where did you find it?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
docsImprovements or additions to documentationImprovements or additions to documentation