feat(guzzle): allow overriding the default curl handler when creating a new client

Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
pull/60167/head
Julien Veyssier 3 months ago
parent 0c3f22eb4b
commit 04dc699a29
No known key found for this signature in database
GPG Key ID: 4141FEE162030638
  1. 6
      lib/private/Http/Client/ClientService.php
  2. 4
      lib/public/Http/Client/IClientService.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());
}

@ -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;
}

Loading…
Cancel
Save