File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change 33namespace Http \Client \Common \Plugin ;
44
55use Http \Client \Common \Plugin ;
6+ use Http \Client \Common \Plugin \Exception \RewindStreamException ;
67use Http \Message \StreamFactory ;
78use Http \Promise \FulfilledPromise ;
89use Psr \Cache \CacheItemInterface ;
@@ -379,7 +380,15 @@ private function createResponseFromCacheItem(CacheItemInterface $cacheItem)
379380
380381 /** @var ResponseInterface $response */
381382 $ response = $ data ['response ' ];
382- $ response = $ response ->withBody ($ this ->streamFactory ->createStream ($ data ['body ' ]));
383+ $ stream = $ this ->streamFactory ->createStream ($ data ['body ' ]);
384+
385+ try {
386+ $ stream ->rewind ();
387+ } catch (\Exception $ e ) {
388+ throw new RewindStreamException ('Cannot rewind stream. ' , 0 , $ e );
389+ }
390+
391+ $ response = $ response ->withBody ($ stream );
383392
384393 return $ response ;
385394 }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Http \Client \Common \Plugin \Exception ;
4+
5+ use Http \Client \Exception ;
6+
7+ /**
8+ * @author Théo FIDRY <theo.fidry@gmail.com>
9+ */
10+ class RewindStreamException extends \RuntimeException implements Exception
11+ {
12+ }
You can’t perform that action at this time.
0 commit comments