Skip to content

Commit

Permalink
#345 - Enable sendfile transport by setting X-Sendfile header
Browse files Browse the repository at this point in the history
  • Loading branch information
johanjanssens committed May 17, 2020
1 parent e64cdfd commit 7e6d33e
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions code/site/components/com_pages/event/subscriber/downloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,16 @@ public function onAfterApplicationRoute(KEventInterface $event)
$response = $dispatcher->getResponse();

//Attach a different transport [stream or sendfile]
if(isset($route->query['transport'])) {
$response->attachTransport($route->query['transport']);
if(isset($route->query['transport']))
{
$transport = $route->query['transport'];

//Enable using the header
if($transport == 'sendfile') {
$response->getHeaders()->set('X-Sendfile', 1);
}

$response->attachTransport($transport);
}

$response->setContent($path, @mime_content_type($path) ?? 'application/octet-stream');
Expand Down

0 comments on commit 7e6d33e

Please sign in to comment.