Conditions | 3 |
Paths | 3 |
Total Lines | 17 |
Lines | 0 |
Ratio | 0 % |
Tests | 11 |
CRAP Score | 3 |
Changes | 0 |
1 | <?php |
||
22 | 2 | public function handleRequest(RequestInterface $request, callable $next, callable $first) |
|
23 | { |
||
24 | 2 | if (!$request->hasHeader('Content-Length')) { |
|
25 | 2 | $stream = $request->getBody(); |
|
26 | |||
27 | // Cannot determine the size so we use a chunk stream |
||
28 | 2 | if (null === $stream->getSize()) { |
|
29 | 1 | $stream = new ChunkStream($stream); |
|
30 | 1 | $request = $request->withBody($stream); |
|
31 | 1 | $request = $request->withAddedHeader('Transfer-Encoding', 'chunked'); |
|
32 | 1 | } else { |
|
33 | 1 | $request = $request->withHeader('Content-Length', $stream->getSize()); |
|
34 | } |
||
35 | 2 | } |
|
36 | |||
37 | 2 | return $next($request); |
|
38 | } |
||
39 | } |
||
40 |
If you suppress an error, we recommend checking for the error condition explicitly: