Re: IdFtp questions

Giganews Newsgroups
Subject: Re: IdFtp questions
Posted by:  Remy Lebeau \(Indy Team\) (
Date: Thu, 4 Jun 2009

"Pascal" <pcoenen@telenetdotbe> wrote in message

> //Note that for LIST, it might be best to put the connection in ASCII
> Why is this only done for List and not for 'ExtListDir(ADest)'?

Because it is not supposed to.  ExtListDir() uses the MLSD command.
According to RFC 3659 Section 7.2 "Format of MLSx Response":

  The data connection opened for a MLSD response shall be a connection
  as if the "TYPE L 8", "MODE S", and "STRU F" commands had been given,
  whatever FTP transfer type, mode and structure had actually been set,
  and without causing those settings to be altered for future commands.
  That is, this transfer type shall be set for the duration of the data
  connection established for this command only.  While the content of
  the data sent can be viewed as a series of lines, implementations
  should note that there is no maximum line length defined.
  Implementations should be prepared to deal with arbitrarily long

> Q2: TIdFTP.SendTransferType
> Why Case TransferType instead of Case FTransferType.

It does not really matter, since the TransferType property does not use a
getter method, it just it reads FTransferType directly.  The compiler will
omit the same machine code either way.

> If you dyn create this IdFtp component at runtime and you don't
> explicitly set the TransferType property then the SendTransferType
> at connect and login won't do anything because TransferType is empty.

FTransferType is initialized in InitComponent(), which is called during

  Id_TIdFTP_TransferType = {ftBinary} ftASCII; // RLebeau 1/22/08: per RFC

procedure TIdFTP.InitComponent;
  inherited InitComponent;
  FTransferType := Id_TIdFTP_TransferType;

Per FTP specs, the default transfer type for an FTP session is ASCII.  Make
sure you are using an up-to-date copy of Indy's 10 source code, if you are
not already.

> Q3: procedure TIdFTP.SetTransferType
> Isn't it better to remove the 'if AValue <> FTransferType' part.
> This way we could resend the Type command (even if it's the same).

There is no reason to do that.  Once the Transfer Type has been set for a
session, it remains active for the rest of the session, unless explicitally
changed again with a new TYPE command.

> The reason: Some FTP servers do ASCII for the LIST command
> (using the ExtListDir(ADest) procedure) but stay in ASCII even
> if I requested Binary at connection (and login).

Then those servers are buggy.  ExtListDir() uses the MLSD command, not the
LIST command.  Refer to the above RFC quote for how MLSD works.

Remy Lebeau (TeamB)


In response to

IdFtp questions posted by Pascal on Thu, 4 Jun 2009