|
9 | 9 | use Psr\Http\Message\ServerRequestInterface; |
10 | 10 | use Psr\Http\Server\MiddlewareInterface; |
11 | 11 | use Psr\Http\Server\RequestHandlerInterface; |
12 | | -use function GuzzleHttp\Psr7\parse_response; |
| 12 | +use GuzzleHttp\Psr7\Message; |
13 | 13 | use function GuzzleHttp\Psr7\str; |
14 | 14 |
|
15 | 15 | class RequestCacheMiddleware implements MiddlewareInterface |
@@ -72,7 +72,7 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface |
72 | 72 |
|
73 | 73 | if ($cacheEntry = $this->cacheFrontend->get($entryIdentifier)) { |
74 | 74 | $age = time() - $cacheEntry['timestamp']; |
75 | | - $response = parse_response($cacheEntry['response']); |
| 75 | + $response = Message::parseResponse($cacheEntry['response']); |
76 | 76 | return $response |
77 | 77 | ->withHeader('Age', $age) |
78 | 78 | ->withHeader(self::HEADER_INFO, 'HIT: ' . $entryIdentifier); |
@@ -105,7 +105,7 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface |
105 | 105 | ->withHeader('Cache-Control', 'public, max-age=' . $publicLifetime); |
106 | 106 | } |
107 | 107 |
|
108 | | - $this->cacheFrontend->set($entryIdentifier,[ 'timestamp' => time(), 'response' => str($response) ], $tags, $lifetime); |
| 108 | + $this->cacheFrontend->set($entryIdentifier,[ 'timestamp' => time(), 'response' => Message::toString($response) ], $tags, $lifetime); |
109 | 109 | $response->getBody()->rewind(); |
110 | 110 | return $response->withHeader(self::HEADER_INFO, 'MISS: ' . $entryIdentifier); |
111 | 111 | } |
|
0 commit comments