hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Baierl <m...@mbaierl.com>
Subject Simple code through proxy not working
Date Wed, 11 Feb 2009 14:09:51 GMT
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?

HttpClient httpclient = null;
MultiThreadedHttpConnectionManager connectionManager = null;

if(connectionManager == null)
	connectionManager = new MultiThreadedHttpConnectionManager();


if(httpclient == null)
	httpclient = new HttpClient(connectionManager);

	// register an SSL protocol factory
		new Protocol("https",
			new EasySSLProtocolSocketFactory(), 443));			

// set my proxy
httpclient.getHostConfiguration().setProxy("", 80);

HttpMethod method = null;
method = new GetMethod(url);
method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new 
DefaultHttpMethodRetryHandler(1, true));
	int status = httpclient.executeMethod(method);
	String content = method.getResponseBodyAsString();
	// do something
catch(Exception ex)


To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org

View raw message