-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #251 from php-http/feature/always-seekable-body-pl…
…ugin Add documentation for always seekable body plugin
- Loading branch information
Showing
3 changed files
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
Seekable Body Plugins | ||
===================== | ||
|
||
``RequestSeekableBodyPlugin`` and ``ResponseSeekableBodyPlugin`` ensure that body used in request and response is always seekable. | ||
This allows a lot of components, reading the stream, to rewind it in order to be used later by another component:: | ||
|
||
use Http\Discovery\HttpClientDiscovery; | ||
use Http\Client\Common\PluginClient; | ||
use Http\Client\Common\Plugin\RequestSeekableBodyPlugin; | ||
use Http\Client\Common\Plugin\ResponseSeekableBodyPlugin; | ||
|
||
$options = [ | ||
'use_file_buffer' => true, | ||
'memory_buffer_size' => 2097152, | ||
]; | ||
$requestSeekableBodyPlugin = new RequestSeekableBodyPlugin($options); | ||
$responseSeekableBodyPlugin = new ResponseSeekableBodyPlugin($options); | ||
|
||
$pluginClient = new PluginClient( | ||
HttpClientDiscovery::find(), | ||
[$requestSeekableBodyPlugin, $responseSeekableBodyPlugin] | ||
); | ||
|
||
Those plugins support the following options (which are passed to the ``BufferedStream`` class): | ||
|
||
* ``use_file_buffer``: Whether it should use a temporary file to buffer the body of a stream if it's too big | ||
* ``memory_buffer_size``: Maximum memory to use for buffering the stream before it switch to a file | ||
|
||
``RequestSeekableBodyPlugin`` should be added in top of your plugins, then next plugins can seek request body (i.e. for logging purpose). | ||
``ResponseSeekableBodyPlugin`` should be the last plugin, then previous plugins can seek response body. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,6 +34,8 @@ phpdoc | |
Puli | ||
rebase | ||
Semver | ||
Seekable | ||
seekable | ||
sexualized | ||
sublicense | ||
sync | ||
|