File tree Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Original file line number Diff line number Diff line change 9
9
use Psr \Cache \CacheItemPoolInterface ;
10
10
use Psr \Http \Message \RequestInterface ;
11
11
use Psr \Http \Message \ResponseInterface ;
12
+ use RewindStreamException ;
12
13
use Symfony \Component \OptionsResolver \Options ;
13
14
use Symfony \Component \OptionsResolver \OptionsResolver ;
14
15
@@ -379,7 +380,15 @@ private function createResponseFromCacheItem(CacheItemInterface $cacheItem)
379
380
380
381
/** @var ResponseInterface $response */
381
382
$ 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 );
383
392
384
393
return $ response ;
385
394
}
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ declare (strict_types=1 );
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
+
13
+ }
You can’t perform that action at this time.
0 commit comments