Skip to content

Commit

Permalink
Add content-type plugin documentation (#204)
Browse files Browse the repository at this point in the history
* Add content-type plugin documentation

* Clean content-type plugin doc

* Add ContentTypePlugin options

* Indicate a more accurate default value
  • Loading branch information
kpn13 authored and Nyholm committed Aug 10, 2017
1 parent e777223 commit 44b726d
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
30 changes: 30 additions & 0 deletions plugins/content-type.rst
Original file line number Diff line number Diff line change
@@ -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``.
1 change: 1 addition & 0 deletions plugins/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 44b726d

Please sign in to comment.