From 04dc699a29d25753e6f4a57d43cdbbc28e2db48e Mon Sep 17 00:00:00 2001 From: Julien Veyssier Date: Wed, 3 Jun 2026 13:11:07 +0200 Subject: [PATCH] feat(guzzle): allow overriding the default curl handler when creating a new client Signed-off-by: Julien Veyssier --- lib/private/Http/Client/ClientService.php | 6 +++--- lib/public/Http/Client/IClientService.php | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/private/Http/Client/ClientService.php b/lib/private/Http/Client/ClientService.php index 8df3d3ed193..385a49f5a60 100644 --- a/lib/private/Http/Client/ClientService.php +++ b/lib/private/Http/Client/ClientService.php @@ -41,9 +41,9 @@ class ClientService implements IClientService { } #[\Override] - public function newClient(): IClient { - $handler = new CurlHandler(); - $stack = HandlerStack::create($handler); + public function newClient(?callable $handler = null): IClient { + $clientHandler = $handler ?? new CurlHandler(); + $stack = HandlerStack::create($clientHandler); if ($this->config->getSystemValueBool('dns_pinning', true)) { $stack->push($this->dnsPinMiddleware->addDnsPinning()); } diff --git a/lib/public/Http/Client/IClientService.php b/lib/public/Http/Client/IClientService.php index 12edf3dcf84..7c853dbbe90 100644 --- a/lib/public/Http/Client/IClientService.php +++ b/lib/public/Http/Client/IClientService.php @@ -16,8 +16,10 @@ namespace OCP\Http\Client; */ interface IClientService { /** + * @param ?callable $handler Handler that overrides the default CurlHandler * @return IClient * @since 8.1.0 + * @since 35.0.0 Added $handler optional param */ - public function newClient(): IClient; + public function newClient(?callable $handler = null): IClient; }