From cc543650a3cf5c6893249687dae078b61b4d4fe3 Mon Sep 17 00:00:00 2001 From: Joel Wurtz Date: Mon, 21 Jan 2019 23:33:23 +0100 Subject: [PATCH 1/4] Add documentation for always seekable body plugin --- plugins/always-seekable-body-plugin.rst | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 plugins/always-seekable-body-plugin.rst diff --git a/plugins/always-seekable-body-plugin.rst b/plugins/always-seekable-body-plugin.rst new file mode 100644 index 0000000..ceeb3cf --- /dev/null +++ b/plugins/always-seekable-body-plugin.rst @@ -0,0 +1,25 @@ +Always Seekable Body Plugin +=========================== + +The ``AlwaysSeekableBodyPlugin`` ensure that body of the request and body of the response are always seekable. +This allows a lot of components that read 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\AlwaysSeekableBodyPlugin; + + $options = [ + 'use_file_buffer' => true, + 'memory_buffer_size' => 2097152, + ]; + $alwaysSeekableBodyPlugin = new AlwaysSeekableBodyPlugin($options); + + $pluginClient = new PluginClient( + HttpClientDiscovery::find(), + [$alwaysSeekableBodyPlugin] + ); + +The plugin supports the following options: + + * ``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 From ba82e4bcfb23fb4e44e34e6d99c387370ec6038a Mon Sep 17 00:00:00 2001 From: Joel Wurtz Date: Mon, 21 Jan 2019 23:52:31 +0100 Subject: [PATCH 2/4] Add seekable to the word list --- spelling_word_list.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spelling_word_list.txt b/spelling_word_list.txt index 5aef073..e4c6bb2 100644 --- a/spelling_word_list.txt +++ b/spelling_word_list.txt @@ -34,6 +34,8 @@ phpdoc Puli rebase Semver +Seekable +seekable sexualized sublicense sync From 3b708036b89e2bd2221f8419a5951ceb5bc2b780 Mon Sep 17 00:00:00 2001 From: Joel Wurtz Date: Tue, 29 Jan 2019 15:19:36 +0100 Subject: [PATCH 3/4] Rewording and add plugin page to the index --- plugins/always-seekable-body-plugin.rst | 6 +++--- plugins/index.rst | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/plugins/always-seekable-body-plugin.rst b/plugins/always-seekable-body-plugin.rst index ceeb3cf..7ab6b9e 100644 --- a/plugins/always-seekable-body-plugin.rst +++ b/plugins/always-seekable-body-plugin.rst @@ -1,8 +1,8 @@ Always Seekable Body Plugin =========================== -The ``AlwaysSeekableBodyPlugin`` ensure that body of the request and body of the response are always seekable. -This allows a lot of components that read the stream to rewind it in order to be used later by another component:: +``AlwaysSeekableBodyPlugin`` ensure that the 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; @@ -19,7 +19,7 @@ This allows a lot of components that read the stream to rewind it in order to be [$alwaysSeekableBodyPlugin] ); -The plugin supports the following options: +This plugin supports 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 diff --git a/plugins/index.rst b/plugins/index.rst index 3788afa..be1dc41 100644 --- a/plugins/index.rst +++ b/plugins/index.rst @@ -10,6 +10,7 @@ request or you can even start a completely new request. This gives you full cont introduction build-your-own + always-seekable-body-plugin authentication cache content-length From bb957be5d649bacb961e0b3be662c0d6209a40ce Mon Sep 17 00:00:00 2001 From: Joel Wurtz Date: Tue, 29 Jan 2019 16:36:06 +0100 Subject: [PATCH 4/4] Rework seekable body documentation with the split into two plugins --- plugins/always-seekable-body-plugin.rst | 25 --------------------- plugins/index.rst | 2 +- plugins/seekable-body-plugins.rst | 30 +++++++++++++++++++++++++ 3 files changed, 31 insertions(+), 26 deletions(-) delete mode 100644 plugins/always-seekable-body-plugin.rst create mode 100644 plugins/seekable-body-plugins.rst diff --git a/plugins/always-seekable-body-plugin.rst b/plugins/always-seekable-body-plugin.rst deleted file mode 100644 index 7ab6b9e..0000000 --- a/plugins/always-seekable-body-plugin.rst +++ /dev/null @@ -1,25 +0,0 @@ -Always Seekable Body Plugin -=========================== - -``AlwaysSeekableBodyPlugin`` ensure that the 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\AlwaysSeekableBodyPlugin; - - $options = [ - 'use_file_buffer' => true, - 'memory_buffer_size' => 2097152, - ]; - $alwaysSeekableBodyPlugin = new AlwaysSeekableBodyPlugin($options); - - $pluginClient = new PluginClient( - HttpClientDiscovery::find(), - [$alwaysSeekableBodyPlugin] - ); - -This plugin supports 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 diff --git a/plugins/index.rst b/plugins/index.rst index be1dc41..7a08d49 100644 --- a/plugins/index.rst +++ b/plugins/index.rst @@ -10,7 +10,7 @@ request or you can even start a completely new request. This gives you full cont introduction build-your-own - always-seekable-body-plugin + seekable-body-plugins authentication cache content-length diff --git a/plugins/seekable-body-plugins.rst b/plugins/seekable-body-plugins.rst new file mode 100644 index 0000000..35f6225 --- /dev/null +++ b/plugins/seekable-body-plugins.rst @@ -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.