Skip to content

Commit a532b2d

Browse files
authored
Merge pull request #52 from veewee/resource-stream-close-docs
Document ResourceStream close behavior
2 parents 27a1835 + 0785ded commit a532b2d

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

docs/transports.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ This package contains some frequently used encoders / decoders for you:
4545
| `StreamDecoder` | `DecoderInterface<StreamInterface>` | Returns the PSR-7 Stream as response result |
4646
| `StreamEncoder` | `EncoderInterface<StreamInterface>` | Adds PSR-7 Stream as request body |
4747

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+
4852
## Built-in transport presets:
4953

5054
We've composed some of the encodings above into pre-configured transports:

0 commit comments

Comments
 (0)