File tree 2 files changed +12
-1
lines changed
2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ public function __construct(StreamInterface $stream)
27
27
$ stream = new LimitStream ($ stream , -1 , 10 + $ filenameHeaderLength );
28
28
$ resource = StreamWrapper::getResource ($ stream );
29
29
stream_filter_append ($ resource , 'zlib.inflate ' , STREAM_FILTER_READ );
30
- $ this ->stream = new Stream ($ resource );
30
+ $ this ->stream = $ stream -> isSeekable () ? new Stream ($ resource) : new NoSeekStream ( new Stream ( $ resource ) );
31
31
}
32
32
33
33
/**
Original file line number Diff line number Diff line change 3
3
4
4
use GuzzleHttp \Psr7 ;
5
5
use GuzzleHttp \Psr7 \InflateStream ;
6
+ use GuzzleHttp \Psr7 \NoSeekStream ;
6
7
7
8
class InflateStreamtest extends \PHPUnit_Framework_TestCase
8
9
{
@@ -22,6 +23,16 @@ public function testInflatesStreamsWithFilename()
22
23
$ this ->assertEquals ('test ' , (string ) $ b );
23
24
}
24
25
26
+ public function testInflatesStreamsPreserveSeekable ()
27
+ {
28
+ $ content = $ this ->getGzipStringWithFilename ('test ' );
29
+ $ seekable = Psr7 \stream_for ($ content );
30
+ $ nonSeekable = new NoSeekStream (Psr7 \stream_for ($ content ));
31
+
32
+ $ this ->assertTrue ((new InflateStream ($ seekable ))->isSeekable ());
33
+ $ this ->assertFalse ((new InflateStream ($ nonSeekable ))->isSeekable ());
34
+ }
35
+
25
36
private function getGzipStringWithFilename ($ original_string )
26
37
{
27
38
$ gzipped = bin2hex (gzencode ($ original_string ));
You can’t perform that action at this time.
0 commit comments