File tree 2 files changed +27
-0
lines changed
2 files changed +27
-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 ``: Set host, scheme and port. Depending on configuration,
7
+ the host is overwritten in every request or only set if not yet defined in the request.
8
+ * ``AddPathPlugin ``: Prefix the request path with a path, leaving the host information untouched.
9
+ * ``BaseUriPlugin ``: It's a combination of ``AddHostPlugin `` and ``AddPathPlugin ``.
10
+
11
+ Each plugin use the ``UriInterface `` to build the base request::
12
+
13
+ use Http\Discovery\HttpClientDiscovery;
14
+ use Http\Discovery\UriFactoryDiscovery;
15
+ use Http\Client\Common\PluginClient;
16
+ use Http\Client\Common\Plugin\BaseUriPlugin;
17
+
18
+ $plugin = new BaseUriPlugin(UriFactoryDiscovery::find()->createUri('https://domain.com:8000/api'), [
19
+ // Always replace the host, even if this one is provided on the sent request. Available for AddHostPlugin.
20
+ 'replace' => true,
21
+ ]));
22
+
23
+ $pluginClient = new PluginClient(
24
+ HttpClientDiscovery::find(),
25
+ [$plugin]
26
+ );
You can’t perform that action at this time.
0 commit comments