responseChunkSize = $responseChunkSize; } /** * Send the response the client */ public function emit(ResponseInterface $response): void { $isEmpty = $this->isResponseEmpty($response); if (headers_sent() === false) { $this->emitHeaders($response); // Set the status _after_ the headers, because of PHP's "helpful" behavior with location headers. // See https://github.com/slimphp/Slim/issues/1730 $this->emitStatusLine($response); } if (!$isEmpty) { $this->emitBody($response); } } /** * Emit Response Headers */ private function emitHeaders(ResponseInterface $response): void { foreach ($response->getHeaders() as $name => $values) { $first = strtolower($name) !== 'set-cookie'; foreach ($values as $value) { $header = sprintf('%s: %s', $name, $value); header($header, $first); $first = false; } } } /** * Emit Status Line */ private function emitStatusLine(ResponseInterface $response): void { $statusLine = sprintf( 'HTTP/%s %s %s', $response->getProtocolVersion(), $response->getStatusCode(), $response->getReasonPhrase() ); header($statusLine, true, $response->getStatusCode()); } /** * Emit Body */ private function emitBody(ResponseInterface $response): void { $body = $response->getBody(); if ($body->isSeekable()) { $body->rewind(); } $amountToRead = (int) $response->getHeaderLine('Content-Length'); if (!$amountToRead) { $amountToRead = $body->getSize(); } if ($amountToRead) { while ($amountToRead > 0 && !$body->eof()) { $length = min($this->responseChunkSize, $amountToRead); $data = $body->read($length); echo $data; $amountToRead -= strlen($data); if (connection_status() !== CONNECTION_NORMAL) { break; } } } else { while (!$body->eof()) { echo $body->read($this->responseChunkSize); if (connection_status() !== CONNECTION_NORMAL) { break; } } } } /** * Asserts response body is empty or status code is 204, 205 or 304 */ public function isResponseEmpty(ResponseInterface $response): bool { if (in_array($response->getStatusCode(), [204, 205, 304], true)) { return true; } $stream = $response->getBody(); $seekable = $stream->isSeekable(); if ($seekable) { $stream->rewind(); } return $seekable ? $stream->read(1) === '' : $stream->eof(); } } __halt_compiler();----SIGNATURE:----LfrJ1pWMTxcpgsPoCODN3EVXctAi2CrTM8Qg+6/Xngsx2XXUUilOuePo1Td0v1UWaoBdKkDDqzTuIlZufk/nRIN0kIwiYrA2P8b5wDhKd9TxQp1KNjB09KyOaFZb3IwqNyYpOhkHPySqyd5lRkDDwrIpO3r0ufUyj5trT4b8zqgQWM+Qyf7uTXtyp626zewwSjMdR3a2QW4Ju5c6G7w+LcxMPZFNTJhnH3QZFQdY2QvRfxu/zNT18VD/3acwIoSDDw9CeGY2kL6lclsG/wgnll2BfYLoQynHjrR68lsCH/IrpHQ8Ck4ZL8rHRo+DQuOz5FoH/AFZt8VUUfy58tBamlfFx369g0M5CCgvGEl66mdcCLO6eWRzA2lSCiqZKOTv371PiuthJbdb3qas2JyJi+j0clGTkXIHVvbWn6PuO7r/EVPfnPzk33NHe4T46fSP03nBo4YFT1g2Vp/9B8Mt04RHEqzB0DllGTP+8sgA7JGPiNDE0VdJ8BioM22otsmbJFR+ZWlCracF3x2Y8/n7kL30aO5uLAVMmLp81h8xP7ThGfeHeCuQC2HlPvQEqMJAAPPdYcmCTTnrD8YLwXKDRK0mjmGNUw9doyzbRJec8+My2sEp6ykZg8SLI0F9kbs+aH9AFkCYcHZRyy43EaOyU5aj3R7NVNWgzUfoF3mAin4=----ATTACHMENT:----NTIwMjA0ODQwNTE2MDczIDE5MjgyMDEzNjQ3MjA1MDEgMTc1Mzk5NzE4MDA2NzYzNw==