Results 1 to 1 of 1
  1. #1
    Jsharma is offline Member
    Join Date
    Jan 2011
    Posts
    1
    Rep Power
    0

    Unhappy 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 05:04 AM.

Similar Threads

  1. httpClient API to Download a xls file.
    By mpahlenig in forum New To Java
    Replies: 1
    Last Post: 01-13-2010, 04:31 AM
  2. Using HttpClient
    By jdetloff in forum New To Java
    Replies: 4
    Last Post: 01-06-2010, 11:43 AM
  3. Using HttpClient with Eclipse
    By jdetloff in forum Eclipse
    Replies: 4
    Last Post: 01-06-2010, 10:47 AM
  4. Http - proxy or non-proxy ?
    By Shiv in forum Networking
    Replies: 0
    Last Post: 04-11-2009, 09:07 AM
  5. Replies: 1
    Last Post: 08-05-2008, 11:18 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •