Skip to content

Commit a028011

Browse files
committed
Fix php-curl-class#506: Remove content-length header for PATCH requests when data is empty
1 parent 624a498 commit a028011

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/Curl/MultiCurl.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,12 +183,17 @@ public function addPatch($url, $data = array())
183183
$data = $url;
184184
$url = $this->baseUrl;
185185
}
186+
186187
$curl = new Curl();
188+
189+
if (is_array($data) && empty($data)) {
190+
$curl->removeHeader('Content-Length');
191+
}
192+
187193
$this->queueHandle($curl);
188194
$curl->setUrl($url);
189-
$curl->removeHeader('Content-Length');
190195
$curl->setOpt(CURLOPT_CUSTOMREQUEST, 'PATCH');
191-
$curl->setOpt(CURLOPT_POSTFIELDS, $data);
196+
$curl->setOpt(CURLOPT_POSTFIELDS, $curl->buildPostData($data));
192197
return $curl;
193198
}
194199

0 commit comments

Comments
 (0)