You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Jake Sebastian-Jones <tr...@gmail.com> on 2013/11/07 02:17:44 UTC

[FTP] Exposing the LIST data connection's InputStream

Hello all,

This is my first interaction with this list.

While using FTPClient on an Android application I was developing, I found
myself wishing I could attach a CountingInputStream to LIST requests. This
was because I was requesting very large file lists on a slow connection.

I thought I could contribute to the net.ftp project by adding a method to
the api that somehow exposed the stream, so that users can do what they
want with it.

I downloaded the source and read enough to understand how list and list
parsing works.

BUT I thought, before I waste my time, I should ask the devs if this idea
is ever going to be accepted to the project.

So, am I wasting my time?

Thanks,
Jake

Re: [FTP] Exposing the LIST data connection's InputStream

Posted by Jake Sebastian-Jones <ja...@linux.com>.
Thanks for the reply,

My FTPClient knowledge is obviously a bit lacking as it hadn't really
clicked that FTPClient inherits from SocketClient.

Jake


On Sat, Nov 9, 2013 at 12:05 AM, Daniel Savarese <df...@savarese.org> wrote:

>
> In message <
> CANTdsqb3ne5BPshJ1u07td0xtOJ3SDhw_B3spwE8EF2w9HWWbA@mail.gmail.com>
> >While using FTPClient on an Android application I was developing, I found
> >myself wishing I could attach a CountingInputStream to LIST requests. This
> >was because I was requesting very large file lists on a slow connection.
>
> This is just a suggestion.  The simplest way to achieve your goal with
> no code modifications is to:
>
> 1. Subclass java.net.Socket and override getInputStream() so that it
>    wraps the result of super.getInputStream() with CountingInputStream.
> 2. Implement a javax.net.SocketFactory that returns such sockets and use
>    it with FTPClient via SocketClient.setSocketFactory.
>
> That will only work for passive mode (see _openDataConnection_()).  If not
> using passive mode, then you need to a little more work, but can still
> accomplish your goal via wrappers and a custom ServerSocketFactory.
>
> >I thought I could contribute to the net.ftp project by adding a method to
> >the api that somehow exposed the stream, so that users can do what they
> >want with it.
>
> I would suggest that any such feature be implemented via the generic
> route I described (i.e., add the support classes to make it easy to
> do) instead of a feature-specific manner.  Given the current hooks,
> it should not require any modifications to FTPClient.  That is just
> my opinion and nothing more.  A class that delegates all operations to
> Socket that can be easily subclassed to override Socket functions could
> be useful (along with a similar one for ServerSocket), making it easy
> to implement arbitrary customizations in conjunction with socket factories.
>
> daniel
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>