Skip to content

[Feature Request] Implement Range Requests for <video> / <audio> #19

@bogeychan

Description

@bogeychan

Due to the current implementation, the frontend must download the entire file, which in turn prevents buffering ("the frontend has to download the whole file first") in the video / audio control:

new Response(Bun.file(file), {

Bun supports Streaming files:

You can send part of a file using the slice(start, end) method on the Bun.file object. This automatically sets the Content-Range and Content-Length headers on the Response object.

However this behavior doesn't allow seeking ("jumping to a timestamp") because the actual size is not set in the Content-Range header:

  • Bun: bytes 0-10/*
  • Required: bytes 0-10/20

manually setting the header works but it ends up twice in the response (with [email protected] - due to slice(start, end))

new Response(Bun.file(filename).slice(start, end), {
  status: 206,
  headers: {
    'Content-Range': `bytes ${start}-${end - 1}/${size}`
  }
});

HTTP range requests

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions