ok, I tried this:
========================
HttpParams params = new BasicHttpParams();
params.setParameter(ConnRoutePNames.DEFAULT_PROXY, new
HttpHost("myproxyserver", 8080));
ClientConnectionManager cm = new BasicClientConnectionManager();
HttpClient httpclient = new DefaultHttpClient(cm, params);
HttpGet httpGet = new HttpGet("http://www.google.com");
HttpResponse response1 = httpclient.execute(httpGet);
System.out.println(response1.getStatusLine());
========================
But the output is always: HTTP/1.1 407 Proxy Authentication Required (
Forefront TMG requires authorization to fulfill the request. Access to the Web
Proxy filter is denied. )
I didn't need credentials in my earlier Java program...why not there and why
now here? And any ideas how to fix this?
----- Original Message -----
From: "Jean-Marc Spaggiari" <[email protected]>
To: "HttpClient User Discussion" <[email protected]>
Sent: Thursday, January 24, 2013 11:19:29 AM GMT -06:00 Central America
Subject: Re: connect through proxy
This piece of code is working for me:
HttpParams params = new BasicHttpParams();
params.setParameter(ConnRoutePNames.DEFAULT_PROXY, new
HttpHost(proxyhostname, 80));
client = new DefaultHttpClient(cm, params);
You might want to look at something similar.
JM
2013/1/24, Kevin Weslowski <[email protected]>:
> Hi,
>
> I have some URLConnection code that connects through a proxy:
> ============================
> java.net.URL url = new java.net.URL("http://www.google.com");
> java.net.SocketAddress sa = new java.net.InetSocketAddress("myproxyserver",
> 8080);
> java.net.Proxy proxy = new java.net.Proxy(java.net.Proxy.Type.HTTP, sa);
> java.net.HttpURLConnection con = (java.net.HttpURLConnection)
> url.openConnection(proxy);
> ============================
> and I want to convert that to equivalent httpclient code but I can't seem to
> find the right way to do that. Can someone point me in the right direction?
> Thanks...
>
> Kevin
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]