You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/plugins.md
+31-39Lines changed: 31 additions & 39 deletions
Original file line number
Diff line number
Diff line change
@@ -1,12 +1,12 @@
1
1
# Plugin System
2
2
3
-
The plugin system allow to manipulate requests and responses inside an `HttpClient`.
3
+
The plugin system allows to look at requests and responses and replace them if needed, inside an `HttpClient`.
4
4
5
-
By using the `Http\Client\Plugin\PluginClient` you can inject an `HttpClient` or an `HttpAsyncClient`, and an array
5
+
Using the `Http\Client\Plugin\PluginClient`, you can inject an `HttpClient`, or an `HttpAsyncClient`, and an array
6
6
of plugins implementing the `Http\Client\Plugin\Plugin` interface.
7
7
8
-
Each plugin can modify the `RequestInterface` sent or the `ResponseInterface` received. It can also change the behavior of a call
9
-
like retrying the request or emit another one when a redirection is present.
8
+
Each plugin can replace the `RequestInterface` sent or the `ResponseInterface` received. It can also change the behavior of a call,
9
+
like retrying the request or emit another one when a redirection response was received.
10
10
11
11
## Install
12
12
@@ -42,7 +42,7 @@ $pluginClient = new PluginClient(HttpClientDiscovery::find(), [
42
42
]);
43
43
```
44
44
45
-
After you can use this plugin client like a classic `Http\Client\HttpClient` or `Http\Client\HttpAsyncClient` one:
45
+
You can use the plugin client like a classic `Http\Client\HttpClient` or `Http\Client\HttpAsyncClient` one:
46
46
47
47
```php
48
48
// Send a request
@@ -56,25 +56,24 @@ Go to the [tutorial](tutorial.md) to read more about using `HttpClient` and `Htt
56
56
57
57
## Available plugins
58
58
59
-
Each plugin have its own configuration and dependencies, check the documentation for each of the available plugin:
59
+
Each plugin has its own configuration and dependencies, check the documentation for each of the available plugins:
60
60
61
61
-[Authentication](plugins/authentication.md): Add authentication header on a request
62
-
-[Cookie](plugins/cookie.md): Add cookie to request and save them from the response by using a CookieJar
63
-
-[Encoding](plugins/encoding.md): Add support for receiving chunked, deflate or gzip response
62
+
-[Cookie](plugins/cookie.md): Add cookies to request and save them from the response
63
+
-[Encoding](plugins/encoding.md): Add support for receiving chunked, deflate or gzip response
64
64
-[Error](plugins/error.md): Transform bad response (400 to 599) to exception
65
65
-[Redirect](plugins/redirect.md): Follow redirection coming from 3XX responses
66
66
-[Retry](plugins/retry.md): Retry a failed call
67
-
-[Stopwatch](plugins/stopwatch.md): Log time of a request call by using the Stopwatch component
67
+
-[Stopwatch](plugins/stopwatch.md): Log time of a request call by using [the Symfony Stopwatch component](http://symfony.com/doc/current/components/stopwatch.html)
68
68
69
69
## Order of plugins
70
70
71
-
When you inject an array of plugins into the `PluginClient`, order of the plugins in array matters.
71
+
When you inject an array of plugins into the `PluginClient`, the order of the plugins, injected into the `PluginClient`, matters.
72
72
73
-
Plugins are transformed into a plugin chain, where the first element in array will be called first, and,
74
-
obviously, the last element will be called at the end. However when the `ResponseInterface` or the `Promise` is
75
-
received from the underlying client, this execution chain is revert and the last plugin defined will be called first.
73
+
During the request, plugins are called in the order they have in the array, from first to last plugin. Once a response has been received,
74
+
they are called again in inverse order, from last to first.
0 commit comments