@@ -53,16 +53,12 @@ public function execute($requestMethod, $url, $parameters = null, $extraOptions
5353 break ;
5454
5555 case 'POST ' :
56- if ($ parameters && is_array ($ parameters )) {
57- curl_setopt ($ curl , CURLOPT_POSTFIELDS , json_encode ($ parameters ));
58- } else {
59- $ customHeaders [] = 'Content-Length: 0 ' ;
60-
61- // Suppress "Transfer-Encoding: chunked" header automatically added by cURL that
62- // causes a 400 bad request (bad content-length).
63- $ customHeaders [] = 'Transfer-Encoding: ' ;
56+ if ( ! $ parameters || ! is_array ($ parameters )) {
57+ $ parameters = array ();
6458 }
6559
60+ curl_setopt ($ curl , CURLOPT_POSTFIELDS , json_encode ($ parameters ));
61+
6662 // Suppress "Expect: 100-continue" header automatically added by cURL that
6763 // causes a 1 second delay if the remote server does not support Expect.
6864 $ customHeaders [] = 'Expect: ' ;
@@ -75,16 +71,12 @@ public function execute($requestMethod, $url, $parameters = null, $extraOptions
7571 break ;
7672
7773 case 'PUT ' :
78- if ($ parameters && is_array ($ parameters )) {
79- curl_setopt ($ curl , CURLOPT_POSTFIELDS , json_encode ($ parameters ));
80- } else {
81- $ customHeaders [] = 'Content-Length: 0 ' ;
82-
83- // Suppress "Transfer-Encoding: chunked" header automatically added by cURL that
84- // causes a 400 bad request (bad content-length).
85- $ customHeaders [] = 'Transfer-Encoding: ' ;
74+ if ( ! $ parameters || ! is_array ($ parameters )) {
75+ $ parameters = array ();
8676 }
8777
78+ curl_setopt ($ curl , CURLOPT_POSTFIELDS , json_encode ($ parameters ));
79+
8880 // Suppress "Expect: 100-continue" header automatically added by cURL that
8981 // causes a 1 second delay if the remote server does not support Expect.
9082 $ customHeaders [] = 'Expect: ' ;
0 commit comments