Fix for video in safari

Video doesn't work safari.

It seem to be to do with the content-range header. Safari initially asked for the first byte. 
However with a single byte request, the header outputs
`bytes 0-0/1000` (if this file is 1000 bytes in size)

It does work however if we make the end value 1. But removing the `-1` breaks it in chrome. So I suggest this change, which means the end can't be smaller than 1.
This commit is contained in:
Cris Ward 2017-09-28 11:12:44 +01:00 committed by GitHub
parent 00981bcf44
commit 81f2ee7815
1 changed files with 1 additions and 1 deletions

View File

@ -156,7 +156,7 @@ private def multipart(file, env : HTTP::Server::Context)
env.response.status_code = 206
env.response.content_length = endb - startb
env.response.headers["Accept-Ranges"] = "bytes"
env.response.headers["Content-Range"] = "bytes #{startb}-#{endb - 1}/#{fileb}" # MUST
env.response.headers["Content-Range"] = "bytes #{startb}-#{endb > 1 ? endb - 1 : 1}/#{fileb}" # MUST
if startb > 1024
skipped = 0