@@ -67,9 +67,9 @@ discard block |
||
67 | 67 | { |
68 | 68 | $timer = null; |
69 | 69 | $that = $this; |
70 | - return new Promise\Promise(function ($resolve, $reject) use ($that, &$timer) { |
|
71 | - $lookupResolve = function ($type) use ($that, $resolve, $reject) { |
|
72 | - return function (array $ips) use ($that, $type, $resolve, $reject) { |
|
70 | + return new Promise\Promise(function($resolve, $reject) use ($that, &$timer) { |
|
71 | + $lookupResolve = function($type) use ($that, $resolve, $reject) { |
|
72 | + return function(array $ips) use ($that, $type, $resolve, $reject) { |
|
73 | 73 | unset($that->resolverPromises[$type]); |
74 | 74 | $that->resolved[$type] = true; |
75 | 75 | |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | }; |
84 | 84 | |
85 | 85 | $that->resolverPromises[Message::TYPE_AAAA] = $that->resolve(Message::TYPE_AAAA, $reject)->then($lookupResolve(Message::TYPE_AAAA)); |
86 | - $that->resolverPromises[Message::TYPE_A] = $that->resolve(Message::TYPE_A, $reject)->then(function (array $ips) use ($that, &$timer) { |
|
86 | + $that->resolverPromises[Message::TYPE_A] = $that->resolve(Message::TYPE_A, $reject)->then(function(array $ips) use ($that, &$timer) { |
|
87 | 87 | // happy path: IPv6 has resolved already (or could not resolve), continue with IPv4 addresses |
88 | 88 | if ($that->resolved[Message::TYPE_AAAA] === true || !$ips) { |
89 | 89 | return $ips; |
@@ -91,18 +91,18 @@ discard block |
||
91 | 91 | |
92 | 92 | // Otherwise delay processing IPv4 lookup until short timer passes or IPv6 resolves in the meantime |
93 | 93 | $deferred = new Promise\Deferred(); |
94 | - $timer = $that->loop->addTimer($that::RESOLUTION_DELAY, function () use ($deferred, $ips) { |
|
94 | + $timer = $that->loop->addTimer($that::RESOLUTION_DELAY, function() use ($deferred, $ips) { |
|
95 | 95 | $deferred->resolve($ips); |
96 | 96 | }); |
97 | 97 | |
98 | - $that->resolverPromises[Message::TYPE_AAAA]->then(function () use ($that, $timer, $deferred, $ips) { |
|
98 | + $that->resolverPromises[Message::TYPE_AAAA]->then(function() use ($that, $timer, $deferred, $ips) { |
|
99 | 99 | $that->loop->cancelTimer($timer); |
100 | 100 | $deferred->resolve($ips); |
101 | 101 | }); |
102 | 102 | |
103 | 103 | return $deferred->promise(); |
104 | 104 | })->then($lookupResolve(Message::TYPE_A)); |
105 | - }, function ($_, $reject) use ($that, &$timer) { |
|
105 | + }, function($_, $reject) use ($that, &$timer) { |
|
106 | 106 | $reject(new \RuntimeException( |
107 | 107 | 'Connection to ' . $that->uri . ' cancelled' . (!$that->connectionPromises ? ' during DNS lookup' : '') . ' (ECONNABORTED)', |
108 | 108 | \defined('SOCKET_ECONNABORTED') ? \SOCKET_ECONNABORTED : 103 |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | public function resolve($type, $reject) |
128 | 128 | { |
129 | 129 | $that = $this; |
130 | - return $that->resolver->resolveAll($that->host, $type)->then(null, function (\Exception $e) use ($type, $reject, $that) { |
|
130 | + return $that->resolver->resolveAll($that->host, $type)->then(null, function(\Exception $e) use ($type, $reject, $that) { |
|
131 | 131 | unset($that->resolverPromises[$type]); |
132 | 132 | $that->resolved[$type] = true; |
133 | 133 | |
@@ -171,13 +171,13 @@ discard block |
||
171 | 171 | $index = \key($this->connectionPromises); |
172 | 172 | |
173 | 173 | $that = $this; |
174 | - $that->connectionPromises[$index]->then(function ($connection) use ($that, $index, $resolve) { |
|
174 | + $that->connectionPromises[$index]->then(function($connection) use ($that, $index, $resolve) { |
|
175 | 175 | unset($that->connectionPromises[$index]); |
176 | 176 | |
177 | 177 | $that->cleanUp(); |
178 | 178 | |
179 | 179 | $resolve($connection); |
180 | - }, function (\Exception $e) use ($that, $index, $ip, $resolve, $reject) { |
|
180 | + }, function(\Exception $e) use ($that, $index, $ip, $resolve, $reject) { |
|
181 | 181 | unset($that->connectionPromises[$index]); |
182 | 182 | |
183 | 183 | $that->failureCount++; |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | // Allow next connection attempt in 100ms: https://tools.ietf.org/html/rfc8305#section-5 |
220 | 220 | // Only start timer when more IPs are queued or when DNS query is still pending (might add more IPs) |
221 | 221 | if ($this->nextAttemptTimer === null && (\count($this->connectQueue) > 0 || $this->resolved[Message::TYPE_A] === false || $this->resolved[Message::TYPE_AAAA] === false)) { |
222 | - $this->nextAttemptTimer = $this->loop->addTimer(self::CONNECTION_ATTEMPT_DELAY, function () use ($that, $resolve, $reject) { |
|
222 | + $this->nextAttemptTimer = $this->loop->addTimer(self::CONNECTION_ATTEMPT_DELAY, function() use ($that, $resolve, $reject) { |
|
223 | 223 | $that->nextAttemptTimer = null; |
224 | 224 | |
225 | 225 | if ($that->connectQueue) { |
@@ -328,6 +328,6 @@ discard block |
||
328 | 328 | $message = ': ' . $message; |
329 | 329 | } |
330 | 330 | |
331 | - return 'Connection to ' . $this->uri . ' failed' . $message; |
|
331 | + return 'Connection to ' . $this->uri . ' failed' . $message; |
|
332 | 332 | } |
333 | 333 | } |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | $connected = false; |
46 | 46 | $promise = $this->connector->connect( |
47 | 47 | \str_replace('tls://', '', $uri) |
48 | - )->then(function (ConnectionInterface $connection) use ($context, $encryption, $uri, &$promise, &$connected) { |
|
48 | + )->then(function(ConnectionInterface $connection) use ($context, $encryption, $uri, &$promise, &$connected) { |
|
49 | 49 | // (unencrypted) TCP/IP connection succeeded |
50 | 50 | $connected = true; |
51 | 51 | |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | } |
61 | 61 | |
62 | 62 | // try to enable encryption |
63 | - return $promise = $encryption->enable($connection)->then(null, function ($error) use ($connection, $uri) { |
|
63 | + return $promise = $encryption->enable($connection)->then(null, function($error) use ($connection, $uri) { |
|
64 | 64 | // establishing encryption failed => close invalid connection and return error |
65 | 65 | $connection->close(); |
66 | 66 | |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | $error->getCode() |
70 | 70 | ); |
71 | 71 | }); |
72 | - }, function (\Exception $e) use ($uri) { |
|
72 | + }, function(\Exception $e) use ($uri) { |
|
73 | 73 | if ($e instanceof \RuntimeException) { |
74 | 74 | $message = \preg_replace('/^Connection to [^ ]+/', '', $e->getMessage()); |
75 | 75 | $e = new \RuntimeException( |
@@ -103,10 +103,10 @@ discard block |
||
103 | 103 | }); |
104 | 104 | |
105 | 105 | return new \React\Promise\Promise( |
106 | - function ($resolve, $reject) use ($promise) { |
|
106 | + function($resolve, $reject) use ($promise) { |
|
107 | 107 | $promise->then($resolve, $reject); |
108 | 108 | }, |
109 | - function ($_, $reject) use (&$promise, $uri, &$connected) { |
|
109 | + function($_, $reject) use (&$promise, $uri, &$connected) { |
|
110 | 110 | if ($connected) { |
111 | 111 | $reject(new \RuntimeException( |
112 | 112 | 'Connection to ' . $uri . ' cancelled during TLS handshake (ECONNABORTED)', |
@@ -37,7 +37,7 @@ |
||
37 | 37 | */ |
38 | 38 | private static function handler($uri) |
39 | 39 | { |
40 | - return function (\Exception $e) use ($uri) { |
|
40 | + return function(\Exception $e) use ($uri) { |
|
41 | 41 | if ($e instanceof TimeoutException) { |
42 | 42 | throw new \RuntimeException( |
43 | 43 | 'Connection to ' . $uri . ' timed out after ' . $e->getTimeout() . ' seconds (ETIMEDOUT)', |
@@ -57,7 +57,7 @@ |
||
57 | 57 | |
58 | 58 | $promise = $this->connect(); |
59 | 59 | $promise->then( |
60 | - function (ConnectionInterface $stream) use ($requestData, &$streamRef, &$stateRef, &$pendingWrites, $that) { |
|
60 | + function(ConnectionInterface $stream) use ($requestData, &$streamRef, &$stateRef, &$pendingWrites, $that) { |
|
61 | 61 | $streamRef = $stream; |
62 | 62 | |
63 | 63 | $stream->on('drain', array($that, 'handleDrain')); |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | |
29 | 29 | $defaults = array_merge( |
30 | 30 | array( |
31 | - 'Host' => $this->getHost().$port, |
|
31 | + 'Host' => $this->getHost() . $port, |
|
32 | 32 | 'User-Agent' => 'ReactPHP/1', |
33 | 33 | ), |
34 | 34 | $connectionHeaders, |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | |
74 | 74 | // assume "/" path by default, but allow "OPTIONS *" |
75 | 75 | if ($path === null) { |
76 | - $path = ($this->method === 'OPTIONS' && $queryString === null) ? '*': '/'; |
|
76 | + $path = ($this->method === 'OPTIONS' && $queryString === null) ? '*' : '/'; |
|
77 | 77 | } |
78 | 78 | if ($queryString !== null) { |
79 | 79 | $path .= '?' . $queryString; |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | $data = ''; |
95 | 95 | $data .= "{$this->method} {$this->getPath()} HTTP/{$this->protocolVersion}\r\n"; |
96 | 96 | foreach ($headers as $name => $values) { |
97 | - foreach ((array)$values as $value) { |
|
97 | + foreach ((array) $values as $value) { |
|
98 | 98 | $data .= "$name: $value\r\n"; |
99 | 99 | } |
100 | 100 | } |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | { |
120 | 120 | if (null !== $auth = $this->getUrlUserPass()) { |
121 | 121 | return array( |
122 | - 'Authorization' => 'Basic ' . base64_encode($auth['user'].':'.$auth['pass']), |
|
122 | + 'Authorization' => 'Basic ' . base64_encode($auth['user'] . ':' . $auth['pass']), |
|
123 | 123 | ); |
124 | 124 | } |
125 | 125 |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | |
68 | 68 | public function send(RequestInterface $request) |
69 | 69 | { |
70 | - $deferred = new Deferred(function () use (&$deferred) { |
|
70 | + $deferred = new Deferred(function() use (&$deferred) { |
|
71 | 71 | if (isset($deferred->pending)) { |
72 | 72 | $deferred->pending->cancel(); |
73 | 73 | unset($deferred->pending); |
@@ -77,11 +77,11 @@ discard block |
||
77 | 77 | $deferred->numRequests = 0; |
78 | 78 | |
79 | 79 | // use timeout from options or default to PHP's default_socket_timeout (60) |
80 | - $timeout = (float)($this->timeout !== null ? $this->timeout : ini_get("default_socket_timeout")); |
|
80 | + $timeout = (float) ($this->timeout !== null ? $this->timeout : ini_get("default_socket_timeout")); |
|
81 | 81 | |
82 | 82 | $loop = $this->loop; |
83 | 83 | $this->next($request, $deferred)->then( |
84 | - function (ResponseInterface $response) use ($deferred, $loop, &$timeout) { |
|
84 | + function(ResponseInterface $response) use ($deferred, $loop, &$timeout) { |
|
85 | 85 | if (isset($deferred->timeout)) { |
86 | 86 | $loop->cancelTimer($deferred->timeout); |
87 | 87 | unset($deferred->timeout); |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | $timeout = -1; |
90 | 90 | $deferred->resolve($response); |
91 | 91 | }, |
92 | - function ($e) use ($deferred, $loop, &$timeout) { |
|
92 | + function($e) use ($deferred, $loop, &$timeout) { |
|
93 | 93 | if (isset($deferred->timeout)) { |
94 | 94 | $loop->cancelTimer($deferred->timeout); |
95 | 95 | unset($deferred->timeout); |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | $body = $request->getBody(); |
107 | 107 | if ($body instanceof ReadableStreamInterface && $body->isReadable()) { |
108 | 108 | $that = $this; |
109 | - $body->on('close', function () use ($that, $deferred, &$timeout) { |
|
109 | + $body->on('close', function() use ($that, $deferred, &$timeout) { |
|
110 | 110 | if ($timeout >= 0) { |
111 | 111 | $that->applyTimeout($deferred, $timeout); |
112 | 112 | } |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | */ |
127 | 127 | public function applyTimeout(Deferred $deferred, $timeout) |
128 | 128 | { |
129 | - $deferred->timeout = $this->loop->addTimer($timeout, function () use ($timeout, $deferred) { |
|
129 | + $deferred->timeout = $this->loop->addTimer($timeout, function() use ($timeout, $deferred) { |
|
130 | 130 | $deferred->reject(new \RuntimeException( |
131 | 131 | 'Request timed out after ' . $timeout . ' seconds' |
132 | 132 | )); |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | $promise = $this->sender->send($request); |
148 | 148 | |
149 | 149 | if (!$this->streaming) { |
150 | - $promise = $promise->then(function ($response) use ($deferred, $that) { |
|
150 | + $promise = $promise->then(function($response) use ($deferred, $that) { |
|
151 | 151 | return $that->bufferResponse($response, $deferred); |
152 | 152 | }); |
153 | 153 | } |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | $deferred->pending = $promise; |
156 | 156 | |
157 | 157 | return $promise->then( |
158 | - function (ResponseInterface $response) use ($request, $that, $deferred) { |
|
158 | + function(ResponseInterface $response) use ($request, $that, $deferred) { |
|
159 | 159 | return $that->onResponse($response, $request, $deferred); |
160 | 160 | } |
161 | 161 | ); |
@@ -187,10 +187,10 @@ discard block |
||
187 | 187 | // buffer stream and resolve with buffered body |
188 | 188 | $maximumSize = $this->maximumSize; |
189 | 189 | $promise = \React\Promise\Stream\buffer($stream, $maximumSize)->then( |
190 | - function ($body) use ($response) { |
|
190 | + function($body) use ($response) { |
|
191 | 191 | return $response->withBody(new BufferedBody($body)); |
192 | 192 | }, |
193 | - function ($e) use ($stream, $maximumSize) { |
|
193 | + function($e) use ($stream, $maximumSize) { |
|
194 | 194 | // try to close stream if buffering fails (or is cancelled) |
195 | 195 | $stream->close(); |
196 | 196 |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | $this->parser = new RequestHeaderParser(); |
111 | 111 | |
112 | 112 | $that = $this; |
113 | - $this->parser->on('headers', function (ServerRequestInterface $request, ConnectionInterface $conn) use ($that) { |
|
113 | + $this->parser->on('headers', function(ServerRequestInterface $request, ConnectionInterface $conn) use ($that) { |
|
114 | 114 | $that->handleRequest($conn, $request); |
115 | 115 | }); |
116 | 116 | |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | |
159 | 159 | // cancel pending promise once connection closes |
160 | 160 | if ($response instanceof CancellablePromiseInterface) { |
161 | - $conn->on('close', function () use ($response) { |
|
161 | + $conn->on('close', function() use ($response) { |
|
162 | 162 | $response->cancel(); |
163 | 163 | }); |
164 | 164 | } |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | |
176 | 176 | $that = $this; |
177 | 177 | $response->then( |
178 | - function ($response) use ($that, $conn, $request) { |
|
178 | + function($response) use ($that, $conn, $request) { |
|
179 | 179 | if (!$response instanceof ResponseInterface) { |
180 | 180 | $message = 'The response callback is expected to resolve with an object implementing Psr\Http\Message\ResponseInterface, but resolved with "%s" instead.'; |
181 | 181 | $message = \sprintf($message, \is_object($response) ? \get_class($response) : \gettype($response)); |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | } |
187 | 187 | $that->handleResponse($conn, $request, $response); |
188 | 188 | }, |
189 | - function ($error) use ($that, $conn, $request) { |
|
189 | + function($error) use ($that, $conn, $request) { |
|
190 | 190 | $message = 'The response callback is expected to resolve with an object implementing Psr\Http\Message\ResponseInterface, but rejected with "%s" instead.'; |
191 | 191 | $message = \sprintf($message, \is_object($error) ? \get_class($error) : \gettype($error)); |
192 | 192 | |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | // assign default "Server" header automatically |
249 | 249 | if (!$response->hasHeader('Server')) { |
250 | 250 | $response = $response->withHeader('Server', 'ReactPHP/1'); |
251 | - } elseif ($response->getHeaderLine('Server') === ''){ |
|
251 | + } elseif ($response->getHeaderLine('Server') === '') { |
|
252 | 252 | $response = $response->withoutHeader('Server'); |
253 | 253 | } |
254 | 254 | |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | if (!$response->hasHeader('Date')) { |
257 | 257 | // IMF-fixdate = day-name "," SP date1 SP time-of-day SP GMT |
258 | 258 | $response = $response->withHeader('Date', gmdate('D, d M Y H:i:s') . ' GMT'); |
259 | - } elseif ($response->getHeaderLine('Date') === ''){ |
|
259 | + } elseif ($response->getHeaderLine('Date') === '') { |
|
260 | 260 | $response = $response->withoutHeader('Date'); |
261 | 261 | } |
262 | 262 | |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | // 304 Not Modified: preserve explicit Content-Length and preserve missing header if body is empty |
270 | 270 | } elseif ($body->getSize() !== null) { |
271 | 271 | // assign Content-Length header when using a "normal" buffered body string |
272 | - $response = $response->withHeader('Content-Length', (string)$body->getSize()); |
|
272 | + $response = $response->withHeader('Content-Length', (string) $body->getSize()); |
|
273 | 273 | } elseif (!$response->hasHeader('Content-Length') && $version === '1.1') { |
274 | 274 | // assign chunked transfer-encoding if no 'content-length' is given for HTTP/1.1 responses |
275 | 275 | $chunked = true; |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | if (($code === Response::STATUS_SWITCHING_PROTOCOLS || ($method === 'CONNECT' && $code >= 200 && $code < 300)) && $body instanceof HttpBodyStream && $body->input instanceof WritableStreamInterface) { |
311 | 311 | if ($request->getBody()->isReadable()) { |
312 | 312 | // request is still streaming => wait for request close before forwarding following data from connection |
313 | - $request->getBody()->on('close', function () use ($connection, $body) { |
|
313 | + $request->getBody()->on('close', function() use ($connection, $body) { |
|
314 | 314 | if ($body->input->isWritable()) { |
315 | 315 | $connection->pipe($body->input); |
316 | 316 | $connection->resume(); |
@@ -372,7 +372,7 @@ discard block |
||
372 | 372 | if ($persist) { |
373 | 373 | $body->pipe($connection, array('end' => false)); |
374 | 374 | $parser = $this->parser; |
375 | - $body->on('end', function () use ($connection, $parser, $body) { |
|
375 | + $body->on('end', function() use ($connection, $parser, $body) { |
|
376 | 376 | $connection->removeListener('close', array($body, 'close')); |
377 | 377 | $parser->handle($connection); |
378 | 378 | }); |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | |
80 | 80 | if ($size !== null && $size !== 0) { |
81 | 81 | // automatically assign a "Content-Length" request header if the body size is known and non-empty |
82 | - $request = $request->withHeader('Content-Length', (string)$size); |
|
82 | + $request = $request->withHeader('Content-Length', (string) $size); |
|
83 | 83 | } elseif ($size === 0 && \in_array($request->getMethod(), array('POST', 'PUT', 'PATCH'))) { |
84 | 84 | // only assign a "Content-Length: 0" request header if the body is expected for certain methods |
85 | 85 | $request = $request->withHeader('Content-Length', '0'); |
@@ -96,9 +96,9 @@ discard block |
||
96 | 96 | $headers[$name] = implode(', ', $values); |
97 | 97 | } |
98 | 98 | |
99 | - $requestStream = $this->http->request($request->getMethod(), (string)$request->getUri(), $headers, $request->getProtocolVersion()); |
|
99 | + $requestStream = $this->http->request($request->getMethod(), (string) $request->getUri(), $headers, $request->getProtocolVersion()); |
|
100 | 100 | |
101 | - $deferred = new Deferred(function ($_, $reject) use ($requestStream) { |
|
101 | + $deferred = new Deferred(function($_, $reject) use ($requestStream) { |
|
102 | 102 | // close request stream if request is cancelled |
103 | 103 | $reject(new \RuntimeException('Request cancelled')); |
104 | 104 | $requestStream->close(); |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | $deferred->reject($error); |
109 | 109 | }); |
110 | 110 | |
111 | - $requestStream->on('response', function (ResponseInterface $response, ReadableStreamInterface $body) use ($deferred, $request) { |
|
111 | + $requestStream->on('response', function(ResponseInterface $response, ReadableStreamInterface $body) use ($deferred, $request) { |
|
112 | 112 | $length = null; |
113 | 113 | $code = $response->getStatusCode(); |
114 | 114 | if ($request->getMethod() === 'HEAD' || ($code >= 100 && $code < 200) || $code == Response::STATUS_NO_CONTENT || $code == Response::STATUS_NOT_MODIFIED) { |
@@ -134,16 +134,16 @@ discard block |
||
134 | 134 | $body->pipe($requestStream); |
135 | 135 | $requestStream->write(''); |
136 | 136 | |
137 | - $body->on('close', $close = function () use ($deferred, $requestStream) { |
|
137 | + $body->on('close', $close = function() use ($deferred, $requestStream) { |
|
138 | 138 | $deferred->reject(new \RuntimeException('Request failed because request body closed unexpectedly')); |
139 | 139 | $requestStream->close(); |
140 | 140 | }); |
141 | - $body->on('error', function ($e) use ($deferred, $requestStream, $close, $body) { |
|
141 | + $body->on('error', function($e) use ($deferred, $requestStream, $close, $body) { |
|
142 | 142 | $body->removeListener('close', $close); |
143 | 143 | $deferred->reject(new \RuntimeException('Request failed because request body reported an error', 0, $e)); |
144 | 144 | $requestStream->close(); |
145 | 145 | }); |
146 | - $body->on('end', function () use ($close, $body) { |
|
146 | + $body->on('end', function() use ($close, $body) { |
|
147 | 147 | $body->removeListener('close', $close); |
148 | 148 | }); |
149 | 149 | } else { |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | } |
153 | 153 | } else { |
154 | 154 | // body is fully buffered => write as one chunk |
155 | - $requestStream->end((string)$body); |
|
155 | + $requestStream->end((string) $body); |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | return $deferred->promise(); |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | $buffer = ''; |
30 | 30 | $maxSize = $this->maxSize; |
31 | 31 | $that = $this; |
32 | - $conn->on('data', $fn = function ($data) use (&$buffer, &$fn, $conn, $maxSize, $that) { |
|
32 | + $conn->on('data', $fn = function($data) use (&$buffer, &$fn, $conn, $maxSize, $that) { |
|
33 | 33 | // append chunk of data to buffer and look for end of request headers |
34 | 34 | $buffer .= $data; |
35 | 35 | $endOfHeader = \strpos($buffer, "\r\n\r\n"); |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | |
58 | 58 | try { |
59 | 59 | $request = $that->parseRequest( |
60 | - (string)\substr($buffer, 0, $endOfHeader + 2), |
|
60 | + (string) \substr($buffer, 0, $endOfHeader + 2), |
|
61 | 61 | $conn->getRemoteAddress(), |
62 | 62 | $conn->getLocalAddress() |
63 | 63 | ); |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | if ($request->hasHeader('Transfer-Encoding')) { |
75 | 75 | $contentLength = null; |
76 | 76 | } elseif ($request->hasHeader('Content-Length')) { |
77 | - $contentLength = (int)$request->getHeaderLine('Content-Length'); |
|
77 | + $contentLength = (int) $request->getHeaderLine('Content-Length'); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | if ($contentLength === 0) { |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | } elseif ($request->hasHeader('Content-Length')) { |
271 | 271 | $string = $request->getHeaderLine('Content-Length'); |
272 | 272 | |
273 | - if ((string)(int)$string !== $string) { |
|
273 | + if ((string) (int) $string !== $string) { |
|
274 | 274 | // Content-Length value is not an integer or not a single integer |
275 | 275 | throw new \InvalidArgumentException('The value of `Content-Length` is not valid', Response::STATUS_BAD_REQUEST); |
276 | 276 | } |