On Wed, 2010-11-17 at 07:03 -0800, David Smiley @MITRE.org wrote: > I've been working with the HtmlUnit open source project to fix and enhance > its use of HttpClient (v4). Given the extensive features of HttpClient, I > am very surprised to see that SOCKS support is absent. I have to make > HtmlUnit do a bunch of things to get SOCKS proxies to work, particularly > https (SSL) layered over SOCKS. I've searched this mailing list on this > subject to find that Oleg directs users to make a SocketFactory and *not* > mess with Routes. I've also observed that ProxySelectorRoutePlanner > expressly ignores PROXY steps; and I'm not sure how code using this class > can detect if NO_PROXY is returned because of ignoring SOCKS or because of > no proxy being needed. Can a comitter comment? > > So I implement a SocketFactory. Unfortunately I can't extend > PlainSocketFactory because its final, and this results in a bunch of > copy-pasted code with only a small change to pass a java.net.Proxy object to > Socket's constructor. It's good to see that the v4.1 development release > passes HttpParams to createSocket(); I hope to eventually use that once v4.1 > is released. SocketFactories are registered with HttpClient in association > with a scheme (e.g. http, https) and so I need to create two socket > factories, one plain, one SSL "layered", and register them. I've gotten > this working for non-SSL and I'm going to work on the SSL case soon, for > HtmlUnit. > > The bottom line is that not only does HttpClient not support SOCKS, it's > made it a pain to support it. Can a committer comment if the lack of SOCKS > support is a deliberate long-term choice or has nobody scratched that itch > yet? Ideally, I'd be working the the HttpClient committers to add SOCKS > support and not HtmlUnit; is that an option here? > > ~ David Smiley
SOCKS is an IP level protocol. As long as SOCKS proxying is configured correctly on the TCP/IP level, no additional support is required on the HTTP level. Ads far as I can tell HttpClient 4.1 makes it fairly easy to implement socket layering over SOCKS. I am really not sure what kind of additional support one may need in this regard. http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientExecuteSOCKS.java I could certainly make PlainSocketFactory non-final if that makes your life easier. Oleg --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
