Skip to content

Commit 439dfa6

Browse files
committed
Convert headers received as a list into key/value pairs
1 parent d7efaab commit 439dfa6

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/Browser.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
use function implode;
4646
use function in_array;
4747
use function is_array;
48+
use function is_int;
4849
use function is_resource;
4950
use function preg_split;
5051
use function property_exists;
@@ -282,6 +283,14 @@ public function request($method, $url, array $headers = [], string|ReadableStrea
282283

283284
$headers = array_change_key_case($headers, CASE_LOWER);
284285

286+
//If we have been passed an array of headers in "Content-Type: application/json" convert to our Header => Value format
287+
foreach($headers as $key => $value) {
288+
if (is_int($key) && str_contains($value, ":")) {
289+
[$header, $value] = explode(":", $value, 2);
290+
$headers[strtolower($header)] = $value;
291+
}
292+
}
293+
285294
if ($body instanceof ReadableStreamInterface ) {
286295
$upload = new UploadBodyStream($body);
287296
$upload->on('pause', static function () use ($curl) {

0 commit comments

Comments
 (0)