diff --git a/http_client.rst b/http_client.rst index 2ca591a5098..b76c8e25199 100644 --- a/http_client.rst +++ b/http_client.rst @@ -150,10 +150,17 @@ brings most of the available options with type-hinted getters and setters:: $this->client = $client->withOptions( (new HttpOptions()) ->setBaseUri('https://...') + // setHeaders() replaces *all* headers at once, and deletes the headers you do not provide ->setHeaders(['header-name' => 'header-value']) + // add or replace a single header using addHeader() + ->addHeader('another-header-name', 'another-header-value') ->toArray() ); +.. versionadded:: 7.1 + + The :method:`Symfony\\Component\\HttpClient\\HttpOptions::addHeader` method was introduced in Symfony 7.1. + Some options are described in this guide: * `Authentication`_