apache/commons-net — pull request #1 by prakapenka (2014-04-16 12:44:20+00:00)
Title: FTPHTTPClient SocketFactory and connection encoding support

Hi all.

I am writing ftp client to have support for https proxies. This also should be able to use SOCK and HTTP poxy (like we do connect to http proxy through transparent sock5 proxy). Also I want to have control over socket timeout for http proxy handshake. This can be achieved using customized SocketFactory (same approach was for FTPClient) to generate proxied sockets.

For example now we have for HTTPFTPclient only drect socket creation in connect mehtod. Using SocketFactory we can control sockets creation. So if out Socket factory will provide implementation like:
{ ...
private final Proxy connProxy;

@Override
public Socket createSocket( String host, int port ) throws UnknownHostException, IOException {
if ( connProxy != null ) {
Socket s = new Socket( connProxy );
s.connect( new InetSocketAddress( host, port ) );
return s;
}
Socket sc = new Socket( host, port );
sc.setSoTimeout( timeout );
return sc;
}
}
where is proxy is sock5 proxy:
new Proxy( Proxy.Type.SOCKS, sock );

I hope we may have HTTPFTPClient supports in next releases.

Thank you.