Skip to content

Commit 44b726d

Browse files
kpn13Nyholm
authored andcommitted
Add content-type plugin documentation (#204)
* Add content-type plugin documentation * Clean content-type plugin doc * Add ContentTypePlugin options * Indicate a more accurate default value
1 parent e777223 commit 44b726d

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

plugins/content-type.rst

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
Content-Type Plugin
2+
===================
3+
4+
The ``ContentTypePlugin`` sets the correct ``Content-Type`` header value based on the content of the body stream of the
5+
request. This helps HTTP servers to handle the request::
6+
7+
use Http\Discovery\HttpClientDiscovery;
8+
use Http\Client\Common\PluginClient;
9+
use Http\Client\Common\Plugin\ContentTypePlugin;
10+
11+
$contentTypePlugin = new ContentTypePlugin();
12+
13+
$pluginClient = new PluginClient(
14+
HttpClientDiscovery::find(),
15+
[$contentTypePlugin]
16+
);
17+
18+
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.
19+
20+
Options
21+
-------
22+
23+
``skip_detection``: boolean (default: false)
24+
25+
When set to ``true``, content type detection will be performed only if the body request content size is under the
26+
size_limit parameter value.
27+
28+
``size_limit``: int (default: a little bit over 15Mb)
29+
30+
Determine the size stream limit for which the detection as to be skipped if ``skip_detection`` is ``true``.

plugins/index.rst

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ request or you can even start a completely new request. This gives you full cont
1313
authentication
1414
cache
1515
content-length
16+
content-type
1617
cookie
1718
decoder
1819
error

0 commit comments

Comments
 (0)