Skip to content

Commit 32dedd1

Browse files
committed
feat: support raw json bodies in send step
Signed-off-by: Vitor Mattos <vitor@php.rio>
1 parent 7876b05 commit 32dedd1

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

src/NextcloudApiContext.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ public function sendOCSRequest(string $verb, string $url, $body = null, array $h
172172
/**
173173
* @param string $verb
174174
* @param string $url
175-
* @param TableNode|array|null $body
175+
* @param TableNode|PyStringNode|array|null $body
176176
* @param array $headers
177177
*/
178178
#[Given('sending :verb to :url')]
@@ -198,13 +198,16 @@ public function sendRequest(string $verb, string $url, $body = null, array $head
198198
$fd = $body->getRowsHash();
199199
$options['form_params'] = $fd;
200200
$options['_decode_table_node_json'] = true;
201+
} elseif ($body instanceof PyStringNode) {
202+
$options['body'] = $body->getRaw();
203+
$options['headers']['Content-Type'] = 'application/json';
201204
} elseif (is_array($body)) {
202205
$options['form_params'] = $body;
203206
}
204207

205208
$options['headers'] = array_merge($headers, [
206209
'Accept' => 'application/json',
207-
], $this->customHeaders);
210+
], $this->customHeaders, $options['headers'] ?? []);
208211

209212
if ($this->currentUser === 'admin') {
210213
$options['auth'] = ['admin', $this->adminPassword];

0 commit comments

Comments
 (0)