Comments 6 and 7
- We strongly disagree with Mark on this point. The algorithm a user-FTP should use goes something like this:
a. Examine the first four characters of the reply.
b. If the fourth character is a space, the reply is not a multi-line reply.
c. If the fourth character is a hyphen, the reply is a multi-line reply, and the text portion of this line and succeeding lines should be reported to the user if this is desired.
d. On each succeeding line, if the first four characters are not the three digits of the original reply code followed by a space, the line is entirely a text line and should either be reported to the user or discarded.
e. If the first four characters on the line are the three digits of the reply code followed by space, this line is the last line of the reply.
This algorithm seems simple enough, if nesting of replies is not required (see comments on paragraph 7, below). This sort of continuation-line convention provides a number of benefits to the person coding a server. Consider the problem of providing a directory listing, in response to a STAT command whose argument is the pathname of a directory. If the FTP Telnet control connection is treated as a pseudo-typewriter (as most ordinary Telnet connections are), the writer of an FTP Server may be able to "borrow" the code from the system command which provides directory status (listing) information, as follows (in a pseudo-PL/l syntax):
call write_out_line ("151- Directory listing follows") ;
call list_directory_contents (directory_pathname);
call write_out_line ("151 Directory listing complete");
The same can be done for the file status reply (code 150). Otherwise, a program must be written which performs the function of the directory-listing command, but uses a special output format. If the implementor of an FTP Server wants to be "nice" and list file attributes, as well as file names, in the directory listing (as many directory-listing commands do), this could be a fairly big job. If already-written software can be borrowed and incorporated into the FTP Server, the implementor of the FTP Server can put more of his effort into doing a better job of building the "guts" of the FTP Server.
- It is not obvious why multi-line replies are allowed to be nested to an arbitrary depth. Only truly spontaneous replies may nest inside other replies -- and it is easy to convince yourself that they will only nest to depth one. It was envisioned that some messages from "the system" might not allow the "exterior" multi-line message to finish; the scenario might go something like this:.
151- Directory listing follows:
a1pha.p11
alpha
rfc.runoff
mailbox
010- From Operator:
010 Emergency shutdown in 5 mins. due to hardware probs.
beta.fortran
foo.lisp
151 Directory listing complete.
It has been pointed out to us that:
a. Messages from "the system" in general cannot be guaranteed to come at the beginning of a line.
b. It may be difficult to modify "the system" to preface such messages with an appropriate FTP reply code.
Therefore, we propose that, since user-FTP implementations must handle multi-line replies, system messages "splattered" into the middle of replies need not be escorted by FTP reply codes. The user-FTP thus need not detect and handle "nested" FTP replies.