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: Daniel Stenberg <daniel_at_haxx.se>
Date: Mon, 2 Nov 2009 09:53:10 +0100 (CET)

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
Received on 2009-11-02

These mail archives are generated by hypermail.

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

File upload with ASP.NET