cURL / Mailing Lists / curl-library / Single Mail

curl-library

PRET + Customrequest (STAT) issue

From: ElBandito <el.bandito123_at_googlemail.com>
Date: Mon, 17 Jan 2011 13:01:34 +0100

Hello,

I've recently come to play around with libcurl a bit.
I use it on different ftp server types, namely glftpd and drftpd
(which requires PRET due to it's slave system).

Working with verbose debugging all the time I noticed libcurl uses
LIST to get dirlists.
For my at home usage I use a different ftp client and noticed it uses
STAT -LA instead of LIST.
STAT -LA gets the dirlist through the control connection and doesn't
open the additional data connection only to get a dirlist as LIST
does.

The way libcurl does it now with LIST looks the following (example
taken from drftpd)
> PRET LIST
< 200 OK, will use master for upcoming transfer
> PASV
* Connect data stream passively
< 227 Entering Passive Mode (xx,xx,xx,xx,xx,xx).
* Trying xx.xx.xx.xx... * connected
* Connecting to xx.xx.xx.xx (xx.xx.xx.xx) port 27291
> TYPE A
< 200 Command okay
> LIST
< 150 File status okay; about to open data connection.
* Doing the SSL/TLS handshake on the data stream
* successfully set certificate verify locations:
* Maxdownload = -1
* Remembering we are in dir ""
< 226 Closing data connection

Although that certainly is fine, it creates some not needed overhead
by opening a data connection everytime I need a dirlist.
So I looked through the libcurl docs and noticed
CURLOPT_CUSTOMREQUEST, when set to STAT -LA on the same drftpd it
fails though:
> PRET STAT -LA
< 504 Command not implemented for that parameter.
* PRET command not accepted: 504

The ftp server expects STAT -LA to come in without preceding PRET. I
can't disable PRET though because file transfers won't work without
it:
> PASV
* Connect data stream passively
< 500 You need to use a client supporting PRET (PRE Transfer) to use PASV
* Bad PASV/EPSV response: 500

Just changing the customrequest to STAT -LA does not seem to be a good
solution for this cmd since it doesnt work very well on glftpd either:
> PASV
* Connect data stream passively
< 227 Entering Passive Mode (xx,xx,xx,xx,xx,xx)
* Trying xx.xx.xx.xx... * connected
* Connecting to xx.xx.xx.xx (xx.xx.xx.xx) port 42351
> STAT -LA
< 213- status of -LA:
< total 1064

As you can see libcurl always tries to PASV since well as the docs
say, the customrequest flag does not change the way it behaves, it
only replaces the actual cmd that is send to the server.
For HTTP there are a bunch of alternative methodes mentioned to tackle
the problem of invalid responses, but for FTP I can't see equivalents.

My question now is, is there a way to use STAT instead of LIST already
which I've failed to notice ?
And if not, is there an easy way to patch this in?

Best regards,

Hendrik
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2011-01-17