curl-library
Re: CURLAUTH_ANY Hangs on CURLOPT_PUT
Date: Mon, 14 Jun 2004 09:10:51 -0500
>I have a suspicion what the problem might be, but you need
>to give us much more details. Can you show us the headers
>send and received (edit out sensitive data) from a an
>attempted PUT that fails like this?
>
>I take for granted this is libcurl 7.12.0?
Here is a sample application I came up with. This is actually using libCURL
7.11.1. If 7.12 fixes something along these lines, then I appologize for
the inconvenience. I think I grabbed the latest 'stable' release a month or
two ago when I began this project, though it could be longer.
I don't care if anyone knows my username, as it is obvious given the
URL's...but I have edited out the password component.
Thanks for the help.
Casey
Source Code:
// CurlPut.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
extern "C"
{
size_t read_callback(void* ptr, size_t size, size_t nmemb, void* stream)
{
size_t retcode;
retcode = fread(ptr, size, nmemb, (FILE*)stream);
printf("*** We read %d bytes from file\n", retcode);
return retcode;
}
}
int main(int argc, char* argv[])
{
printf("CurlPut Test Application:\n");
printf("Local File:\t%s\n", argv[1]);
printf("Remote File:\t%s\n", argv[2]);
curl_global_init(CURL_GLOBAL_ALL);
// Do it!
CURL* pCurl;
CURLcode res;
char szUserPass[512] = "";
strcat(szUserPass, argv[3]);
strcat(szUserPass, ":");
strcat(szUserPass, argv[4]);
int iHD;
FILE* pSrcFile;
struct stat file_info;
iHD = open(argv[1], O_RDONLY);
fstat(iHD, &file_info);
close(iHD);
pSrcFile = fopen(argv[1], "rb");
if(pSrcFile)
{
int iFileLength = file_info.st_size;
curl_off_t offFLen = file_info.st_size;
pCurl = curl_easy_init();
if(pCurl)
{
curl_easy_setopt(pCurl, CURLOPT_VERBOSE, TRUE);
curl_easy_setopt(pCurl, CURLOPT_READFUNCTION, read_callback);
curl_easy_setopt(pCurl, CURLOPT_UPLOAD, TRUE);
curl_easy_setopt(pCurl, CURLOPT_PUT, TRUE);
curl_easy_setopt(pCurl, CURLOPT_URL, argv[2]);
curl_easy_setopt(pCurl, CURLOPT_READDATA, pSrcFile);
curl_easy_setopt(pCurl, CURLOPT_INFILESIZE_LARGE, offFLen);
curl_easy_setopt(pCurl, CURLOPT_USERPWD, szUserPass);
// curl_easy_setopt(pCurl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_easy_setopt(pCurl, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
res = curl_easy_perform(pCurl);
curl_easy_cleanup(pCurl);
}
fclose(pSrcFile);
}
curl_global_cleanup();
return 0;
}
Output:
CURLAUTH_BASIC -
CurlPut Test Application:
Local File: C:\Documents and Settings\CODONNELL\Desktop\temp.html
Remote File: http://idisk.mac.com/codonnell/Sites/bob.html
* About to connect() to idisk.mac.com port 80
* Connected to idisk.mac.com (17.250.248.77) port 80
* Server auth using Basic with user 'codonnell'
>PUT /codonnell/Sites/bob.html HTTP/1.1
Authorization: Basic <ENCODED PASS>==
Host: idisk.mac.com
Pragma: no-cache
Accept: */*
Content-Length: 9880
Expect: 100-continue
< HTTP/1.1 100 Continue
*** We read 9880 bytes from file
*** We read 0 bytes from file
< HTTP/1.1 201 Created
< Date: Mon, 14 Jun 2004 13:56:23 GMT
< Server: Apache/1.3.14 (Unix) DAV/1.0.2
< Content-Type: text/html
< X-Cache: MISS from idisk.mac.com
< Connection: close
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<HTML><HEAD>
<TITLE>201 Created</TITLE>
</HEAD><BODY>
<H1>Created</H1>
Resource /codonnell/Sites/bob.html has been created.</BODY></HTML>
* Closing connection #0
Press any key to continue
CURLAUTH_ANY (hangs at "< HTTP/1.1 100 Continue") -
CurlPut Test Application:
Local File: C:\Documents and Settings\CODONNELL\Desktop\temp.html
Remote File: http://idisk.mac.com/codonnell/Sites/bob.html
* About to connect() to idisk.mac.com port 80
* Connected to idisk.mac.com (17.250.248.77) port 80
>PUT /codonnell/Sites/bob.html HTTP/1.1
Host: idisk.mac.com
Pragma: no-cache
Accept: */*
Content-Length: 9880
Expect: 100-continue
< HTTP/1.1 100 Continue
* Connection #0 left intact
* Closing connection #0
Press any key to continue
_________________________________________________________________
Get fast, reliable Internet access with MSN 9 Dial-up – now 3 months FREE!
http://join.msn.click-url.com/go/onm00200361ave/direct/01/
Received on 2004-06-14