Skip to content

Commit 20707b6

Browse files
committed
Add note on excluding content-length header from DELETE requests
1 parent 9edf511 commit 20707b6

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/Curl/Curl.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,14 @@ public function delete($url, $query_parameters = array(), $data = array())
265265

266266
$this->setUrl($url, $query_parameters);
267267
$this->setOpt(CURLOPT_CUSTOMREQUEST, 'DELETE');
268+
269+
// Avoid including a content-length header in DELETE requests unless there is a message body. The following
270+
// would include "Content-Length: 0" in the request header:
271+
// curl_setopt($ch, CURLOPT_POSTFIELDS, array());
272+
// RFC 2616 4.3 Message Body:
273+
// The presence of a message-body in a request is signaled by the
274+
// inclusion of a Content-Length or Transfer-Encoding header field in
275+
// the request's message-headers.
268276
if (!empty($data)) {
269277
$this->setOpt(CURLOPT_POSTFIELDS, $this->buildPostData($data));
270278
}

0 commit comments

Comments
 (0)