* * 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(); } }