Skip to content

Commit 52528bb

Browse files
committed
Allow user to provide Guzzle options in requests
1 parent 2bbe999 commit 52528bb

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/Common/Api/OperatorTrait.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,10 @@ protected function sendRequest(Operation $operation, array $userValues = [], boo
112112

113113
$uri = Utils::uri_template($operation->getPath(), $userValues);
114114

115+
if (array_key_exists('guzzle', $userValues)) {
116+
$options += $userValues['guzzle'];
117+
}
118+
115119
return $this->client->$method($operation->getMethod(), $uri, $options);
116120
}
117121

tests/unit/Common/Api/OperatorTraitTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,17 @@ public function test_it_populates_models_from_arrays()
105105
$data = ['flavor' => [], 'image' => []];
106106
$this->assertInstanceOf(ResourceInterface::class, $this->operator->model(TestResource::class, $data));
107107
}
108+
109+
public function test_guzzle_options_are_forwarded()
110+
{
111+
$this->client->request('GET', 'test', ['headers' => [], 'stream' => true])->willReturn(new Response());
112+
113+
$this->operator->execute($this->def, [
114+
'guzzle' => ['stream' => true]
115+
]);
116+
117+
$this->addToAssertionCount(1);
118+
}
108119
}
109120

110121
class TestResource extends AbstractResource

0 commit comments

Comments
 (0)