Skip to content

Commit ab38701

Browse files
committed
feature #19289 [HttpClient] Added a paragraph about HttpOptions object (Dean151)
This PR was merged into the 5.4 branch. Discussion ---------- [HttpClient] Added a paragraph about HttpOptions object Partial fix of #19236 A note will be added on the 7.1 branch after this gets merged to warn about the override behavior of ->setHeaders instead of newly added ->addHeader. Commits ------- dbc790b Added a paragraph about HttpOptions object
2 parents a28c1ee + dbc790b commit ab38701

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

http_client.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,16 @@ method to retrieve a new instance of the client with new default options::
149149

150150
The ``withOptions()`` method was introduced in Symfony 5.3.
151151

152+
Alternatively, the :class:`Symfony\\Component\\HttpClient\\HttpOptions` class brings most of the available options with
153+
type-hinted getters and setters::
154+
155+
$this->client = $client->withOptions(
156+
(new HttpOptions())
157+
->setBaseUri('https://...')
158+
->setHeaders(['header-name' => 'header-value'])
159+
->toArray()
160+
);
161+
152162
Some options are described in this guide:
153163

154164
* `Authentication`_

0 commit comments

Comments
 (0)