Results 1 to 1 of 1
- 01-21-2011, 03:33 AM #1
Member
- Join Date
- Jan 2011
- Posts
- 1
- Rep Power
- 0
Proxy authentication using HttpClient 4.0.3
Hi all
I am using HttpClient 4.0.3 Api for proxy authentication,i am getting the following errors, can some one plz help me in this.
org.apache.http.client.ClientProtocolException
at org.apache.http.impl.client.AbstractHttpClient.exe cute(AbstractHttpClient.java:643)
at org.apache.http.impl.client.AbstractHttpClient.exe cute(AbstractHttpClient.java:576)
at org.apache.http.impl.client.AbstractHttpClient.exe cute(AbstractHttpClient.java:554)
at methodXYZ.<init>(methodXYZ.java:51)
at methodXYZ.main(methodXYZ.java:68)
Caused by: org.apache.http.auth.MalformedChallengeException: Authentication challenge is empty
at org.apache.http.impl.auth.RFC2617Scheme.parseChall enge(RFC2617Scheme.java:71)
at org.apache.http.impl.auth.AuthSchemeBase.processCh allenge(AuthSchemeBase.java:111)
at org.apache.http.impl.auth.BasicScheme.processChall enge(BasicScheme.java:88)
at org.apache.http.impl.client.DefaultRequestDirector .processChallenges(DefaultRequestDirector.java:113 3)
at org.apache.http.impl.client.DefaultRequestDirector .handleResponse(DefaultRequestDirector.java:1058)
at org.apache.http.impl.client.DefaultRequestDirector .execute(DefaultRequestDirector.java:545)
at org.apache.http.impl.client.AbstractHttpClient.exe cute(AbstractHttpClient.java:641)
... 4 more
below is the code which i am using
public methodXYZ()
{
HttpGet httpGet = null;
HttpEntity entity = null;
HttpResponse response = null;
DefaultHttpClient httpclient = new DefaultHttpClient();
HttpHost proxy = new HttpHost("127.0.0.1", 8080);
httpclient.getParams().setParameter(ConnRoutePName s.DEFAULT_PROXY, proxy);
httpclient.getCredentialsProvider().setCredentials (new AuthScope("127.0.0.1", 8080),new UsernamePasswordCredentials("username", "password"));
httpGet = new HttpGet("http://www.yahoo.com");
try {
response =httpclient.execute(httpGet);
entity = response.getEntity();
writeToFile(entity,"URLHit_Via_Proxy.html");
}
catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}Last edited by Jsharma; 01-21-2011 at 04:04 AM.
Similar Threads
-
httpClient API to Download a xls file.
By mpahlenig in forum New To JavaReplies: 1Last Post: 01-13-2010, 03:31 AM -
Using HttpClient
By jdetloff in forum New To JavaReplies: 4Last Post: 01-06-2010, 10:43 AM -
Using HttpClient with Eclipse
By jdetloff in forum EclipseReplies: 4Last Post: 01-06-2010, 09:47 AM -
Http - proxy or non-proxy ?
By Shiv in forum NetworkingReplies: 0Last Post: 04-11-2009, 08:07 AM -
Proxy Authentication - Cannot login as multiple users
By Dikla in forum Advanced JavaReplies: 1Last Post: 08-05-2008, 10:18 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks