From 5f3797c83c8ef040475a8981a746ade09b862d0b Mon Sep 17 00:00:00 2001 From: Karim PINCHON Date: Mon, 10 Jul 2017 11:43:01 +0200 Subject: [PATCH 1/4] Add content-type plugin documentation --- plugins/content-type.rst | 18 ++++++++++++++++++ plugins/index.rst | 1 + 2 files changed, 19 insertions(+) create mode 100644 plugins/content-type.rst diff --git a/plugins/content-type.rst b/plugins/content-type.rst new file mode 100644 index 0000000..299e1f3 --- /dev/null +++ b/plugins/content-type.rst @@ -0,0 +1,18 @@ +Content-Type Plugin +===================== + +The ``ContentTypePlugin`` sets the correct ``Content-Type`` header value based on the content of the body stream of the +request. This helps HTTP servers to handle the request:: + + use Http\Discovery\HttpClientDiscovery; + use Http\Client\Common\PluginClient; + use Http\Client\Common\Plugin\ContentTypePlugin; + + $contentTypePlugin = new ContentTypePlugin(); + + $pluginClient = new PluginClient( + HttpClientDiscovery::find(), + [$contentTypePlugin] + ); + +For now, the plugin could only detect Json or XML content. If the content of the stream can not be determined, the plugin does nothing. \ No newline at end of file diff --git a/plugins/index.rst b/plugins/index.rst index 4a04e70..6874ceb 100644 --- a/plugins/index.rst +++ b/plugins/index.rst @@ -13,6 +13,7 @@ request or you can even start a completely new request. This gives you full cont authentication cache content-length + content-type cookie decoder error From 128ad1db63ff2c7a42c959fd831e8a0468e14f72 Mon Sep 17 00:00:00 2001 From: Karim PINCHON Date: Fri, 21 Jul 2017 10:02:31 +0200 Subject: [PATCH 2/4] Clean content-type plugin doc --- plugins/content-type.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/content-type.rst b/plugins/content-type.rst index 299e1f3..d7b383b 100644 --- a/plugins/content-type.rst +++ b/plugins/content-type.rst @@ -1,5 +1,5 @@ Content-Type Plugin -===================== +=================== The ``ContentTypePlugin`` sets the correct ``Content-Type`` header value based on the content of the body stream of the request. This helps HTTP servers to handle the request:: @@ -15,4 +15,4 @@ request. This helps HTTP servers to handle the request:: [$contentTypePlugin] ); -For now, the plugin could only detect Json or XML content. If the content of the stream can not be determined, the plugin does nothing. \ No newline at end of file +For now, the plugin can only detect JSON or XML content. If the content of the stream can not be determined, the plugin does nothing. \ No newline at end of file From 68ff8c676e9622d86415ce70f8f9f62cc452e014 Mon Sep 17 00:00:00 2001 From: Karim PINCHON Date: Fri, 21 Jul 2017 17:42:11 +0200 Subject: [PATCH 3/4] Add ContentTypePlugin options --- plugins/content-type.rst | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/plugins/content-type.rst b/plugins/content-type.rst index d7b383b..411306b 100644 --- a/plugins/content-type.rst +++ b/plugins/content-type.rst @@ -15,4 +15,16 @@ request. This helps HTTP servers to handle the request:: [$contentTypePlugin] ); -For now, the plugin can only detect JSON or XML content. If the content of the stream can not be determined, the plugin does nothing. \ No newline at end of file +For now, the plugin can only detect JSON or XML content. If the content of the stream can not be determined, the plugin does nothing. + +Options +------- + +``skip_detection``: boolean (default: false) + +When set to ``true``, content type detection will be performed only if the body request content size is under the +size_limit parameter value. + +``size_limit``: int (default: 16 Mb) + +Determine the size stream limit for which the detection as to be skipped if ``skip_detection`` is ``true``. \ No newline at end of file From 9160c3ef2a79243dbf95db07b94350e9ac145981 Mon Sep 17 00:00:00 2001 From: Karim PINCHON Date: Thu, 10 Aug 2017 16:24:57 +0200 Subject: [PATCH 4/4] Indicate a more accurate default value --- plugins/content-type.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/content-type.rst b/plugins/content-type.rst index 411306b..0bd0a19 100644 --- a/plugins/content-type.rst +++ b/plugins/content-type.rst @@ -25,6 +25,6 @@ Options When set to ``true``, content type detection will be performed only if the body request content size is under the size_limit parameter value. -``size_limit``: int (default: 16 Mb) +``size_limit``: int (default: a little bit over 15Mb) Determine the size stream limit for which the detection as to be skipped if ``skip_detection`` is ``true``. \ No newline at end of file