From 81f2ee7815cdc9321ab4f707791cafd3f98e4f4e Mon Sep 17 00:00:00 2001 From: Cris Ward Date: Thu, 28 Sep 2017 11:12:44 +0100 Subject: [PATCH] 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. --- src/kemal/helpers/helpers.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/kemal/helpers/helpers.cr b/src/kemal/helpers/helpers.cr index 7e55681..87c8947 100644 --- a/src/kemal/helpers/helpers.cr +++ b/src/kemal/helpers/helpers.cr @@ -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