Skip to content

Commit

Permalink
Allow http client options
Browse files Browse the repository at this point in the history
  • Loading branch information
sergix44 committed Mar 23, 2024
1 parent 64017a0 commit 00c6b99
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ class Client extends RemoteClient

private ?string $hfToken;

public function __construct(string $src, ?string $hfToken = null, ?Config $config = null)
public function __construct(string $src, ?string $hfToken = null, ?Config $config = null, array $httpClientOptions = [])
{
parent::__construct($src);
parent::__construct($src, $httpClientOptions);
$this->config = $config ?? $this->http('get', self::HTTP_CONFIG, dto: Config::class);
$this->loadEndpoints($this->config->dependencies);
$this->sessionHash = substr(md5(microtime()), 0, 11);
Expand Down
6 changes: 3 additions & 3 deletions src/Client/RemoteClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ abstract class RemoteClient extends RegisterEvents

protected HydratorInterface $hydrator;

public function __construct(string $src)
public function __construct(string $src, array $httpClientOptions = [])
{
if (
! str_starts_with($src, 'http://') &&
Expand All @@ -32,13 +32,13 @@ public function __construct(string $src)

$this->hydrator = new Hydrator();

$this->httpClient = new Guzzle([
$this->httpClient = new Guzzle(array_merge([
'base_uri' => str_replace('ws', 'http', $this->src),
'headers' => [
'User-Agent' => 'gradio_client_php/1.0',
'Accept' => 'application/json',
],
]);
], $httpClientOptions));
}

protected function http(string $method, string $uri, array $params = [], array $opt = [], ?string $dto = null)
Expand Down

0 comments on commit 00c6b99

Please sign in to comment.