curl-users
Re: Posting data
Date: Fri, 2 Apr 2004 11:08:44 +0200 (CEST)
On Thu, 1 Apr 2004, BV wrote:
> I'm new to cURL and trying to understand the ways to POST data...
I recommend the curl-library mailing list for libcurl questions/talk. This
reply is CC'ed that way.
> I want to be able to POST data both as a single blob and also via the read
> callback. I don't want to PUT files, or to post multipart form data:
>
> Is the following correct to accomplish the two cases ?
Why don't you try it out first and then ask if it doesn't work?
> // Post data via read callback...
> curl_easy_setopt(m_pCurl,CURLOPT_READDATA,this);
> curl_easy_setopt(m_pCurl,CURLOPT_READFUNCTION,staticCurlReadCallback);
> curl_easy_setopt(m_pCurl,CURLOPT_UPLOAD,1);
> curl_easy_setopt(m_pCurl,CURLOPT_POST,1);
> curl_easy_setopt(m_pCurl,CURLOPT_POSTFIELDS,0);
>
> // Post data as a singne form encoded blob:
> curl_easy_setopt(m_pCurl,CURLOPT_POST,1);
> curl_easy_setopt(m_pCurl,CURLOPT_POSTFIELDS,pbData);
> curl_easy_setopt(m_pCurl,CURLOPT_POSTFIELDSIZE,iDataLen);
Yeps, they look fine to me!
-- Daniel Stenberg -- http://curl.haxx.se -- http://daniel.haxx.se Dedicated custom curl help for hire: http://haxx.se/curl.htmlReceived on 2004-04-02