hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Paul <abnomina...@web.de>
Subject Re: Best practise to add SOCKS proxy support?
Date Mon, 24 Aug 2009 23:25:21 GMT
On Mon, 24 Aug 2009 10:35:09 +0200
Oleg Kalnichevski <olegk@apache.org> wrote:

> On Sun, Aug 23, 2009 at 11:57:56PM +0200, Peter Paul wrote:
> > Hello,
> > I'm about add SOCKS proxy support to an application that uses
> > HttpClient and it's HttpProxy capabilities. While Http Proxy
> > support is given by the HttpClient API, I could not find said thing
> > for SOCKS, so I found that it would be nessesary to implement it via
> > ProtocolSocketFactory.
> > However, the application in question can has several open
> > connections that even may go through different proxies. There is a
> > HttpClient object for every connection. So I did a
> > ProxySocketFactory class and specified a custom proxy protocol
> > 
> > Protocol myProxy = new Protocol("http", new
> > ProxySocketFactory(proxy), 80);
> > 
> > How can I get the HttpClient object to use this protocol by default?
> > There is a default protocol in HttpClient's HostConfiguration
> > object, but it only provides a getProtocol method.
> > 
> Use static Protocol#register method

Do you mean I should override the default HTTP protocol with that? But
then all HttpClients will use the same proxy - that's the reason I
can't just set the proxy of the java enviroment.
The idea behind having multiple HttpClients in this application is that
they can use of different proxies (HTTP and SOCKS alike), so there
might be two connections using SOCKS proxy A, a third one to use HTTP
proxy B and another one using SOCKS proxy C at the same time.
I don't see how I can accomplish this using Proxy.registerProtocol()

> > So maybe there is a better way on how to get an application support
> > SOCKS as well? I have not figured out yet how to get
> > authentification either.
> >   
> As far as I know SOCK proxying works on the java.net.Socket level and
> therefore should be absolutely transparent for the HTTP layer.

Well, that's what the SocketFactory is for, but how can I get an
HttpClient to always use this SocketFactory?

> Oleg



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

View raw message