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
+5Lines changed: 5 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -41,6 +41,11 @@ This package contains some frequently used encoders / decoders for you:
41
41
|`RawEncoder`|`EncoderInterface<string>`| Adds raw string as request body |
42
42
|`ResourceStreamDecoder`|`DecoderInterface<ResourceStream>`| Returns `phpro/resource-stream` from response body |
43
43
|`ResourceStreamEncoder`|`EncoderInterface<ResourceStream>`| Adds `phpro/resource-stream` as request body |
44
+
45
+
> **Note:** The `ResourceStreamEncoder` passes the underlying PHP resource to a PSR-7 stream.
46
+
> PSR-7's `StreamInterface::close()` will close this resource, which also closes the original `ResourceStream`.
47
+
> 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.
48
+
44
49
|`ResponseDecoder`|`DecoderInterface<ResponseInterface>`| Returns the received PSR-7 response as result |
45
50
|`StreamDecoder`|`DecoderInterface<StreamInterface>`| Returns the PSR-7 Stream as response result |
46
51
|`StreamEncoder`|`EncoderInterface<StreamInterface>`| Adds PSR-7 Stream as request body |
0 commit comments