Skip to content

Commit

Permalink
fix empty POST/PUT body in 520d22b
Browse files Browse the repository at this point in the history
  • Loading branch information
robocoder committed Dec 6, 2023
1 parent 4ac0709 commit 9e60018
Showing 1 changed file with 8 additions and 19 deletions.
27 changes: 8 additions & 19 deletions lib/WebDriver/Service/CurlService.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,36 +50,25 @@ public function execute($requestMethod, $url, $parameters = null, $extraOptions
break;

case 'POST':
if ( ! $parameters || ! is_array($parameters)) {
$parameters = array();
}
case 'PUT':
$parameters = ! $parameters || ! is_array($parameters)
? '{}'
: json_encode($parameters);

curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($parameters));
curl_setopt($curl, CURLOPT_POSTFIELDS, $parameters);

// Suppress "Expect: 100-continue" header automatically added by cURL that
// causes a 1 second delay if the remote server does not support Expect.
$customHeaders[] = 'Expect:';

curl_setopt($curl, CURLOPT_POST, true);
$requestMethod === 'POST'
? curl_setopt($curl, CURLOPT_POST, true)
: curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'PUT');
break;

case 'DELETE':
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'DELETE');
break;

case 'PUT':
if ( ! $parameters || ! is_array($parameters)) {
$parameters = array();
}

curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($parameters));

// Suppress "Expect: 100-continue" header automatically added by cURL that
// causes a 1 second delay if the remote server does not support Expect.
$customHeaders[] = 'Expect:';

curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'PUT');
break;
}

foreach ($extraOptions as $option => $value) {
Expand Down

0 comments on commit 9e60018

Please sign in to comment.