1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2014
    Rep Power

    Question [Ask]How to use proxy in HttpClient? The proxy needs username and password!

    I'd like to use httpclient to access the Internet, but it's necessary to use proxy....
    But the proxy needs username and password! So how can I?...

    HttpClient httpClient=new DefaultHttpClient();
    AuthScope authScope=new AuthScope("proxy.urlnet.cn", 8080);
    CredentialsProvider credentialsProvider=new BasicCredentialsProvider();
    UsernamePasswordCredentials usernamePasswordCredentials=new UsernamePasswordCredentials("username", "password");
    credentialsProvider.setCredentials(authScope, usernamePasswordCredentials);
    HttpResponse response=httpClient.execute(request);

    This way is invalid.....
    Please help me!
    Last edited by ckcz123; February 11th, 2014 at 05:07 AM. Reason: Edit format of the code

IMN logo majestic logo threadwatch logo seochat tools logo