Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions src/Common/Service/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,21 @@ class Builder
*/
private $defaults = ['urlType' => 'publicURL'];

/** @var array */
private $requestOptions;

/**
* @param array $globalOptions Options that will be applied to every service created by this builder.
* Eventually they will be merged (and if necessary overridden) by the
* service-specific options passed in.
* @param array $globalOptions Options that will be applied to every service created by this builder.
* Eventually they will be merged (and if necessary overridden) by the
* service-specific options passed in.
* @param string $rootNamespace API classes' root namespace
* @param array $requestOptions Guzzle client default request option
*/
public function __construct(array $globalOptions = [], $rootNamespace = 'OpenCloud')
public function __construct(array $globalOptions = [], $rootNamespace = 'OpenCloud', $requestOptions = [])
{
$this->globalOptions = $globalOptions;
$this->rootNamespace = $rootNamespace;
$this->requestOptions = $requestOptions;
}

private function getClasses($namespace)
Expand Down Expand Up @@ -138,10 +144,12 @@ private function getStack(callable $authHandler, Token $token = null): HandlerSt

private function httpClient(string $baseUrl, HandlerStack $stack): ClientInterface
{
return new Client([
$options = array_merge($this->requestOptions, [
'base_uri' => Utils::normalizeUrl($baseUrl),
'handler' => $stack,
]);

return new Client($options);
}

private function mergeOptions(array $serviceOptions): array
Expand Down