curl / Mailing Lists / curl-library / Single Mail

curl-library

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

From: Ray Satiro via curl-library <curl-library_at_cool.haxx.se>
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
> CURLOPT_POSTFIELDS implies CURLOPT_POST". The CUSTOMREQUEST
> 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.

[1]: https://curl.haxx.se/libcurl/c/CURLOPT_CUSTOMREQUEST.html

-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2018-01-03