cURL / Mailing Lists / curl-library / Single Mail

curl-library

replacing HTTPget with basic auth credentials into libcurl commands

From: Sunil Chandrasekharan <sunil.kainat_at_gmail.com>
Date: Wed, 16 Oct 2013 10:44:49 +0900

Hi,

I am using Java DefaultHttpClient with basic auth in my android code as:

*HttpParams params = new BasicHttpParams();
ConnManagerParams.setTimeout(params, mTimeOut);
HttpConnectionParams.setSoTimeout(params, mTimeOut);
HttpConnectionParams.setConnectionTimeout(params, mTimeOut);
HttpConnectionParams.setTcpNoDelay(params, true);*
**
*DefaultHttpClient client = new DefaultHttpClient(params);
client.getCredentialsProvider().setCredentials(
        new AuthScope(getHost(), getPort()),
        new UsernamePasswordCredentials(getId(),getPassowrd()));*
**
*HttpGet httpget = new HttpGet(url);
HttpResponse response = client.execute(httpget);*

The above code is using basic credentials for HTTPGet request.
I have to replace this code with CURL (libcurl) call.
I wrote a sample code to understand Libcurl calls.

*curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_URL, webpage);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, HTTPData);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &page);
res = curl_easy_perform(curl);*

But this is just basic CURL calls. How to incorporate the above http params
and credentials into my libcurl calls.

I need to know how to write/modify the CURL code above to add the params
and credentials of Authscope and USRPSWD credentials

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2013-10-16