You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The underlying PHP resource is shared between the ResourceStream
and the PSR-7 stream, so closing one closes the other. Document
this and suggest copying the stream when reuse is needed.
Copy file name to clipboardExpand all lines: docs/transports.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -45,6 +45,10 @@ This package contains some frequently used encoders / decoders for you:
45
45
|`StreamDecoder`|`DecoderInterface<StreamInterface>`| Returns the PSR-7 Stream as response result |
46
46
|`StreamEncoder`|`EncoderInterface<StreamInterface>`| Adds PSR-7 Stream as request body |
47
47
48
+
> **Note:** The `ResourceStreamEncoder` passes the underlying PHP resource to a PSR-7 stream.
49
+
> PSR-7's `StreamInterface::close()` will close this resource, which also closes the original `ResourceStream`.
50
+
> If you need to reuse the resource after sending a request, pass a copy of the stream (e.g. via `$stream->copyTo(MemoryStream::create())`) to the encoder instead.
51
+
48
52
## Built-in transport presets:
49
53
50
54
We've composed some of the encodings above into pre-configured transports:
0 commit comments