Skip to content
This repository has been archived by the owner on Mar 1, 2023. It is now read-only.

Commit

Permalink
Changed some line in SapiEmitter | removed SapiStreamEmitter for now
Browse files Browse the repository at this point in the history
  • Loading branch information
prisis committed Apr 4, 2017
1 parent 7839a28 commit 96922e3
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 49 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"exclude-from-classmap" : ["tests/"]
},
"autoload-dev": {
"files" : ["tests/sapiEmitterFunctions.php"],
"files" : ["tests/OverwritePhpFunctions.php"],
"psr-4": {
"Narrowspark\\HttpEmitter\\Tests\\" : "tests/"
}
Expand Down
39 changes: 19 additions & 20 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 16 additions & 10 deletions src/SapiEmitter.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,27 +29,33 @@ public function setMaxBufferLevel(int $maxBufferLevel)
*/
public function emit(ResponseInterface $response)
{
if (headers_sent()) {
throw new RuntimeException('Unable to emit response: headers already sent.');
$file = $line = null;

if (headers_sent($file, $line)) {
throw new RuntimeException(sprintf(
'Unable to emit response: Headers already sent in file %s on line %s.',
$file,
$line
));
}

$response = $this->injectContentLength($response);

// Emit the HTTP status line
$this->emitStatusLine($response);
// Emit the HTTP headers
$this->emitHeaders($response);
// Emit the body
$this->sendBody($response);

if (function_exists('fastcgi_finish_request')) {
fastcgi_finish_request();
} elseif (php_sapi_name() == 'cli' || php_sapi_name() == 'phpdbg') {
// Command line output buffering is disabled in cli by default.
// Command line output buffering is disabled in cli by default.
if (php_sapi_name() == 'cli' || php_sapi_name() == 'phpdbg') {
$this->collectGarbage();

Util::closeOutputBuffers($this->maxBufferLevel ?? ob_get_level(), true);
}

$this->sendBody($response);

if (function_exists('fastcgi_finish_request')) {
fastcgi_finish_request();
}
}

/**
Expand Down
15 changes: 0 additions & 15 deletions src/SapiStreamEmitter.php

This file was deleted.

File renamed without changes.
3 changes: 0 additions & 3 deletions tests/SapiStreamEmitterTest.php

This file was deleted.

0 comments on commit 96922e3

Please sign in to comment.