@@ -53,36 +53,25 @@ public function execute($requestMethod, $url, $parameters = null, $extraOptions
5353 break ;
5454
5555 case 'POST ' :
56- if ( ! $ parameters || ! is_array ($ parameters )) {
57- $ parameters = array ();
58- }
56+ case 'PUT ' :
57+ $ parameters = ! $ parameters || ! is_array ($ parameters )
58+ ? '{} '
59+ : json_encode ($ parameters );
5960
60- curl_setopt ($ curl , CURLOPT_POSTFIELDS , json_encode ( $ parameters) );
61+ curl_setopt ($ curl , CURLOPT_POSTFIELDS , $ parameters );
6162
6263 // Suppress "Expect: 100-continue" header automatically added by cURL that
6364 // causes a 1 second delay if the remote server does not support Expect.
6465 $ customHeaders [] = 'Expect: ' ;
6566
66- curl_setopt ($ curl , CURLOPT_POST , true );
67+ $ requestMethod === 'POST '
68+ ? curl_setopt ($ curl , CURLOPT_POST , true )
69+ : curl_setopt ($ curl , CURLOPT_CUSTOMREQUEST , 'PUT ' );
6770 break ;
6871
6972 case 'DELETE ' :
7073 curl_setopt ($ curl , CURLOPT_CUSTOMREQUEST , 'DELETE ' );
7174 break ;
72-
73- case 'PUT ' :
74- if ( ! $ parameters || ! is_array ($ parameters )) {
75- $ parameters = array ();
76- }
77-
78- curl_setopt ($ curl , CURLOPT_POSTFIELDS , json_encode ($ parameters ));
79-
80- // Suppress "Expect: 100-continue" header automatically added by cURL that
81- // causes a 1 second delay if the remote server does not support Expect.
82- $ customHeaders [] = 'Expect: ' ;
83-
84- curl_setopt ($ curl , CURLOPT_CUSTOMREQUEST , 'PUT ' );
85- break ;
8675 }
8776
8877 foreach (array_replace ($ this ->defaultOptions , $ extraOptions ) as $ option => $ value ) {
0 commit comments