cURL / Mailing Lists / curl-library / Single Mail

curl-library

RE: replacing HTTPget with basic auth credentials into libcurl commands

From: Zeman, Vaclav <Vaclav.Zeman_at_ca.com>
Date: Wed, 16 Oct 2013 13:37:30 +0000

Take a look at CURLOPT_USERPWD and CURLOPT_HTTPAUTH options.
--
VZ

From: curl-library [mailto:curl-library-bounces_at_cool.haxx.se] On Behalf Of Sunil Chandrasekharan
Sent: Wednesday, October 16, 2013 3:45 AM
To: curl-library_at_cool.haxx.se
Subject: replacing HTTPget with basic auth credentials into libcurl commands

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