curl / Mailing Lists / curl-library / Single Mail


Re: Sending out an HTTP DELETE with a body through libcurl

From: Ray Satiro via curl-library <>
Date: Tue, 2 Jan 2018 18:59:53 -0500

On 1/2/2018 6:35 PM, Martin Galvan via curl-library wrote:
> I noticed there's currently no way to send an HTTP DELETE request
> using curl_easy_setup other than using CURLOPT_CUSTOMREQUEST. I saw
> that many people say that the request's body should be specified
> through CURLOPT_POSTFIELDS, but the documentation clearly says: "Using
> documentation in turn isn't clear of what the effect of doing this is,
> other than "to switch to a proper POST use CURLOPT_POST or
> CURLOPT_POSTFIELDS" which sounds to me like using POSTFIELDS will
> result in a POST being sent.
> What's the proper way to send out DELETE requests?

curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "DELETE");

From the doc [1]

"When you change the request method by setting CURLOPT_CUSTOMREQUEST to
something, you don't actually change how libcurl behaves or acts in
regards to the particular request method, it will only change the actual
string sent in the request."

So you can send a post with the request method changed to DELETE. I
don't think DELETE bodies are spec though.


Received on 2018-01-03