@@ -82,12 +82,15 @@ discard block |
||
82 | 82 | $kernel->addDispatcher($factory->make(SapiDispatcher::class)); |
83 | 83 | }); |
84 | 84 | |
85 | - if (!class_exists('Spiral\RoadRunnerBridge\Http\Dispatcher')) { |
|
86 | - if (class_exists(PSR7Client::class)) { |
|
85 | + if (!class_exists('Spiral\RoadRunnerBridge\Http\Dispatcher')) |
|
86 | + { |
|
87 | + if (class_exists(PSR7Client::class)) |
|
88 | + { |
|
87 | 89 | $kernel->addDispatcher($factory->make(LegacyRrDispatcher::class)); |
88 | 90 | } |
89 | 91 | |
90 | - if (class_exists(PSR7Worker::class)) { |
|
92 | + if (class_exists(PSR7Worker::class)) |
|
93 | + { |
|
91 | 94 | $kernel->addDispatcher($factory->make(RrDispatcher::class)); |
92 | 95 | } |
93 | 96 | } |
@@ -131,7 +134,8 @@ discard block |
||
131 | 134 | { |
132 | 135 | $emitter = new SapiEmitter(); |
133 | 136 | |
134 | - if (($chunkSize = $config->getChunkSize()) !== null) { |
|
137 | + if (($chunkSize = $config->getChunkSize()) !== null) |
|
138 | + { |
|
135 | 139 | $emitter->bufferSize = $chunkSize; |
136 | 140 | } |
137 | 141 |
@@ -58,7 +58,8 @@ |
||
58 | 58 | */ |
59 | 59 | public function getChunkSize(): ?int |
60 | 60 | { |
61 | - if (\is_null($this->config['chunkSize']) || (int) $this->config['chunkSize'] < 0) { |
|
61 | + if (\is_null($this->config['chunkSize']) || (int) $this->config['chunkSize'] < 0) |
|
62 | + { |
|
62 | 63 | return null; |
63 | 64 | } |
64 | 65 |
@@ -54,16 +54,20 @@ discard block |
||
54 | 54 | private function emitBody(ResponseInterface $response): void |
55 | 55 | { |
56 | 56 | $body = $response->getBody(); |
57 | - if ($body->isSeekable()) { |
|
57 | + if ($body->isSeekable()) |
|
58 | + { |
|
58 | 59 | $body->rewind(); |
59 | 60 | } |
60 | - if (!$body->isReadable()) { |
|
61 | + if (!$body->isReadable()) |
|
62 | + { |
|
61 | 63 | return; |
62 | 64 | } |
63 | - if ($this->bufferSize === 0) { |
|
65 | + if ($this->bufferSize === 0) |
|
66 | + { |
|
64 | 67 | echo $body; |
65 | 68 | } |
66 | - while (!$body->eof()) { |
|
69 | + while (!$body->eof()) |
|
70 | + { |
|
67 | 71 | echo $body->read($this->bufferSize); |
68 | 72 | flush(); |
69 | 73 | } |
@@ -80,11 +84,13 @@ discard block |
||
80 | 84 | */ |
81 | 85 | private function assertNoPreviousOutput(): void |
82 | 86 | { |
83 | - if (headers_sent()) { |
|
87 | + if (headers_sent()) |
|
88 | + { |
|
84 | 89 | throw new EmitterException('Unable to emit response, headers already send.'); |
85 | 90 | } |
86 | 91 | |
87 | - if (ob_get_level() > 0 && ob_get_length() > 0) { |
|
92 | + if (ob_get_level() > 0 && ob_get_length() > 0) |
|
93 | + { |
|
88 | 94 | throw new EmitterException('Unable to emit response, found non closed buffered output.'); |
89 | 95 | } |
90 | 96 | } |
@@ -128,10 +134,12 @@ discard block |
||
128 | 134 | { |
129 | 135 | $statusCode = $response->getStatusCode(); |
130 | 136 | |
131 | - foreach ($response->getHeaders() as $header => $values) { |
|
137 | + foreach ($response->getHeaders() as $header => $values) |
|
138 | + { |
|
132 | 139 | $name = $this->filterHeader($header); |
133 | 140 | $first = $name === 'Set-Cookie' ? false : true; |
134 | - foreach ($values as $value) { |
|
141 | + foreach ($values as $value) |
|
142 | + { |
|
135 | 143 | header(sprintf( |
136 | 144 | '%s: %s', |
137 | 145 | $name, |