cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Help required on data option usage with DELETE - curl -X DELETE -d data='{"name":"test"}'

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Sun, 22 Sep 2013 19:59:05 +0200 (CEST)

On Sat, 21 Sep 2013, Prasanna Viswakumar wrote:

Hi Prasanna,

Please note that we don't use top-posting on this mailing list. We comment
inlined instead and remove the parts of the old mail from the quote that isn't
relevant.

> I have been looking at the CURL code available at git.
>
> I see that the code sets the CUSTOMREQUEST option and the postdatafields as
> well for this purpose of sending DELETE with the data-body.

Exactly.

> With the call to multi_easy_perform(), do we just copy the header first to a
> data-buffer, place the data-body following the header and send it as a
> DELETE request based on the CUSTOMREQUEST option ?

If you want to see exactly how the code looks that does the logic, see the
lib/http.c:Curl_http() function. But yes, it creates the request in a buffer
and then sends that off over TCP.

In libcurl terms, CURLOPT_POSTFIELDS will cause a POST request with that body
to get sent, but then CUSTOMREQUEST is used to replace the actual method
keyword in the request.

> With packet-captures, I do see that the request goes out as DELETE, but just
> wanted to confirm if this is the case.

Yes it does, and you can use curl's --trace-ascii or --trace instead of a
capture to see exactly what curl sends "over the wire".

-- 
  / daniel.haxx.se
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Received on 2013-09-22