diff --git a/plugins/content-type.rst b/plugins/content-type.rst new file mode 100644 index 0000000..0bd0a19 --- /dev/null +++ b/plugins/content-type.rst @@ -0,0 +1,30 @@ +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 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: 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 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