@@ -35,15 +35,21 @@ class Builder
35
35
*/
36
36
private $ defaults = ['urlType ' => 'publicURL ' ];
37
37
38
+ /** @var array */
39
+ private $ requestOptions ;
40
+
38
41
/**
39
- * @param array $globalOptions Options that will be applied to every service created by this builder.
40
- * Eventually they will be merged (and if necessary overridden) by the
41
- * service-specific options passed in.
42
+ * @param array $globalOptions Options that will be applied to every service created by this builder.
43
+ * Eventually they will be merged (and if necessary overridden) by the
44
+ * service-specific options passed in.
45
+ * @param string $rootNamespace API classes' root namespace
46
+ * @param array $requestOptions Guzzle client default request option
42
47
*/
43
- public function __construct (array $ globalOptions = [], $ rootNamespace = 'OpenCloud ' )
48
+ public function __construct (array $ globalOptions = [], $ rootNamespace = 'OpenCloud ' , $ requestOptions = [] )
44
49
{
45
50
$ this ->globalOptions = $ globalOptions ;
46
51
$ this ->rootNamespace = $ rootNamespace ;
52
+ $ this ->requestOptions = $ requestOptions ;
47
53
}
48
54
49
55
private function getClasses ($ namespace )
@@ -138,10 +144,12 @@ private function getStack(callable $authHandler, Token $token = null): HandlerSt
138
144
139
145
private function httpClient (string $ baseUrl , HandlerStack $ stack ): ClientInterface
140
146
{
141
- return new Client ( [
147
+ $ options = array_merge ( $ this -> requestOptions , [
142
148
'base_uri ' => Utils::normalizeUrl ($ baseUrl ),
143
149
'handler ' => $ stack ,
144
150
]);
151
+
152
+ return new Client ($ options );
145
153
}
146
154
147
155
private function mergeOptions (array $ serviceOptions ): array
0 commit comments