File tree 2 files changed +26
-0
lines changed
2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -20,5 +20,6 @@ request or you can even start a completely new request. This gives you full cont
20
20
history
21
21
logger
22
22
redirect
23
+ request-uri-manipulations
23
24
retry
24
25
stopwatch
Original file line number Diff line number Diff line change
1
+ Request URI Manipulations
2
+ =========================
3
+
4
+ Request URI manipulations can be done thanks to several plugins:
5
+
6
+ * ``AddHostPlugin ``: Sets default host, scheme and port of each request.
7
+ * ``AddPathPlugin ``: Sets default base path of each request.
8
+ * ``BaseUriPlugin ``: Is a combination of ``AddHostPlugin `` and ``AddPathPlugin `` using the ``UriInterface `` class.
9
+
10
+ Each plugin use the ``UriInterface `` to build the base request::
11
+
12
+ use Http\Discovery\HttpClientDiscovery;
13
+ use Http\Discovery\UriFactoryDiscovery;
14
+ use Http\Client\Common\PluginClient;
15
+ use Http\Client\Common\Plugin\BaseUriPlugin;
16
+
17
+ $plugin = new BaseUriPlugin(UriFactoryDiscovery::find()->createUri('https://domain.com:8000/api'), [
18
+ // Always replace the host, even if this one is provided on the sent request. Available for AddHostPlugin.
19
+ 'replace' => 'true',
20
+ ]));
21
+
22
+ $pluginClient = new PluginClient(
23
+ HttpClientDiscovery::find(),
24
+ [$plugin]
25
+ );
You can’t perform that action at this time.
0 commit comments