curl-library
RE: Using Digest Authentication
Date: Tue, 14 Aug 2007 08:44:51 +1200
> Have you tried the curl command line tool with digest on this particular
URL?
Yes but the version of Curl is displayed as 7.9.5 which appears is before
'--digest' was added as I get an option unknown error. I've explicitly
checked the version of libcurl and its 7.16.3. I'm not sure why I've got
different versions but I will download the latest version of curl and test
again from the command line.
> Can you show us how your code looks like? I don't understand why this
doesn't just work for you.
The curl part of the code is essentially:
curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_URL, "http://xxxxxxxxxxxxxxxxx");
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
curl_easy_setopt(curl, CURLOPT_USERPWD, userPwd);
curl_easy_setopt(curl, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST);
if (sessionCookie != NULL){
curl_easy_setopt(curl, CURLOPT_COOKIE, sessionCookie);
}
curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, WriteHeaderCallback);
curl_easy_setopt(curl, CURLOPT_WRITEHEADER, (void *)&headerChunk);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION,
WriteResponseCallback);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&responseChunk);
headers = curl_slist_append( headers, "Accept: text/xml" );
headers = curl_slist_append( headers, requestMethod );
headers = curl_slist_append( headers, "Content-Type: text/xml" );
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, requestContent);
res = curl_easy_perform(curl);
curl_easy_cleanup(curl);
}
Thanks again for your help.
Received on 2007-08-13