cURL
Haxx ad
libcurl

Shopping cart software, Online file storage, Online photo storage, Hosted shopping cart, Contact management software, Email marketing software, Project management software, Issue tracking software, Online notepad, Web publishing software

curl's project page on SourceForge.net

Sponsors:
Haxx

cURL > Mailing List > Monthly Index > Single Mail

curl-library Archives

RE: Put request with postfields libcurl c++

From: Zaid Amir <z.alamir_at_genie-soft.com>
Date: Tue, 10 Nov 2009 12:08:24 +0200

-----Original Message-----
From: curl-library-bounces_at_cool.haxx.se
[mailto:curl-library-bounces_at_cool.haxx.se] On Behalf Of Daniel Stenberg
Sent: Monday, November 02, 2009 10:53 AM
To: libcurl development
Subject: Re: Put request with postfields libcurl c++

On Mon, 2 Nov 2009, Zaid Amir wrote:

> size_t readTextCallback(void* ptr,size_t size, size_t nmemb, void* stream)
> {
> #ifdef _DEBUG
> cout << "read_data being called" << endl;
> #endif

> string* strptrdst = static_cast<string*>(ptr);
> strptrdst = static_cast<string*>(stream);
> return nmemb*size;
> }

Don't get sucked up by all the fancy C++isms you can make in a program. Try
to
focus on what the docs actually say the callback is supposed to do.

The read callback is supposed to copy data to the buffer, data that libcurl
is
supposed to send away.

'ptr' points to the buffer. size*nmemb is the (maximum) amount of data you
should copy there.

Just copy data to the buffer in every invoke until there is no more data to
copy.

A slightly different way to do PUT with a fixed string, is to instead: use
CURLOPT_POSTFIELDS and CURLOPT_CUSTOMREQUEST to change the request to a
"PUT"
and then you modify the Content-Type: to whatever you want it to be.

-- 
  / daniel.haxx.se
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Neither one of the methods you provided worked, The problem is that when
using CUSTOMREQUEST and POSTFIELDS the connection hangs. 
I am still not sure how I'm supposed to issue a PUT request with a message
body in curl... its been days now and I'm still at point zero.
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Received on 2009-11-10

These mail archives are generated by hypermail.

donate! Page updated November 16, 2009.
web site info

File upload with ASP.NET