On Tue, 2010-04-20 at 13:48 -0700, Josh Gordineer wrote:
> 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?
>
You can full control over network socket initialization by using a
custom SocketFactory
http://hc.apache.org/httpcomponents-client-4.0.1/tutorial/html/connmgmt.html#d4e484
http://hc.apache.org/httpcomponents-client-4.0.1/httpclient/apidocs/org/apache/http/conn/scheme/SocketFactory.html
Oleg
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]