cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: How to "PUT" http body to HTTP PUT in libcurl

From: cnm marketing <cnn.marketing_at_gmail.com>
Date: Tue, 26 Jan 2016 16:00:05 -0500

By changing CURLOPT_POST to a CURLOPT_PUT in post-callback.c sample code, I
got the following - NOTICE the "405 Method Not Allowed", what does it mean?
Does it mean that this "PUT" does not allow or ?

< HTTP/1.1 100 Continue
< HTTP/1.1 405 Method Not Allowed
< Cache-Control: max-age=604800
< Date: Tue, 26 Jan 2016 20:55:05 GMT
< Expires: Tue, 02 Feb 2016 20:55:05 GMT
< Server: EOS (lax004/2816)
< Content-Length: 0
< Via: 1.1 inprthop11p.corp.emc.com:80 (Cisco-WSA/8.5.3-051)
< Connection: keep-alive

Date: Mon, 25 Jan 2016 21:53:19 +0100
From: Dan Fandrich <dan_at_coneharvesters.com>
To: curl-library_at_cool.haxx.se
Subject: Re: How to "PUT" http body to HTTP PUT in libcurl
Message-ID: <20160125205319.GA32044_at_coneharvesters.com>
Content-Type: text/plain; charset=iso-8859-1

On Mon, Jan 25, 2016 at 12:41:27PM -0500, cnm marketing wrote:
> Hi,
>
> I have the following http put, how do I use curl_easy_setopt( ) to set it.
> Notice that the body portion is just a Json text string.
>
> //url
> HTTP PUT https://xxxxxx/object?name=xyz
> // body
> {
> "bodayField":"abcd"
> }
>
> CURLOPT_READDATA and CURLOPT_INFILESIZE_LARGE is for reading a file.

Who says it's for reading a file? It can be used for data from any source.
Take
a look at the post-callback.c example program, for example. Changing the
CURLOPT_POST to a CURLOPT_PUT ought to get you what you want.

>>> Dan

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2016-01-26