21use Psr\Http\Message\ResponseInterface;
53 $ini_memory_limit = ini_get(
'memory_limit');
55 if (preg_match(
'/^(\d+)(.)$/', $ini_memory_limit, $matches)) {
57 'G' => (
int) $matches[1] * 1024 * 1024 * 1024,
58 'M' => (
int) $matches[1] * 1024 * 1024,
59 'K' => (
int) $matches[1] * 1024,
60 default => (
int) $matches[1],
69 return (
int) round(max($this->memory_limit / 4, 8 * 1024));
87 http_response_code(
$response->getStatusCode());
90 foreach (array_keys(
$response->getHeaders()) as $key) {
92 if (strtolower($key) ===
'set-cookie') {
93 foreach (
$response->getHeader($key) as $header) {
94 header(
"$key: " . $header,
false);
106 $body_size = $stream->getSize();
107 if ($body_size > $this->memory_limit) {
112 $resource = $stream->detach();
116 if (is_resource($resource)) {
120 }
catch (\Throwable) {
122 switch ($this->method) {
124 $sendStatus = fpassthru($resource);
129 while (!feof($resource)) {
130 echo $return = fread($resource, $this->chunk_size);
131 $sendStatus = $sendStatus && $return !==
false;
142 if ($sendStatus ===
false) {
Class DefaultResponseSenderStrategy.
sendResponse(ResponseInterface $response)
Sends the rendered response to the client.
Interface ResponseSenderStrategy.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...