@@ -50,16 +50,12 @@ public function execute($requestMethod, $url, $parameters = null, $extraOptions
5050 break ;
5151
5252 case 'POST ' :
53- if ($ parameters && is_array ($ parameters )) {
54- curl_setopt ($ curl , CURLOPT_POSTFIELDS , json_encode ($ parameters ));
55- } else {
56- $ customHeaders [] = 'Content-Length: 0 ' ;
57-
58- // Suppress "Transfer-Encoding: chunked" header automatically added by cURL that
59- // causes a 400 bad request (bad content-length).
60- $ customHeaders [] = 'Transfer-Encoding: ' ;
53+ if ( ! $ parameters || ! is_array ($ parameters )) {
54+ $ parameters = array ();
6155 }
6256
57+ curl_setopt ($ curl , CURLOPT_POSTFIELDS , json_encode ($ parameters ));
58+
6359 // Suppress "Expect: 100-continue" header automatically added by cURL that
6460 // causes a 1 second delay if the remote server does not support Expect.
6561 $ customHeaders [] = 'Expect: ' ;
@@ -72,16 +68,12 @@ public function execute($requestMethod, $url, $parameters = null, $extraOptions
7268 break ;
7369
7470 case 'PUT ' :
75- if ($ parameters && is_array ($ parameters )) {
76- curl_setopt ($ curl , CURLOPT_POSTFIELDS , json_encode ($ parameters ));
77- } else {
78- $ customHeaders [] = 'Content-Length: 0 ' ;
79-
80- // Suppress "Transfer-Encoding: chunked" header automatically added by cURL that
81- // causes a 400 bad request (bad content-length).
82- $ customHeaders [] = 'Transfer-Encoding: ' ;
71+ if ( ! $ parameters || ! is_array ($ parameters )) {
72+ $ parameters = array ();
8373 }
8474
75+ curl_setopt ($ curl , CURLOPT_POSTFIELDS , json_encode ($ parameters ));
76+
8577 // Suppress "Expect: 100-continue" header automatically added by cURL that
8678 // causes a 1 second delay if the remote server does not support Expect.
8779 $ customHeaders [] = 'Expect: ' ;
0 commit comments