Skip to content

Commit

Permalink
CurlService should set its headers first so user's extraOptions can o…
Browse files Browse the repository at this point in the history
…verride
  • Loading branch information
robocoder committed Dec 8, 2023
1 parent 1c4f303 commit 3314cd8
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/WebDriver/Service/CurlService.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ public function execute($requestMethod, $url, $parameters = null, $extraOptions

case 'POST':
case 'PUT':
$parameters = ! $parameters || ! is_array($parameters)
? '{}'
$parameters = ! $parameters || ! is_array($parameters)
? '{}' // instead of json_encode(new \stdclass))
: json_encode($parameters);

curl_setopt($curl, CURLOPT_POSTFIELDS, $parameters);
Expand All @@ -74,12 +74,12 @@ public function execute($requestMethod, $url, $parameters = null, $extraOptions
break;
}

curl_setopt($curl, CURLOPT_HTTPHEADER, $customHeaders);

foreach (array_replace($this->defaultOptions, $extraOptions) as $option => $value) {
curl_setopt($curl, $option, $value);
}

curl_setopt($curl, CURLOPT_HTTPHEADER, $customHeaders);

$rawResult = curl_exec($curl);
$rawResult = is_string($rawResult) ? trim($rawResult) : '';

Expand Down

0 comments on commit 3314cd8

Please sign in to comment.