curl-library
Re: LibCURL PUT Question...
Date: Wed, 26 May 2004 11:37:08 -0700
On Wed, May 26, 2004 at 12:34:08PM -0500, Casey O'Donnell wrote:
> I've been attempting to use LibCURL (also read, "I am a newbie to
> LibCURL.") to implement HTTP GET and PUT functionality in my application.
> I've gotten GET to work effectively, but have had some trouble with PUT. I
> get a valid return code from curl_easy_perform(pCurl);
>
> pFile = fFile.fp(); // Already opened FP
>
> pCurl = curl_easy_init();
>
> if(pCurl && pFile)
> {
> curl_easy_setopt(pCurl, CURLOPT_READFUNCTION, myread_callback);
> curl_easy_setopt(pCurl, CURLOPT_UPLOAD, TRUE);
> curl_easy_setopt(pCurl, CURLOPT_PUT, TRUE);
> curl_easy_setopt(pCurl, CURLOPT_URL, szDest); // something like
> "http://idisk.mac.com/bobbuilder/Sites/test.html"
> curl_easy_setopt(pCurl, CURLOPT_READDATA, pFile);
> curl_easy_setopt(pCurl, CURLOPT_INFILESIZE_LARGE, fFile.Length());
> curl_easy_setopt(pCurl, CURLOPT_USERPWD, szUserPass);
> curl_easy_setopt(pCurl, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
> res = curl_easy_perform(pCurl);
>
> curl_easy_cleanup(pCurl);
> }
>
> I'm testing with a .Mac iDisk account, and it appears to be working, yet no
> files are uploaded. I'm using the same read callback as in the HTTPUT
> example source code. Am I missing something here? I've actually tried
> placing break-points in my call-back, yet they are never tripped, so I
> suspect that it isn't actually making it into that section of the code
> (explaining the failed upload).
>
> Thanks for any insight.
Try using curl_get_info() with CURLINFO_RESPONSE_CODE after the transfer to
retrieve the HTTP error code; there may be a clue from the server there.
You may also have to cast the fFile.Length() as curl_off_t for it to be
passed in correctly.
>>> Dan
-- http://www.MoveAnnouncer.com The web change of address service Let webmasters know that your web site has movedReceived on 2004-05-26