Class DefaultResponseSenderStrategy.
More...
Class DefaultResponseSenderStrategy.
The default response sender strategy rewinds the current body stream and sends the entire stream out to the client.
- Author
- Nicolas Schäfli ns@st.nosp@m.uder.nosp@m.-raim.nosp@m.ann..nosp@m.ch
Definition at line 31 of file DefaultResponseSenderStrategy.php.
◆ __construct()
ILIAS\StaticURL\Response\Response\Sender\DefaultResponseSenderStrategy::__construct |
( |
| ) |
|
◆ initChunkSize()
ILIAS\StaticURL\Response\Response\Sender\DefaultResponseSenderStrategy::initChunkSize |
( |
| ) |
|
|
private |
◆ initMemoryLimit()
ILIAS\StaticURL\Response\Response\Sender\DefaultResponseSenderStrategy::initMemoryLimit |
( |
| ) |
|
|
private |
◆ sendResponse()
ILIAS\StaticURL\Response\Response\Sender\DefaultResponseSenderStrategy::sendResponse |
( |
ResponseInterface |
$response | ) |
|
Sends the rendered response to the client.
- Parameters
-
ResponseInterface | $response | The response which should be send to the client. |
- Exceptions
-
Implements ILIAS\StaticURL\Response\Response\Sender\ResponseSenderStrategy.
Definition at line 79 of file DefaultResponseSenderStrategy.php.
References ILIAS\UI\examples\Symbol\Glyph\Header\header().
83 throw new ResponseSendingException(
"Response was already sent.");
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) {
108 $this->method = self::METHOD_READFILE;
112 $resource = $stream->detach();
116 if (is_resource($resource)) {
122 switch ($this->method) {
123 case self::METHOD_FPASSTHRU:
124 $sendStatus = fpassthru($resource);
126 case self::METHOD_READFILE:
129 while (!feof($resource)) {
130 echo $return = fread($resource, $this->chunk_size);
131 $sendStatus = $sendStatus && $return !==
false;
142 if ($sendStatus ===
false) {
143 throw new ResponseSendingException(
"Could not send body content to client.");
◆ $chunk_size
int ILIAS\StaticURL\Response\Response::Sender\DefaultResponseSenderStrategy::$chunk_size |
|
private |
◆ $memory_limit
int ILIAS\StaticURL\Response\Response::Sender\DefaultResponseSenderStrategy::$memory_limit |
|
private |
◆ $method
string ILIAS\StaticURL\Response\Response::Sender\DefaultResponseSenderStrategy::$method = self::METHOD_FPASSTHRU |
|
private |
◆ METHOD_FPASSTHRU
const ILIAS\StaticURL\Response\Response::Sender\DefaultResponseSenderStrategy::METHOD_FPASSTHRU = 'fpassthru' |
|
private |
◆ METHOD_READFILE
const ILIAS\StaticURL\Response\Response::Sender\DefaultResponseSenderStrategy::METHOD_READFILE = 'readfile' |
|
private |
The documentation for this class was generated from the following file: