Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions http_client.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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`_
Expand Down