Hi Sebastien, Alan,
Alan Moss wrote:
You need to create your own custom ProtocolSocketFactory[1] and
implement the createSocket methods in the manner you mentioned. Once you
do that, you need to tell HttpClient to use it. Something like this:
if (shouldUseSocks) {
Protocol.registerProtocol("http",
new Protocol("http", new MyProtocolScoketFactory(), 80));
}
That's the idea, although I would move the if(...) part into the
socket factory. Things get ugly if you want to juggle between
different socket factories for the same protocol/scheme.
Alternatively, if you're on Java 5 or later, you might want to
install your own ProxySelector in the "legacy" java.net API :-)
http://java.sun.com/j2se/1.5.0/docs/api/java/net/ProxySelector.html#setDefault(java.net.ProxySelector)
http://java.sun.com/j2se/1.5.0/docs/guide/net/proxies.html
cheers,
Roland
[1]
http://hc.apache.org/httpclient-3.x/apidocs/org/apache/commons/httpclient/protocol/ProtocolSocketFactory.html
Good luck.
-Alan
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]