hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Josh Gordineer <joshg...@yahoo.com>
Subject Re: Fw: SOCKS proxy example??
Date Tue, 20 Apr 2010 20:48:40 GMT
Thanks John!  So from this configuration it looks like there is no way to control socks proxy
setting on a per request basis through HttpClient?  We have a scenario where we let users
give proxy configuration information to our system, and we in turn make an HTTP request on
their behalf, therefore we can't make a system-wide property setting since we don't know what
proxies the user will provide.

Previously in the JDK implementation we were doing:

    Proxy.Type type;
    String scheme = # User input;
    if (scheme != null && scheme.equalsIgnoreCase("socks")) {
      type = Proxy.Type.SOCKS;
    } else {
      type = Proxy.Type.HTTP;

    String host = # User input
    int port = # User input

    InetSocketAddress address = new InetSocketAddress(host, port);
    return new Proxy(type, address);

Then pass that proxy into the httpurlconnection for URI:

    URL u = new URL("http://www.somewhere.com/hidden");
    HttpURLConnection ucon = (HttpURLConnection) u.openConnection(p);

Now it appears we don't have that option in HttpClient?

Thanks again for the help!


From: John Smith <deaf.c0t@gmail.com>
To: HttpClient User Discussion <httpclient-users@hc.apache.org>
Sent: Tue, April 20, 2010 11:44:23 AM
Subject: Re: Fw: SOCKS proxy example??

"Transparent connections through SOCKS proxies (version 4 & 5) using
native Java socket support"

Please look at  this - http://hc.apache.org/httpclient-3.x/features.html

You should use something lake that -

System.setProperty("socksProxySet", "false");
System.setProperty("socksProxyHost", "localhost");
System.setProperty("socksProxyPort", "1080");

To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message