diff --git a/src/Curl/Curl.php b/src/Curl/Curl.php index 38a2162..6fee6d6 100644 --- a/src/Curl/Curl.php +++ b/src/Curl/Curl.php @@ -265,6 +265,14 @@ class Curl $this->setUrl($url, $query_parameters); $this->setOpt(CURLOPT_CUSTOMREQUEST, 'DELETE'); + + // Avoid including a content-length header in DELETE requests unless there is a message body. The following + // would include "Content-Length: 0" in the request header: + // curl_setopt($ch, CURLOPT_POSTFIELDS, array()); + // RFC 2616 4.3 Message Body: + // The presence of a message-body in a request is signaled by the + // inclusion of a Content-Length or Transfer-Encoding header field in + // the request's message-headers. if (!empty($data)) { $this->setOpt(CURLOPT_POSTFIELDS, $this->buildPostData($data)); }