diff --git a/code/libraries/joomlatools/library/dispatcher/response/transport/http.php b/code/libraries/joomlatools/library/dispatcher/response/transport/http.php index f997f1578..e0214c246 100644 --- a/code/libraries/joomlatools/library/dispatcher/response/transport/http.php +++ b/code/libraries/joomlatools/library/dispatcher/response/transport/http.php @@ -172,8 +172,8 @@ public function send(KDispatcherResponseInterface $response) $response->setContentType('application/octet-stream'); } - //Add Content-Length if not present - if(!$response->headers->has('Content-Length')) { + //Add Content-Length if not present and not streaming + if(!$response->headers->has('Content-Length') && !$request->isStreaming()) { $response->headers->set('Content-Length', $response->getStream()->getSize()); } } @@ -239,3 +239,4 @@ public function send(KDispatcherResponseInterface $response) return parent::send($response); } } + diff --git a/code/libraries/joomlatools/library/dispatcher/response/transport/stream.php b/code/libraries/joomlatools/library/dispatcher/response/transport/stream.php index 261032b95..beeecbdb8 100644 --- a/code/libraries/joomlatools/library/dispatcher/response/transport/stream.php +++ b/code/libraries/joomlatools/library/dispatcher/response/transport/stream.php @@ -224,8 +224,12 @@ public function send(KDispatcherResponseInterface $response) $size = $this->getFileSize($response); $response->setStatus(KHttpResponse::PARTIAL_CONTENT); - $response->headers->set('Content-Length', $range - $offset + 1); $response->headers->set('Content-Range', sprintf('bytes %s-%s/%s', $offset, $range, $size)); + + //Safari sends an initial 0-1 range request, which fails if a Content-Length is provided in response on HTTP2 + if(($range - $offset) > 1) { + $response->headers->set('Content-Length', $range - $offset); + } } if($response->isError())