Skip to content

Commit

Permalink
fixes #122 - translate empty params in POST
Browse files Browse the repository at this point in the history
  • Loading branch information
robocoder committed Dec 4, 2023
1 parent f4c78bd commit e8d3c96
Showing 1 changed file with 8 additions and 16 deletions.
24 changes: 8 additions & 16 deletions lib/WebDriver/Service/CurlService.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,12 @@ public function execute($requestMethod, $url, $parameters = null, $extraOptions
break;

case 'POST':
if ($parameters && is_array($parameters)) {
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($parameters));
} else {
$customHeaders[] = 'Content-Length: 0';

// Suppress "Transfer-Encoding: chunked" header automatically added by cURL that
// causes a 400 bad request (bad content-length).
$customHeaders[] = 'Transfer-Encoding:';
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:';
Expand All @@ -75,16 +71,12 @@ public function execute($requestMethod, $url, $parameters = null, $extraOptions
break;

case 'PUT':
if ($parameters && is_array($parameters)) {
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($parameters));
} else {
$customHeaders[] = 'Content-Length: 0';

// Suppress "Transfer-Encoding: chunked" header automatically added by cURL that
// causes a 400 bad request (bad content-length).
$customHeaders[] = 'Transfer-Encoding:';
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:';
Expand Down

0 comments on commit e8d3c96

Please sign in to comment.