Skip to content

Feature request: HTTP Range support for serveStatic #1267

@Michealjunior

Description

@Michealjunior

Describe the feature

Describe the feature

serveStatic currently ignores HTTP Range requests. When a client sends a Range header, the server still responds with the full response body and does not include partial-content headers. This prevents:

Download resumption

Media seeking in browsers and video/audio players

Proper CDN and proxy behavior

This feature request proposes adding byte range support to serveStatic for GET and HEAD requests when the asset size is known.

Proposed behavior

Always advertise Accept-Ranges: bytes

Support only a single byte range

Ignore malformed or multi-range requests and serve the full response

For valid ranges:

Respond with 206 Partial Content

Include Content-Range and correct Content-Length

For HEAD, send headers only

For unsatisfiable ranges:

Respond with 416 Range Not Satisfiable

Include Content-Range: bytes */

Content-Length: 0

Important constraints

Preserve existing caching, encoding selection, fallthrough behavior, and 404/405 handling

Do not introduce new public exports

Keep all helper logic private within the serveStatic module

Use cases

Video/audio streaming

Resumable file downloads

Browser compatibility

Better support for media players and HTTP clients

Additional information

This behavior aligns with RFC 7233 and matches what users expect from static file servers. Most modern browsers automatically send range requests for media, and lack of support breaks playback and seeking.

No API changes are required—this is a backward-compatible internal enhancement to serveStatic.

Additional information

  • Would you be willing to help implement this feature?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions