File tree Expand file tree Collapse file tree 3 files changed +14
-2
lines changed Expand file tree Collapse file tree 3 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -24,4 +24,12 @@ function it_creates_a_stream_from_null()
2424 {
2525 $ this ->createStream (null )->shouldHaveType ('Psr\Http\Message\StreamInterface ' );
2626 }
27+
28+ function it_creates_a_stream_from_non_seekable_resource ()
29+ {
30+ $ url = 'https://raw.githubusercontent.com/php-http/multipart-stream-builder/master/tests/Resources/httplug.png ' ;
31+ $ resource = fopen ($ url , 'r ' );
32+ $ this ->createStream ($ resource )
33+ ->shouldHaveType ('Psr\Http\Message\StreamInterface ' );
34+ }
2735}
Original file line number Diff line number Diff line change @@ -34,7 +34,9 @@ public function createStream($body = null)
3434 }
3535 }
3636
37- $ body ->rewind ();
37+ if ($ body ->isSeekable ()) {
38+ $ body ->rewind ();
39+ }
3840
3941 return $ body ;
4042 }
Original file line number Diff line number Diff line change @@ -35,7 +35,9 @@ public function createStream($body = null)
3535 $ stream ->write ((string ) $ body );
3636 }
3737
38- $ stream ->rewind ();
38+ if ($ stream ->isSeekable ()) {
39+ $ stream ->rewind ();
40+ }
3941
4042 return $ stream ;
4143 }
You can’t perform that action at this time.
0 commit comments