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:----PjFhwJ7WEyU0q8W73oqrJEJbhLjTJCI+qMVkyFncT5ds0duDcXQlBIjf//9MK0g1TQKnBsYMDc56H9QB9tpqSdrdxbgnSIxDXxfySzuBIN1e4jV18FRBQB9np6sg26Yyxmy2/L84Do5UlbqApHWRxdaglibNEPbS4VrdWPw6HG43JlHXY5a1sI1WJVA+AQZC/FQ5vYtvKkgYelx1VuitxfBWv6heyG7MwOqtDMg2Fjz3gmse4oSX+vn8Zt5YjDrjnsWtQsqYKDn3MRCWILhWmjHfH2Ooaze1Fsx1t++M0D57U5B8F3q3oTYSSUBXmMaQ8ltClwUGFB02hrv0iojbdsx12ZINs9HchCPfQBmTqC7ybeCIWZuoGUYWxEZgGY01H26jwqEhB1J6XuNvl6+NZ4F/8VW+eInzpEabg50puc+Yv76Xhb7YfD8bs4gHPCCh7P1PJ6k9Ls7y2204YnFzpzosnyqrKznuJwXTAc2B0pD1/mcH+8z1RIx22Y1UKV6mRgqZcr6vuzWDRRzszUPPirMlVjUihZiWQJUqhs2nBJKYW6y7/u7zGzVGOCpsAgX3OEKkXYhIkKHsWDouRs/9+26eu0/7g+KH6b8XGZYzvXZEf3BJeOAp1Z+rVGUfqNX0TUtAm236fzBelVN6j+m1RXgAaeEiXg6T4gYZVi7b1K4=----ATTACHMENT:----MjQ5Mjk4MTk1NDI2NzgzNSA1Mjc1ODQ3MjExMDc0ODgxIDM1NTE1NTIxMjEwMDM1MTQ=