Re: Response against the unknown command

Giganews Newsgroups
Subject: Re: Response against the unknown command
Posted by:  Remy Lebeau \(Indy Team\) (no.spam@no.spam.com)
Date: Sat, 17 Mar 2007

"Fumio Kawamata" <fum…@my.email.ne.jp> wrote in message
news:20070317230659.2FEC.FUM…@my.email.ne.jp...

> I am testing my POP3 proxy program.

Which component are you using to create your proxy - TIdPOP3Server or
TIdMappedPOP3?

> However, my program replies two lines response against
> the unknown command.

Since TIdMappedPortPOP3 will never send that kind of reply, I am
assuming that you are using TIdPOP3Server instead.  It does not
process unknown commands.  The only commands it supports are as
follows:

    USER
    PASS
    LIST
    RETR
    DELE
    UIDL
    STAT
    TOP
    NOOP
    APOP
    RSET
    QUIT
    STLS
    CAPA

If you need to handle other commands, then you will have to derive a
new class from TIdPOP3Server and override its virtual
InitializeCommandHandlers() method to add your own custom handlers, or
override the virtual DoReplyUnknownCommand() method to process unknown
commands manually.

>  6 C: TEST
>  7 S: -ERR-Sorry, Unknown Command
>  8 C: CAPA
>  9 S: -ERR TEST

The reply on line 9 is a continuation of the reply that started on
line 7 for the TEST command.  It is not the reply for the CAPA command
from line 8.  Because you are sending commands using a terminal
program, you are able to send new commands before receiving the full
reply from a previous command.  Had you been using a real POP3 client,
then a reply would be received in full before the next command can
then be sent.

> 10 C: CAPA
> 11 S: +OK Capability list follows
> 12 S: USER
> 13 S: .

That reply is for the CAPA command from line 8, not the one from line
10.  The CAPA command from line 10 has not been processed by the
server yet.

> 14 C: QUIT
> 15 S: +OK Capability list follows

That reply is for the CAPA command from line 10.  It is not for the
QUIT command from line 14.

> (The connections was disconnected)

It was not being disconnected by the server.  The reply to the CAPA
command from line 10 has not finished being sent yet, so the QUIT
command from line 14 has not been processed by the server yet.

> I think that the display of the 9th line is strange.

It is not that strange when you realize what is actually happening.
The replies are being sent in the order of the commands that it
received.  You are simply not handling the commands/replies in the
correct order on your end.  You are not taking into account when a
command sends back a multi-line reply.

However, in this particular situation, the reply being sent back for
an unknown command is wrong.  The reply is not being formatted
according to RFC 1939 for the POP3 protocol.  What you are seeing is a
carry-over of how TIdCmdTCPServer generically formats replies for
unknown commands.  TIdPOP3Server was apparently not overriding that
behavior to match the RFC correctly.  That has been fixed now.

> I am expecting the following sequence.  Am I wrong?

Had TIdPOP3Server been sending the correct reply to unknown commands
to begin with, then yes, what you are expecting would be a more
correct sequence.

Gambit

Replies

In response to

Response against the unknown command posted by Fumio Kawamata on Sat, 17 Mar 2007