hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oleg Kalnichevski <ol...@apache.org>
Subject Re: SOCKS support is absent
Date Thu, 18 Nov 2010 15:53:12 GMT
On Thu, 2010-11-18 at 07:12 -0800, David Smiley @MITRE.org wrote:
> In the example ClientExecuteSOCKS.java you showed me:
> 1. Why isn't the SOCKS support built into httpclient instead of requiring
> users to do it themselves?  HttpClient is already invovled with Socket level
> TCP/IP stuff, with all the socket factory stuff going on, which is where the
> SOCKS support needs to be implemented.

Feature-bloat is one of the biggest issues with HttpClient. I am usually
very reluctant to include additional features that are conceptually not
related to HTTP, especially if we do not have enough expertise within
the project to support them.

SOCKS protocol is not supported out of the box simply because we cannot
adequately test it. If you are willing to contribute a patch for this
feature as well as provide a reasonable test coverage for it, I will
happily review and commit it to the repository.  

> 2. There is duplicated code between MySchemeSocketFactory,
> PlainSocketFactory, and ... I was about to say MultihomePlainSocketFactory
> but its deprecated now and I don't see its replacement.  I think PSF should
> be non-final, and then why not bake SOCKS support right into PSF using new
> SOCKS HttpConnectionParams?

I made PlainSocketFactory non-final. So, one simply has to override one
method in order to add SOCKS support. Same applies to the
SSLSocketFactory in the 4.1 branch (trunk)

> 3. The code doesn't work for SSL.

What specifically does not work?

> 4. ProxySelectorRoutePlanner still doesn't support SOCKS but it would be
> nice if it did.  (I have no solution for this)

It is not supposed to, as SOCKS does not require any special provisions
on the HTTP protocol level. 

> Last night I got the HTTPS side working and fortunately it didn't involve
> creating yet another socket factory.  Based on HttpClient 4.0.3 code, I used
> a customized DefaultClientConnectionOperator which conditionally used my
> SocksSocketFactory in its openConnection()... I extended DCCO, overriding
> openConnection(), copy pasted (ugh!) DCCO's implementation and made some
> small changes.  I see now that DCCO's code in trunk is different--it no
> longer knows anything about a Layered socket factory in openConnection(). 
> I'll have to track down what changed and if that affects me.

Please have a look at the HttpClient 4.1-beta1 [1] With 4.1 API one
needs to override just one method (#createSocket(HttpParams)) to add
SOCKS layering.

Hope this helps



> olegk wrote:
> > 
> > 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: httpclient-users-unsubscribe@hc.apache.org
> > For additional commands, e-mail: httpclient-users-help@hc.apache.org
> > 
> > 
> > 

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

View raw message