Skip to content

Commit

Permalink
Better RFC 2616 compliance
Browse files Browse the repository at this point in the history
Co-authored-by: Aaron Piotrowski <aaron@trowski.com>
  • Loading branch information
ostrolucky and trowski committed Jan 12, 2019
1 parent 9984b39 commit d3b3ad6
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/Responder.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,17 @@ public function __invoke(Socket $socket): \Generator
/** @var Handle $handle */
$handle = yield \Amp\File\open($this->bufferer->getFilePath(), 'rb');

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

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

yield $socket->write("$header\n\n");
yield $socket->write(implode("\r\n", $header) . "\r\n\r\n");

$progressBar = new ProgressBar(
$this->consoleOutput->section(),
Expand Down

0 comments on commit d3b3ad6

Please sign in to comment.