cURL / Mailing Lists / curl-library / Single Mail

curl-library

HTTP 401- Unauthorized error.

From: Pankaj Kumar Maharana <maharana.pankaj_at_gmail.com>
Date: Thu, 30 Apr 2009 15:50:03 +0530

Hi All,

I am trying to implement the support of Basic authentication in my
application. I am using lib-curl. The issue what I found is described as
below. Can some body guide what to do to achieve my objective.

What I observed is libcurl only sends the request once to the server with
username and password. i.e.
I am doing
curl_easy_setopt(handle, CURLOPT_USERPWD, "Wrong : Userpassword"); in the
header callback function, when I receive a HTTP 401 error code.
After setting this incorrect user-name and password with the CURL handle
CURL returns HTTP 401 error again. But CURL does not send the username and
password set with the handle second time to the server. So with this second
time if I give correct login information than also write callback function
is getting called with unauthorized page data. i.e. second setopt with
correct credentials is ignored.

I want that ki till the user wishes to continue without credentials or
provide correct credentials, he should be asked to provide the correct
credential.

Please somebody suggest me as what is going wrong here or what should i do
so that CURL will consider the username and password provided second time
also.

Note: I have attached a sample test application where site URL's are
mentioned along with correct credential information required.

Thanks,
-Pankaj

  • text/x-csrc attachment: test.c
Received on 2009-04-30