@@ -94,7 +94,7 @@ public function get($url_mixed, $data = array())
94
94
public function post ($ url , $ data = array ())
95
95
{
96
96
if (is_array ($ data ) && empty ($ data )) {
97
- $ this ->setHeader ('Content-Length ' );
97
+ $ this ->unsetHeader ('Content-Length ' );
98
98
}
99
99
100
100
$ this ->setOpt (CURLOPT_URL , $ this ->buildURL ($ url ));
@@ -118,7 +118,7 @@ public function put($url, $data = array())
118
118
119
119
public function patch ($ url , $ data = array ())
120
120
{
121
- $ this ->setHeader ('Content-Length ' );
121
+ $ this ->unsetHeader ('Content-Length ' );
122
122
$ this ->setOpt (CURLOPT_URL , $ this ->buildURL ($ url ));
123
123
$ this ->setOpt (CURLOPT_CUSTOMREQUEST , 'PATCH ' );
124
124
$ this ->setOpt (CURLOPT_POSTFIELDS , $ data );
@@ -127,7 +127,7 @@ public function patch($url, $data = array())
127
127
128
128
public function delete ($ url , $ data = array ())
129
129
{
130
- $ this ->setHeader ('Content-Length ' );
130
+ $ this ->unsetHeader ('Content-Length ' );
131
131
$ this ->setOpt (CURLOPT_URL , $ this ->buildURL ($ url , $ data ));
132
132
$ this ->setOpt (CURLOPT_CUSTOMREQUEST , 'DELETE ' );
133
133
return $ this ->exec ();
@@ -143,7 +143,7 @@ public function head($url, $data = array())
143
143
144
144
public function options ($ url , $ data = array ())
145
145
{
146
- $ this ->setHeader ('Content-Length ' );
146
+ $ this ->unsetHeader ('Content-Length ' );
147
147
$ this ->setOpt (CURLOPT_URL , $ this ->buildURL ($ url , $ data ));
148
148
$ this ->setOpt (CURLOPT_CUSTOMREQUEST , 'OPTIONS ' );
149
149
return $ this ->exec ();
@@ -155,12 +155,18 @@ public function setBasicAuthentication($username, $password)
155
155
$ this ->setOpt (CURLOPT_USERPWD , $ username . ': ' . $ password );
156
156
}
157
157
158
- public function setHeader ($ key , $ value = '' )
158
+ public function setHeader ($ key , $ value )
159
159
{
160
160
$ this ->headers [$ key ] = $ key . ': ' . $ value ;
161
161
$ this ->setOpt (CURLOPT_HTTPHEADER , array_values ($ this ->headers ));
162
162
}
163
163
164
+ public function unsetHeader ($ key )
165
+ {
166
+ $ this ->setHeader ($ key , '' );
167
+ unset($ this ->headers [$ key ]);
168
+ }
169
+
164
170
public function setUserAgent ($ user_agent )
165
171
{
166
172
$ this ->setOpt (CURLOPT_USERAGENT , $ user_agent );
0 commit comments