Skip to content

Commit b817af0

Browse files
committed
Closes #15033 by documenting the HttpClientInterface::withOptions method
1 parent 94df07b commit b817af0

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

http_client.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,20 @@ You can configure the global options using the ``default_options`` option:
138138
'max_redirects' => 7,
139139
]);
140140
141+
You can also use the :method:`Symfony\\Contracts\\HttpClient\\HttpClientInterface::withOptions`
142+
method to retrieve a new instance of the client with new default options :
143+
144+
.. code-block:: php
145+
146+
$this->client = $client->withOptions([
147+
'base_uri' => 'https://...',
148+
'headers' => ['header-name' => 'value0, value1, ...']
149+
]);
150+
151+
.. versionadded:: 5.3
152+
153+
The :method:`Symfony\\Contracts\\HttpClient\\HttpClientInterface::withOptions` method was introduced in Symfony 5.3.
154+
141155
Some options are described in this guide:
142156

143157
* `Authentication`_

0 commit comments

Comments
 (0)