Skip to content

Commit 285fff8

Browse files
committed
Custom Guzzle request options
1 parent 677350e commit 285fff8

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/OpenStack.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class OpenStack
2020
private $builder;
2121

2222
/**
23-
* @param array $options User-defined options
23+
* @param array $options User-defined options
2424
*
2525
* $options['username'] = (string) Your OpenStack username [REQUIRED]
2626
* ['password'] = (string) Your OpenStack password [REQUIRED]
@@ -30,6 +30,9 @@ class OpenStack
3030
* ['debugLog'] = (bool) Whether to enable HTTP logging [OPTIONAL]
3131
* ['logger'] = (LoggerInterface) Must set if debugLog is true [OPTIONAL]
3232
* ['messageFormatter'] = (MessageFormatter) Must set if debugLog is true [OPTIONAL]
33+
* ['requestOption'] = (array) Guzzle Http request options [OPTIONAL]
34+
*
35+
* @param Builder $builder
3336
*/
3437
public function __construct(array $options = [], Builder $builder = null)
3538
{
@@ -51,10 +54,16 @@ private function getDefaultIdentityService(array $options): Service
5154
throw new \InvalidArgumentException("'authUrl' is a required option");
5255
}
5356

54-
return Service::factory(new Client([
57+
$clientOptions = [
5558
'base_uri' => Utils::normalizeUrl($options['authUrl']),
5659
'handler' => HandlerStack::create(),
57-
]));
60+
];
61+
62+
if (isset($options['requestOptions'])) {
63+
$clientOptions = array_merge($options['requestOptions'], $clientOptions);
64+
}
65+
66+
return Service::factory(new Client($clientOptions));
5867
}
5968

6069
/**

0 commit comments

Comments
 (0)