Newsgroups : Borland : borland.public.delphi.internet.winsock : 2006 Mar : question for TIdReplyPOP3.IsEndMarker procedure
| Subject: | question for TIdReplyPOP3.IsEndMarker procedure |
| Posted by: | "Huang Xiaobin" (hxbtoug..@yahoo.com.cn) |
| Date: | Mon, 13 Mar 2006 13:35:14 |
Hi Guys,
i am studying Indy10.1.5 hard, and i have many question, following is one of
them, ^_^
in the CHM help of indy10.1.5, the comments for the TIdReplyPOP3.IsEndMarker
procedure is:
IsEndMarker is an overridden Boolean class function used to indicate when
the RFC-compliant protocol response contains a terminal response instead of
a continuation response.
IsEndMarker examines the value in ALine to determine if it contains a
continuation mark for the protocol response.
IsEndMarker returns True when ALine contains at least 4 characters and the
fourth character is not the continuation marker character '-' (Decimal 45).
i checked the source code of IsEndMarker and its inner calling procedure
FindCodeTextDelin:
class function TIdReplyPOP3.IsEndMarker(const ALine: string): Boolean;
var
LPos: Integer;
begin
Result := False;
LPos := FindCodeTextDelin(ALine);
if LPos > 0 then begin
if LPos > Length(ALine) then begin
Result := True
end else begin
Result := ALine[LPos] <> '-';
end;
end;
end;
class function TIdReplyPOP3.FindCodeTextDelin(const AText: String): Integer;
var
LMin, LSpace: Integer;
LBuf: String;
LAddBackFlag: Boolean; //if we deleted a begging -, we need to add it back
begin
LAddBackFlag := False;
//we do things this way because a line can start with a minus as in
//-ERR [IN-USE] Mail box in use
LBuf := AText;
if Copy(LBuf, 1, 1) = '-' then begin
Delete(LBuf, 1, 1);
LAddBackFlag := True;
end;
LMin := IndyPos(' ',LBuf);
LSpace := IndyPos('-', LBuf);
if LMin > 0 then begin
if (LSpace <> 0) and (LMin > LSpace) then begin
Result := LSpace;
end else begin
Result := LMin;
end;
end else begin
if LSpace <> 0 then begin
Result := LSpace;
end else begin
Result := Length(AText) + 1;
end;
end;
if LAddBackFlag then begin
Inc(Result);
end;
end;
Now, I testes as following:
set input argument of IsEndMarker: AALine := 'My' (ie, less than 4
characters and no continuation marker),
then FindCodeTextDelin(ALine) will return 3, so IsEndMarker will return
true.
as you can see, this is not identified with the comments. This is my first
question!!!
also i notice the following code in indy:
procedure TIdTCPConnection.GetInternalResponse;
var
LLine: string;
LResponse: TIdStringList;
begin
CheckConnected;
LResponse := TIdStringList.Create; try
// Some servers with bugs send blank lines before reply. Dont remember
which
// ones, but I do remember we changed this for a reason
LLine := IOHandler.ReadLnWait;
LResponse.Add(LLine);
while not FLastCmdResult.IsEndMarker(LLine) do begin
LLine := IOHandler.ReadLn;
LResponse.Add(LLine);
end;
//Note that FormattedReply uses an assign in it's property set method.
FLastCmdResult.FormattedReply := LResponse;
finally Sys.FreeAndNil(LResponse); end;
end;
as if the IsEndMarker procedure is use to judge whether the response from
the connection is ended or not,
but in my opinion, RFC(POP3) always use '.#0D#0A' ie .CTLF to indicate the
terminated of the response, so i
think IsEndMarker can not fit for this work.
thanks anybody for answering my question first!
best regards!