Skip to content

FTPHTTPClient SocketFactory and connection encoding support#1

Closed
prakapenka wants to merge 1 commit intoapache:trunkfrom
prakapenka:FTPHTTPsf
Closed

FTPHTTPClient SocketFactory and connection encoding support#1
prakapenka wants to merge 1 commit intoapache:trunkfrom
prakapenka:FTPHTTPsf

Conversation

@prakapenka
Copy link
Copy Markdown

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.

@prakapenka
Copy link
Copy Markdown
Author

@prakapenka
Copy link
Copy Markdown
Author

UPD *Since FTPHTTPClient extends FTPClient we just can change new Scoket(...) to factory methods.

@sebbASF
Copy link
Copy Markdown
Contributor

sebbASF commented Mar 24, 2017

Fixed, thanks

@asfgit asfgit closed this in 5cf1121 Mar 24, 2017
sebbASF pushed a commit that referenced this pull request Jun 19, 2020
GiacomoTortora added a commit to GiacomoTortora/commons-net that referenced this pull request Oct 21, 2024
refactor of 2 main methods in examples/ftp/ServerToServerFTP.java and examples/Main.java
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants