Re: Response Multi-line without "."

Giganews Newsgroups
Subject: Re: Response Multi-line without "."
Posted by:  Remy Lebeau (TeamB) (no.spam@no.spam.com)
Date: Tue, 18 Oct 2005

"Pedro" <pizquierdo20…@hotmail.com> wrote in message
news:870A5E336DDEE240pizquierdo20…@hotmail.com...

> When the client asks for the listing (LIST) of the mailbox, if
> there are no messages the server not send the '.' of end
> response multiline.

The TIdCommand.Response property is sent using
TIdTCPConnection.WriteRFCStrings(), which always sends the terminating '.'
line.  However, if the TIdCommand.Response property is empty then
WriteRFCStrings will not be called at all:

    procedure TIdCommandHandler.DoCommand(
        //...
    begin
        LCommand := TIdCommand.Create(Self);
        with LCommand do try
            //...
            if Response.Count > 0 then begin // <-- here
                AContext.Connection.WriteRFCStrings(Response);
            //...
        end;
    end;

Which means that you will have to send the '.' yourself manually when the
Response property is empty:

    procedure TSAPOP.OnList(ASender: TIdCommand; AMessageNum: Integer);
    var
        Instancia : TSAInstanciaPOP;
        Men : TMen;
        j : integer;
        Totbytes : Int64;
    begin
        Instancia := TSAInstanciaPOP(ASender.Context.Data);
        Instancia.List(lbTodos);
        if AMessageNum < 1 then begin
            if Instancia.ListaMens.Count > 0 then begin
                TotBytes := 0;
                for j := 0 to Instancia.ListaMens.Count-1 do begin
                    Men := TMen(Instancia.ListaMens.Objects[j]);
                    ASender.Response.Add(Format('%d %d', [j+1, Men.Bytes]));
                    TotBytes := TotBytes+Men.Bytes;
                end;
                ASender.Reply.SetReply(OK, Format('%d %d',
[Instancia.ListaMens.Count, TotBytes]));
            end else begin
                ASender.Reply.SetReply(OK, '0 0');
                ASender.SendReply;
                ASender.Context.Connection.IOHandler.WriteLn('.');
            end;
        end else begin
            if AMessageNum <= Instancia.ListaMens.Count then
                ASender.Reply.SetReply(OK, Format('%d %d', [AMessageNum,
TMen(Instancia.ListaMens.Objects[AmessageNum-1]).Bytes]))
            else
                ASender.Reply.SetReply(ERR, rMsgNotExists);
        end;
    end;

Gambit

Replies

In response to

Response Multi-line without "." posted by Pedro on Tue, 18 Oct 2005