|
@@ -1,4 +1,4 @@ discard block |
|
|
block discarded – undo |
|
1
|
|
-<?php declare(strict_types=1); |
|
|
1
|
+<?php declare(strict_types = 1); |
|
2
|
2
|
|
|
3
|
3
|
namespace WyriHaximus\React\Http\Middleware; |
|
4
|
4
|
|
|
@@ -47,17 +47,17 @@ discard block |
|
|
block discarded – undo |
|
47
|
47
|
|
|
48
|
48
|
$key = $uri; |
|
49
|
49
|
|
|
50
|
|
- return $this->cache->get($key)->then(function ($json) { |
|
|
50
|
+ return $this->cache->get($key)->then(function($json) { |
|
51
|
51
|
$cachedResponse = json_decode($json); |
|
52
|
52
|
|
|
53
|
|
- return new Response($cachedResponse->code, (array)$cachedResponse->headers, stream_for($cachedResponse->body)); |
|
54
|
|
- }, function () use ($next, $request, $key) { |
|
55
|
|
- return resolve($next($request))->then(function (ResponseInterface $response) use ($key) { |
|
|
53
|
+ return new Response($cachedResponse->code, (array) $cachedResponse->headers, stream_for($cachedResponse->body)); |
|
|
54
|
+ }, function() use ($next, $request, $key) { |
|
|
55
|
+ return resolve($next($request))->then(function(ResponseInterface $response) use ($key) { |
|
56
|
56
|
if ($response->getBody() instanceof HttpBodyStream) { |
|
57
|
57
|
return $response; |
|
58
|
58
|
} |
|
59
|
59
|
|
|
60
|
|
- $body = (string)$response->getBody(); |
|
|
60
|
+ $body = (string) $response->getBody(); |
|
61
|
61
|
$headers = []; |
|
62
|
62
|
foreach ($this->headers as $header) { |
|
63
|
63
|
if (!$response->hasHeader($header)) { |
Please login to merge, or discard this patch.