Skip to content

Commit f14f84d

Browse files
author
Jamie Hannaford
authored
Merge pull request #63 from haphan/guzzle-opts
[wip] Guzzle request options
2 parents 677350e + d6e4f42 commit f14f84d

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@
2525
}
2626
],
2727
"require": {
28-
"php-opencloud/common": "~1.0"
28+
"php-opencloud/common": "^1.0.5"
2929
},
3030
"require-dev": {
3131
"phpunit/phpunit": "~4.0",
3232
"sami/sami": "dev-master",
3333
"psr/log": "~1.0",
3434
"satooshi/php-coveralls": "~1.0",
3535
"jakub-onderka/php-parallel-lint": "0.*",
36-
"fabpot/php-cs-fixer": "~1.0"
36+
"friendsofphp/php-cs-fixer": "^1.0"
3737
}
3838
}

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+
* ['requestOptions'] = (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)