@@ -50,36 +50,25 @@ public function execute($requestMethod, $url, $parameters = null, $extraOptions
50
50
break ;
51
51
52
52
case 'POST ' :
53
- if ( ! $ parameters || ! is_array ($ parameters )) {
54
- $ parameters = array ();
55
- }
53
+ case 'PUT ' :
54
+ $ parameters = ! $ parameters || ! is_array ($ parameters )
55
+ ? '{} '
56
+ : json_encode ($ parameters );
56
57
57
- curl_setopt ($ curl , CURLOPT_POSTFIELDS , json_encode ( $ parameters) );
58
+ curl_setopt ($ curl , CURLOPT_POSTFIELDS , $ parameters );
58
59
59
60
// Suppress "Expect: 100-continue" header automatically added by cURL that
60
61
// causes a 1 second delay if the remote server does not support Expect.
61
62
$ customHeaders [] = 'Expect: ' ;
62
63
63
- curl_setopt ($ curl , CURLOPT_POST , true );
64
+ $ requestMethod === 'POST '
65
+ ? curl_setopt ($ curl , CURLOPT_POST , true )
66
+ : curl_setopt ($ curl , CURLOPT_CUSTOMREQUEST , 'PUT ' );
64
67
break ;
65
68
66
69
case 'DELETE ' :
67
70
curl_setopt ($ curl , CURLOPT_CUSTOMREQUEST , 'DELETE ' );
68
71
break ;
69
-
70
- case 'PUT ' :
71
- if ( ! $ parameters || ! is_array ($ parameters )) {
72
- $ parameters = array ();
73
- }
74
-
75
- curl_setopt ($ curl , CURLOPT_POSTFIELDS , json_encode ($ parameters ));
76
-
77
- // Suppress "Expect: 100-continue" header automatically added by cURL that
78
- // causes a 1 second delay if the remote server does not support Expect.
79
- $ customHeaders [] = 'Expect: ' ;
80
-
81
- curl_setopt ($ curl , CURLOPT_CUSTOMREQUEST , 'PUT ' );
82
- break ;
83
72
}
84
73
85
74
foreach ($ extraOptions as $ option => $ value ) {
0 commit comments