Scheme Selection: XRSQ
XRSQ is the means by which a user program can test for implementation of XRSQ/XRCP, select a particular scheme, reset its state thereof, and even do some rudimentary negotiation. Its format is like that of the TYPE command, as follows:
XRSQ [<SP> <scheme>] <CRLF>
<scheme> = a single character. The following are defined:
R Recipients first. If not implemented, T must be.
T Text first. If this is not implemented, R must be.
? Request for preference. Must always be implemented.
No argument means a "selection" of none of the schemes (the
default).
Replies:
200 OK, we'll use specified scheme.
215 <scheme> This is the scheme I prefer.
501 I understand XRSQ but can't use that scheme.
5xx Command unrecognized or unimplemented.
See Appendix A for more about the choice of reply codes.
Three aspects of XRSQ need to be pointed out here. The first is that an XRSQ with no argument must always return a 200 reply and restore the default state of having no scheme selected. Any other reply implies that XRSQ and hence XRCP are not understood or cannot be performed correctly.
The second is that the use of "?" as a <scheme> asks the FTP server to return a 215 reply in which the server specifies a "preferred" scheme. The format of this reply is simple:
215 <SP> <scheme> [<SP> <arbitrary text>] <CRLF>
Any other reply (e.g. 4xx or 5xx) implies that XRSQ and XRCP are
not implemented, because "?" must always be implemented if XRSQ
is.
The third important thing about XRSQ is that it always has the side effect of resetting all schemes to their initial state. This reset must be done no matter what the reply will be - 200, 215, or 501. The actions necessary for a reset will be explained when discussing how each scheme actually works.