Skip to content

Commit

Permalink
Autodetect filename from path to put to HTTP response
Browse files Browse the repository at this point in the history
  • Loading branch information
ostrolucky committed Jan 18, 2019
1 parent 66c7297 commit 7fb87f8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
},
"require-dev": {
"amphp/artax": "^3.0",
"amphp/process": "dev-master#e7e2821 as 1.0.3",
"amphp/process": "^1.0.3",
"phpunit/phpunit": "^7.5"
},
"config": {
Expand Down
7 changes: 6 additions & 1 deletion src/Responder.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,12 @@ public function __invoke(Socket $socket): \Generator
$remoteAddress = $socket->getRemoteAddress();
$this->logger->debug("Accepted connection from $remoteAddress:\n".trim(yield $socket->read()));

$header = ['HTTP/1.1 200 OK', 'Content-Type:'.yield $this->bufferer->getMimeType(), 'Connection: close'];
$header = [
'HTTP/1.1 200 OK',
'Content-Disposition: inline; filename="'.basename($this->bufferer->getFilePath()).'"',
'Content-Type:'.yield $this->bufferer->getMimeType(),
'Connection: close',
];

if (!$this->bufferer->isBuffering()) {
$header[] = "Content-Length: {$this->bufferer->getCurrentProgress()}";
Expand Down

0 comments on commit 7fb87f8

Please sign in to comment.