@@ -35,15 +35,21 @@ class Builder
3535 */
3636 private $ defaults = ['urlType ' => 'publicURL ' ];
3737
38+ /** @var array */
39+ private $ requestOptions ;
40+
3841 /**
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
4247 */
43- public function __construct (array $ globalOptions = [], $ rootNamespace = 'OpenCloud ' )
48+ public function __construct (array $ globalOptions = [], $ rootNamespace = 'OpenCloud ' , $ requestOptions = [] )
4449 {
4550 $ this ->globalOptions = $ globalOptions ;
4651 $ this ->rootNamespace = $ rootNamespace ;
52+ $ this ->requestOptions = $ requestOptions ;
4753 }
4854
4955 private function getClasses ($ namespace )
@@ -138,10 +144,12 @@ private function getStack(callable $authHandler, Token $token = null): HandlerSt
138144
139145 private function httpClient (string $ baseUrl , HandlerStack $ stack ): ClientInterface
140146 {
141- return new Client ( [
147+ $ options = array_merge ( $ this -> requestOptions , [
142148 'base_uri ' => Utils::normalizeUrl ($ baseUrl ),
143149 'handler ' => $ stack ,
144150 ]);
151+
152+ return new Client ($ options );
145153 }
146154
147155 private function mergeOptions (array $ serviceOptions ): array
0 commit comments