Newsgroups : Borland : borland.public.delphi.internet.winsock : 2007 Feb : Re: Indy FTP Response Codes for NLST

www.cryer.info
Managed Newsgroup Archive

Re: Indy FTP Response Codes for NLST

Subject:Re: Indy FTP Response Codes for NLST
Posted by:"Erik Berry" (..@techie.zzzcom)
Date:Thu, 15 Feb 2007 20:03:09

Remy Lebeau (TeamB) wrote:
>> it appears not to send
>> a 150 response to ls/NLST requests in empty directories.
>
> Yes, it does (or you would not be getting the 226 reply).  The console
> output simply does not show it.  That is why you need to use a better
> viewer of the FTP commands/replies.

I've verified with the vendor that the 150 response is not sent by some
older versions of the server, though they claim to have fixed it:
http://bugs.proftpd.org/show_bug.cgi?id=2229

I also debugged into the Indy code, and the server does not send a 150 in
response to an NLST request when in empty dirs the same as it does for
non-empty dirs, and this is what causes causes Indy to hang.  I was only
posting the ls output (which I know hides many things) to show this
difference in quick summary.  Since the summary isn't convincing, here is a
full log I generated yesterday of the send/recv strings from
TIdTCPConnection.SendCmd and TIdTCPConnection.GetInternalResponse:

...
AOut: 'FEAT'
LLine: '211-Features:'
LLine: 'MDTM'
LLine: 'REST STREAM'
LLine: 'SIZE'
LLine: '211 End'
AOut: 'TYPE I'
LLine: '200 Type set to I'
AOut: 'SYST'
LLine: '215 UNIX Type: L8'
AOut: 'PWD'
LLine: '257 "/" is current directory.'
AOut: 'TYPE A'
LLine: '200 Type set to A'
AOut: 'PORT 192,168,1,131,9,0'
LLine: '200 PORT command successful'
AOut: 'NLST'       <note - in a non-empty directory, succeeds>
LLine: '150 Opening ASCII mode data connection for file list'
LLine: '226 Transfer complete.'
AOut: 'TYPE I'
LLine: '200 Type set to I'
AOut: 'CWD XXX'     <into empty dir>
LLine: '250 CWD command successful'
AOut: 'TYPE A'
LLine: '200 Type set to A'
AOut: 'PORT 192,168,1,131,9,1'
LLine: '200 PORT command successful'
AOut: 'NLST'      <note - in empty directory, fails, no 150 response>
LLine: '226 Transfer complete.'

Then this is raised:
EIdReplyRFCError "Transfer complete." with this call stack:
TIdReplyRFC.RaiseReplyError
TIdTCPConnection.RaiseExceptionForLastCmdResult
TIdTCPConnection.CheckResponse(226,...)
TIdTCPConnection.GetResponse
TIdTCPConnection.SendCmd('NLST',...)
TIdFTP.InternalGet('NLST',...,False)
TIdFTP.List(...,'',False)

Finally, the last line of FinalizeDataOperation in TIdFTP.InternalGet hangs
for several minutes until it times out.

If a workaround in Indy isn't practical, I'd suggest commenting on this in
the Indy code to help others with this server.  I'm no longer affected by
this issue, and can't spend more time on it.

Good luck,
Erik

Replies:

none

In response to:

www.cryer.info
Managed Newsgroup Archive