Skip to content

Commit

Permalink
#345 - Add a transport query parameter
Browse files Browse the repository at this point in the history
The `transport`query parameter allows to define which transport. At the
moment two additional transports are supported: `stream` and `sendfile
  • Loading branch information
johanjanssens committed May 17, 2020
1 parent 10514ab commit e64cdfd
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions code/site/components/com_pages/event/subscriber/downloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,17 @@ public function onAfterApplicationRoute(KEventInterface $event)
//Set the location header
$dispatcher = $this->getObject('com://site/pages.dispatcher.http');

try {
$dispatcher->getResponse()->setContent($path, @mime_content_type($path) ?? 'application/octet-stream');
try
{
$response = $dispatcher->getResponse();

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

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

} catch (InvalidArgumentException $e) {
throw new KControllerExceptionResourceNotFound('File not found');
}
Expand Down

0 comments on commit e64cdfd

Please sign in to comment.