question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support for HTTP range requests (for FileResponse)

See original GitHub issue

I’m trying to embed an mp4 file on a page using the following HTML:

<video controls width="600">
    <source src="/media/video.mp4" type="video/mp4">
</video>

The video file is being served by a Starlette FileResponse.

I’m getting this error in Safari:

localhost_8001_live-photos_and_Real-time_HTML_Editor

It looks to me like Safari is trying to make an HTTP range request in order to stream the video - but Starlette doesn’t support that option.

I tried adding accept-ranges: none as a response header but that didn’t seem to fix the problem.

So… it would be great if Starlette could handle range requests so you could use it to serve video files to Safari!

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:8
  • Comments:21 (14 by maintainers)

github_iconTop GitHub Comments

3reactions
simonwcommented, Aug 17, 2022

I’d be disappointed to see this not land in Starlette. I’d understand if it required additional dependencies and a complex implementation, but I feel like the implementation in #1013 is small enough and clean enough that it shouldn’t add undue complexity to the project.

And supporting range requests has a whole bunch of applications beyond just getting the HTML <video> tag to work properly:

  • Support reusable downloads using tools like curl -C and wget --continue - or the download UI in browsers like Chrome and Firefox
  • Enable really neat tricks like the one described in Hosting SQLite databases on Github Pages, where the range header is used to allow queries to be executed against giant SQLite databases without needing to download the entire database first
3reactions
abersheerancommented, Aug 15, 2022

@abersheeran Do you think Starlette should support this? If not, should we add a note on the FileResponse section itself about baize.asgi.FileResponse, and close this as “Won’t do”?

I think Starlette could consider adding this feature. It is not complicated and requires little extra maintenance cost.

Read more comments on GitHub >

github_iconTop Results From Across the Web

HTTP range requests - MDN Web Docs - Mozilla
Range requests are useful for clients like media players that support random access, data tools that know they need only part of a...
Read more >
Configure Nginx and Django for Byte Range Request
I am building a web API using Django and Nginx that needs to support Byte-Range requests. Currently, when making a request such as:...
Read more >
http headers (content-range) wrong for static audio files ...
Hello! I hope I find you well. I'm having a bit of difficulty configuring my Django site to serve audio correctly.
Read more >
Server Reference — aiohttp 3.8.3 documentation
Originating IP address of a client initiated HTTP request. ... Read-only property that returns information about Range HTTP header.
Read more >
Custom Response - HTML, Stream, File, others - FastAPI
In this case, the HTTP header Content-Type will be set to application/json . And it will be documented as such in OpenAPI. Tip....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found