Daniel, Still it did not solve the issue.. I tried by setting CURLOPT_HTTPAUTH to CURLAUTH_BASIC. But I found a new use case. The new use case is that if I set CURLAUTH_BASIC with the initial request itself than I did not get any response at all. So I tried setting CURLAUTH_ANY with the initial request. But when I get 401 error than set CURLAUTH_BASIC with the username and password from header callback. Here I observed that the issue of not sending second time is still there with this approach also.
The issue is, with the same handle when i am setting a new username and password than CURL does not send that information to the server. Instead it gives back the response body through write_callback function. I understand that it is not the correct behaviour. If I am setting username and password with the same handle than CURL need to send the info to server and need to call header_callback with the response header. Does the return value of header_callback function keep some impact on this(For not sending the request again)? What I don’t understand is , is this the curl behaviour or there is some options to set which i am missing. Thanks, Pankaj
