Skip to content

Add content-type plugin documentation #204

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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