Skip to content

Commit 7830cb6

Browse files
author
Jamie Hannaford
authored
Merge pull request #4 from haphan/request-options
[rfr] Guzzle request options
2 parents 109aee8 + 14cf2f5 commit 7830cb6

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

src/Common/Service/Builder.php

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,21 +35,16 @@ class Builder
3535
*/
3636
private $defaults = ['urlType' => 'publicURL'];
3737

38-
/** @var array */
39-
private $requestOptions;
40-
4138
/**
4239
* @param array $globalOptions Options that will be applied to every service created by this builder.
4340
* Eventually they will be merged (and if necessary overridden) by the
4441
* service-specific options passed in.
4542
* @param string $rootNamespace API classes' root namespace
46-
* @param array $requestOptions Guzzle client default request option
4743
*/
48-
public function __construct(array $globalOptions = [], $rootNamespace = 'OpenCloud', $requestOptions = [])
44+
public function __construct(array $globalOptions = [], $rootNamespace = 'OpenCloud')
4945
{
5046
$this->globalOptions = $globalOptions;
5147
$this->rootNamespace = $rootNamespace;
52-
$this->requestOptions = $requestOptions;
5348
}
5449

5550
private function getClasses($namespace)
@@ -144,12 +139,16 @@ private function getStack(callable $authHandler, Token $token = null): HandlerSt
144139

145140
private function httpClient(string $baseUrl, HandlerStack $stack): ClientInterface
146141
{
147-
$options = array_merge($this->requestOptions, [
142+
$clientOptions = [
148143
'base_uri' => Utils::normalizeUrl($baseUrl),
149144
'handler' => $stack,
150-
]);
145+
];
146+
147+
if (isset($this->globalOptions['requestOptions'])) {
148+
$clientOptions = array_merge($this->globalOptions['requestOptions'], $clientOptions);
149+
}
151150

152-
return new Client($options);
151+
return new Client($clientOptions);
153152
}
154153

155154
private function mergeOptions(array $serviceOptions): array

0 commit comments

Comments
 (0)