/var/www/vhosts/ihelp.ro/httpdocs/vendor/cakephp/cakephp/src/Http
NameSizeModeActions
Client/-0755rm
Cookie/-0755rm
Exception/-0755rm
Middleware/-0755rm
Session/-0755rm
TestSuite/-0755rm
BaseApplication.php93880644editdlrm
CallbackStream.php15750644editdlrm
Client.php256240644editdlrm
composer.json15090644editdlrm
ContentTypeNegotiation.php52730644editdlrm
ControllerFactory.php2300644editdlrm
ControllerFactoryInterface.php15340644editdlrm
CorsBuilder.php60250644editdlrm
FlashMessage.php68120644editdlrm
LICENSE.txt12040644editdlrm
MiddlewareApplication.php17910644editdlrm
MiddlewareQueue.php91130644editdlrm
README.md33920644editdlrm
Response.php512180644editdlrm
ResponseEmitter.php89400644editdlrm
Runner.php30640644editdlrm
Server.php55520644editdlrm
ServerRequest.php559690644editdlrm
ServerRequestFactory.php130810644editdlrm
Session.php209880644editdlrm
Uri.php50270644editdlrm
Edit: /var/www/vhosts/ihelp.ro/httpdocs/vendor/cakephp/cakephp/src/Http/ResponseEmitter.php (8940B)
maxBufferLength = $maxBufferLength; } /** * Emit a response. * * Emits a response, including status line, headers, and the message body, * according to the environment. * * @param \Psr\Http\Message\ResponseInterface $response The response to emit. * @return bool */ public function emit(ResponseInterface $response): bool { $file = ''; $line = 0; if (headers_sent($file, $line)) { $message = "Unable to emit headers. Headers sent in file=$file line=$line"; trigger_error($message, E_USER_WARNING); } $this->emitStatusLine($response); $this->emitHeaders($response); $this->flush(); $range = $this->parseContentRange($response->getHeaderLine('Content-Range')); if (is_array($range)) { $this->emitBodyRange($range, $response); } else { $this->emitBody($response); } if (function_exists('fastcgi_finish_request')) { fastcgi_finish_request(); } return true; } /** * Emit the message body. * * @param \Psr\Http\Message\ResponseInterface $response The response to emit * @return void */ protected function emitBody(ResponseInterface $response): void { if (in_array($response->getStatusCode(), [204, 304], true)) { return; } $body = $response->getBody(); if (!$body->isSeekable()) { echo $body; return; } $body->rewind(); while (!$body->eof()) { echo $body->read($this->maxBufferLength); } } /** * Emit a range of the message body. * * @param array $range The range data to emit * @param \Psr\Http\Message\ResponseInterface $response The response to emit * @return void */ protected function emitBodyRange(array $range, ResponseInterface $response): void { [, $first, $last] = $range; $body = $response->getBody(); if (!$body->isSeekable()) { $contents = $body->getContents(); echo substr($contents, $first, $last - $first + 1); return; } $body = new RelativeStream($body, $first); $body->rewind(); $pos = 0; $length = $last - $first + 1; while (!$body->eof() && $pos < $length) { if ($pos + $this->maxBufferLength > $length) { echo $body->read($length - $pos); break; } echo $body->read($this->maxBufferLength); $pos = $body->tell(); } } /** * Emit the status line. * * Emits the status line using the protocol version and status code from * the response; if a reason phrase is available, it, too, is emitted. * * @param \Psr\Http\Message\ResponseInterface $response The response to emit * @return void */ protected function emitStatusLine(ResponseInterface $response): void { $reasonPhrase = $response->getReasonPhrase(); header(sprintf( 'HTTP/%s %d%s', $response->getProtocolVersion(), $response->getStatusCode(), ($reasonPhrase ? ' ' . $reasonPhrase : '') )); } /** * Emit response headers. * * Loops through each header, emitting each; if the header value * is an array with multiple values, ensures that each is sent * in such a way as to create aggregate headers (instead of replace * the previous). * * @param \Psr\Http\Message\ResponseInterface $response The response to emit * @return void */ protected function emitHeaders(ResponseInterface $response): void { $cookies = []; if (method_exists($response, 'getCookieCollection')) { $cookies = iterator_to_array($response->getCookieCollection()); } foreach ($response->getHeaders() as $name => $values) { if (strtolower($name) === 'set-cookie') { $cookies = array_merge($cookies, $values); continue; } $first = true; foreach ($values as $value) { header(sprintf( '%s: %s', $name, $value ), $first); $first = false; } } $this->emitCookies($cookies); } /** * Emit cookies using setcookie() * * @param array<\Cake\Http\Cookie\CookieInterface|string> $cookies An array of cookies. * @return void */ protected function emitCookies(array $cookies): void { foreach ($cookies as $cookie) { $this->setCookie($cookie); } } /** * Helper methods to set cookie. * * @param \Cake\Http\Cookie\CookieInterface|string $cookie Cookie. * @return bool */ protected function setCookie($cookie): bool { if (is_string($cookie)) { $cookie = Cookie::createFromHeaderString($cookie, ['path' => '']); } if (PHP_VERSION_ID >= 70300) { /** @psalm-suppress InvalidArgument */ return setcookie($cookie->getName(), $cookie->getScalarValue(), $cookie->getOptions()); } $path = $cookie->getPath(); $sameSite = $cookie->getSameSite(); if ($sameSite !== null) { // Temporary hack for PHP 7.2 to set "SameSite" attribute // https://stackoverflow.com/questions/39750906/php-setcookie-samesite-strict $path .= '; samesite=' . $sameSite; } return setcookie( $cookie->getName(), $cookie->getScalarValue(), $cookie->getExpiresTimestamp() ?: 0, $path, $cookie->getDomain(), $cookie->isSecure(), $cookie->isHttpOnly() ); } /** * Loops through the output buffer, flushing each, before emitting * the response. * * @param int|null $maxBufferLevel Flush up to this buffer level. * @return void */ protected function flush(?int $maxBufferLevel = null): void { if ($maxBufferLevel === null) { $maxBufferLevel = ob_get_level(); } while (ob_get_level() > $maxBufferLevel) { ob_end_flush(); } } /** * Parse content-range header * https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.16 * * @param string $header The Content-Range header to parse. * @return array|false [unit, first, last, length]; returns false if no * content range or an invalid content range is provided */ protected function parseContentRange(string $header) { if (preg_match('/(?P[\w]+)\s+(?P\d+)-(?P\d+)\/(?P\d+|\*)/', $header, $matches)) { return [ $matches['unit'], (int)$matches['first'], (int)$matches['last'], $matches['length'] === '*' ? '*' : (int)$matches['length'], ]; } return false; } }