From dbc790bab4fa9058e11b31bfe9b2f672c20f246e Mon Sep 17 00:00:00 2001 From: Thomas Durand Date: Thu, 14 Dec 2023 01:18:31 +0100 Subject: [PATCH] Added a paragraph about HttpOptions object A note will be added for 7.1 to warn about the override behavior of ->setHeaders instead of newly added ->addHeader --- http_client.rst | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/http_client.rst b/http_client.rst index d05977e7155..137933a36e1 100644 --- a/http_client.rst +++ b/http_client.rst @@ -149,6 +149,16 @@ method to retrieve a new instance of the client with new default options:: The ``withOptions()`` method was introduced in Symfony 5.3. +Alternatively, the :class:`Symfony\\Component\\HttpClient\\HttpOptions` class brings most of the available options with +type-hinted getters and setters:: + + $this->client = $client->withOptions( + (new HttpOptions()) + ->setBaseUri('https://...') + ->setHeaders(['header-name' => 'header-value']) + ->toArray() + ); + Some options are described in this guide: * `Authentication`_