babashka / http-server

Serve static assets
MIT License
75 stars 8 forks source link

Support range requests #16

Closed jmglov closed 1 month ago

jmglov commented 1 month ago

When a browser makes a range request such as this:

GET /Garth+Brooks/Fresh+Horses/Garth+Brooks+-+The+Old+Stuff.mp3 HTTP/1.1
Range: bytes=0-

According to our good friends over at the Mozilla Developer Network, it expects a response like this:

HTTP/1.1 206 Partial Content
Accept-Ranges: bytes
Content-length: 1048576
Content-Range: bytes 0-1048575/5943424
Content-Type: audio/mpeg

However, http-server currently returns this:

HTTP/1.1 200 OK
Content-length: 5943424
Content-Type: audio/mpeg
Server: http-kit

with a bunch of bytes in the body. In fact, a bountiful buffet of beautiful bytes, five whole million of them! And another 943,424 thrown in for dessert.

This means that the standard HTTP <audio> tag player thingy refuses to seek in the file, instead jumping back to the beginning of the file every time one tries. :scream:

It would be lovely, bordering on spectacular, if http-server supported this. And I think I know just the guy to implement that support and then vomit out 7000 words about it. :roll_eyes:

jmglov commented 1 month ago

Never fear friends, I'm on it!

borkdude commented 1 month ago

Awesome!