Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[HttpClient] Add withOptions() to HttplugClient and Psr18Client#17756

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Changes fromall 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
39 changes: 39 additions & 0 deletionshttp_client.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1435,6 +1435,27 @@ Now you can make HTTP requests with the PSR-18 client as follows:

$content = json_decode($response->getBody()->getContents(), true);

You can also pass a set of default options to your client thanks to the
``Psr18Client::withOptions()`` method::

use Symfony\Component\HttpClient\Psr18Client;

$client = (new Psr18Client())
->withOptions([
'base_uri' => 'https://symfony.com',
'headers' => [
'Accept' => 'application/json',
],
]);

$request = $client->createRequest('GET', '/versions.json');

// ...

.. versionadded:: 6.2

The ``Psr18Client::withOptions()`` method was introduced in Symfony 6.2.

HTTPlug
~~~~~~~

Expand DownExpand Up@@ -1523,6 +1544,24 @@ Then you're ready to go::
// wait for all remaining promises to resolve
$httpClient->wait();

You can also pass a set of default options to your client thanks to the
``HttplugClient::withOptions()`` method::

use Psr\Http\Message\ResponseInterface;
use Symfony\Component\HttpClient\HttplugClient;

$httpClient = (new HttplugClient())
->withOptions([
'base_uri' => 'https://my.api.com',
]);
$request = $httpClient->createRequest('GET', '/');

// ...

.. versionadded:: 6.2

The ``HttplugClient::withOptions()`` method was introduced in Symfony 6.2.

Native PHP Streams
~~~~~~~~~~~~~~~~~~

Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp