I have a scenario when I send a POST request but the the body should be empty and this case the servers return an error when I send an empty array with

curl_setopt($ch, CURLOPT_POSTFIELDS, $request->data);
CommentFileSizeAuthor
#2 empty_body-2827729-1.patch750 bytesboyan.borisov

Comments

boyan.borisov created an issue. See original summary.

boyan.borisov’s picture

Status: Active » Needs review
StatusFileSize
new750 bytes

The patch that I've created fix the problem by checking $content_length > 0 explicitly.

john franklin’s picture

Status: Needs review » Needs work

Without the CURLOPT_POSTFIELDS or something else to set the "Content-Length:" header, any POST and PUT requests with empty bodies would be malformed. POST and PUT *require* a "Content-Length" header, even if it's zero.

I think something may be up with your servers.