cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Https connect (user+password)

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Thu, 8 May 2003 09:24:46 +0200 (CEST)

On Thu, 8 May 2003, Naved Khan wrote:

> m_CurlReturnCode = curl_easy_setopt(m_pCurlHandle, CURLOPT_URL, pszServer);
>
> int nLen = strlen(pszUserID) + strlen(pszPassword) + 2;
> char* pszUserPwd = new char[nLen];
> sprintf(pszUserPwd, "%s:%s", pszUserID, pszPassword);
>
> m_CurlReturnCode = curl_easy_setopt(m_pCurlHandle, CURLOPT_USERPWD,
> pszUserPwd);
> m_CurlReturnCode = curl_easy_perform(m_pCurlHandle);
>
> In case the user+password fails, the Return code will indicate the error.

No, it won't. Only if you also use FAILONERROR, as otherwise you'll probably
only get a HTML page back saying you don't have access to the page (most web
servers are setup that way).

> Is this the only way?

You could set NOBODY as then libcurl will issue a HEAD request which is
guaranteed to never return any HTML contents.

> Can we test the connection to the server in any other way using libcurl
> than trying to get a page?

This system does not "test the connection to the server". It does a lot more,
it tests if you can get a web page off the server.

But no, you can't know if you can get a page without trying to get the page!

-- 
 Daniel Stenberg -- curl, cURL, Curl, CURL. Groks URLs.
-------------------------------------------------------
Enterprise Linux Forum Conference & Expo, June 4-6, 2003, Santa Clara
The only event dedicated to issues related to Linux enterprise solutions
www.enterpriselinuxforum.com
Received on 2003-05-08