From 436f69e60f3177827ffb162bd48824433dd2acc5 Mon Sep 17 00:00:00 2001 From: Thomas Durand Date: Thu, 14 Dec 2023 15:41:19 +0100 Subject: [PATCH] [HttpClient] Add `HttpOptions::addHeader` method --- http_client.rst | 7 +++++++ 1 file changed, 7 insertions(+) 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`_