Hi there,
I have some pretty simple code that is not working through a proxy.
What I have:
-) an open proxy which does not require authentication
-) the proxy listens on port 80
-) I verified using curl that everything works as expected
What I want to do:
-) request http://somewhere/ through the proxy
-) request https://somewhere/ through the proxy
I did some packet sniffing and to me it seems that HttpClient 3 is not
going to do a CONNECT first.
What I would expect:
-) On the request to http://somewhere/
1) connect to the proxy on the given port (80)
2) use CONNECT somewhere:80
3) do a GET request
4) done
-) On the request to https://somewhere/ (SSL!)
1) connect to the proxy on the given port (80)
2) use CONNECT somewhere:443
3) build up the SSL connection
4) do a GET request
5) done
Packet sniffing has shown me that this is not the case, HttpClient just
fails and does not connect using the CONNECT function...
Any ideas?
<code>
****************************************************
HttpClient httpclient = null;
MultiThreadedHttpConnectionManager connectionManager = null;
if(connectionManager == null)
connectionManager = new MultiThreadedHttpConnectionManager();
connectionManager.getParams().setDefaultMaxConnectionsPerHost(4);
connectionManager.getParams().setMaxTotalConnections(20);
connectionManager.getParams().setConnectionTimeout(5000);
if(httpclient == null)
{
httpclient = new HttpClient(connectionManager);
httpclient.getParams()
.setParameter(HttpClientParams.USER_AGENT,
"MyUserAgent/0.0.0");
httpclient.getParams()
.setParameter(HttpClientParams.HTTP_CONTENT_CHARSET,
"UTF-8");
// register an SSL protocol factory
Protocol.registerProtocol("https",
new Protocol("https",
new EasySSLProtocolSocketFactory(), 443));
}
// set my proxy
httpclient.getHostConfiguration().setProxy("10.10.1.10", 80);
HttpMethod method = null;
method = new GetMethod(url);
method.setFollowRedirects(false);
method.setDoAuthentication(false);
method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new
DefaultHttpMethodRetryHandler(1, true));
try
{
int status = httpclient.executeMethod(method);
String content = method.getResponseBodyAsString();
// do something
}
catch(Exception ex)
{
method.abort();
}
finally
{
method.releaseConnection();
}
****************************************************
</code>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]