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