8000 [HttpClient] Add `withOptions()` to `HttplugClient` and `Psr18Client` · symfony/symfony@1e2afea · GitHub
[go: up one dir, main page]

Skip to content

Commit 1e2afea

Browse files
[HttpClient] Add withOptions() to HttplugClient and Psr18Client
1 parent d0dc7b2 commit 1e2afea

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

src/Symfony/Component/HttpClient/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ CHANGELOG
66

77
* Make `HttplugClient` implement `Psr\Http\Message\RequestFactoryInterface`, `StreamFactoryInterface` and `UriFactoryInterface`
88
* Deprecate implementing `Http\Message\RequestFactory`, `StreamFactory` and `UriFactory` on `HttplugClient`
9+
* Add `withOptions()` to `HttplugClient` and `Psr18Client`
910

1011
6.1
1112
---

src/Symfony/Component/HttpClient/HttplugClient.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,14 @@ public function __construct(HttpClientInterface $client = null, ResponseFactoryI
9999
$this->waitLoop = new HttplugWaitLoop($this->client, $this->promisePool, $this->responseFactory, $this->streamFactory);
100100
}
101101

102+
public function withOptions(array $options): static
103+
{
104+
$clone = clone $this;
105+
$clone->client = $clone->client->withOptions($options);
106+
107+
return $clone;
108+
}
109+
102110
public function sendRequest(RequestInterface $request): Psr7ResponseInterface
103111
{
104112
try {

src/Symfony/Component/HttpClient/Psr18Client.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,14 @@ public function __construct(HttpClientInterface $client = null, ResponseFactoryI
7979
$this->streamFactory = $streamFactory;
8080
}
8181

82+
public function withOptions(array $options): static
83+
{
84+
$clone = clone $this;
85+
$clone->client = $clone->client->withOptions($options);
86+
87+
return $clone;
88+
}
89+
8290
public function sendRequest(RequestInterface $request): ResponseInterface
8391
{
8492
try {

0 commit comments

Comments
 (0)
0