Skip to content

Commit 04dc699

Browse files
committed
feat(guzzle): allow overriding the default curl handler when creating a new client
Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
1 parent 0c3f22e commit 04dc699

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

lib/private/Http/Client/ClientService.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ public function __construct(
4141
}
4242

4343
#[\Override]
44-
public function newClient(): IClient {
45-
$handler = new CurlHandler();
46-
$stack = HandlerStack::create($handler);
44+
public function newClient(?callable $handler = null): IClient {
45+
$clientHandler = $handler ?? new CurlHandler();
46+
$stack = HandlerStack::create($clientHandler);
4747
if ($this->config->getSystemValueBool('dns_pinning', true)) {
4848
$stack->push($this->dnsPinMiddleware->addDnsPinning());
4949
}

lib/public/Http/Client/IClientService.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@
1616
*/
1717
interface IClientService {
1818
/**
19+
* @param ?callable $handler Handler that overrides the default CurlHandler
1920
* @return IClient
2021
* @since 8.1.0
22+
* @since 35.0.0 Added $handler optional param
2123
*/
22-
public function newClient(): IClient;
24+
public function newClient(?callable $handler = null): IClient;
2325
}

0 commit comments

Comments
 (0)