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

Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
This commit is contained in:
Julien Veyssier 2026-06-03 13:11:07 +02:00
parent 0c3f22eb4b
commit 04dc699a29
No known key found for this signature in database
GPG key ID: 4141FEE162030638
2 changed files with 6 additions and 4 deletions

View file

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

View file

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