47 lines
1.0 KiB
PHP
47 lines
1.0 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
/**
|
|
* This file is part of Narrowspark.
|
|
*
|
|
* (c) Daniel Bannert <d.bannert@anolilab.de>
|
|
*
|
|
* This source file is subject to the MIT license that is bundled
|
|
* with this source code in the file LICENSE.
|
|
*/
|
|
|
|
namespace Narrowspark\HttpEmitter;
|
|
|
|
use Psr\Http\Message\ResponseInterface;
|
|
|
|
final class SapiEmitter extends AbstractSapiEmitter
|
|
{
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function emit(ResponseInterface $response): void
|
|
{
|
|
$this->assertNoPreviousOutput();
|
|
|
|
$this->emitHeaders($response);
|
|
|
|
// Set the status _after_ the headers, because of PHP's "helpful" behavior with location headers.
|
|
$this->emitStatusLine($response);
|
|
|
|
$this->emitBody($response);
|
|
|
|
$this->closeConnection();
|
|
}
|
|
|
|
/**
|
|
* Sends the message body of the response.
|
|
*
|
|
* @param \Psr\Http\Message\ResponseInterface $response
|
|
*/
|
|
private function emitBody(ResponseInterface $response): void
|
|
{
|
|
echo $response->getBody();
|
|
}
|
|
}
|