From 20707b600ffbda7eabeb882249d22ff70358c712 Mon Sep 17 00:00:00 2001 From: Zach Borboa Date: Thu, 29 Nov 2018 23:48:18 -0800 Subject: [PATCH] Add note on excluding content-length header from DELETE requests --- src/Curl/Curl.php | 8 ++++++++ 1 file changed, 8 insertions(+) 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)); }