You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by Tej Kiran Sharma <te...@gmail.com> on 2010/05/25 08:59:46 UTC
unable to connect through proxy
Hi,
i am trying to connect my appplication through proxy but not able to connect
it. my sample application as following....
DefaultHttpClient httpclient = new DefaultHttpClient();
HttpHost proxy = new HttpHost("192.168.0.98", 3128, "http");
httpclient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
httpclient.getCredentialsProvider().setCredentials(
AuthScope.ANY,
new NTCredentials("admin","admin",null,"domain"));
HttpGet httpget = new HttpGet("http://www.google.com");
System.out.println("executing request" + httpget.getRequestLine());
HttpResponse response = httpclient.execute(httpget);
HttpEntity entity = response.getEntity();
System.out.println("----------------------------------------");
System.out.println(response.getStatusLine());
System.out.println(response.getStatusLine().getStatusCode());
if (entity != null) {
System.out.println("Response content length: " + entity.getContentLength());
}
if (entity != null) {
entity.consumeContent();
}
// When HttpClient instance is no longer needed,
// shut down the connection manager to ensure
// immediate deallocation of all system resources
httpclient.getConnectionManager().shutdown();
can anyone help me
--
Thanks
Tej Kiran Sharma
tejkiransharma@gmail.com