Re: Bug in TIdHeaderList ?

Giganews Newsgroups
Subject: Re: Bug in TIdHeaderList ?
Posted by:  Remy Lebeau \(TeamB\) (no.spam@no.spam.com)
Date: Thu, 7 Aug 2008

"Ted" <torerikoge…@googlemail.com> wrote in message
news:7F78D259375EE340torerikoge…@googlemail.com...

> Hi! Using Delphi 2007 / Indy 10.2.3 I get strange headers from
> a TidHttp.Get request:

The problem is not with TIdHeaderList itself.  Your code is simply using it
wrong.  You should not be calling ValueFromIndex at all.  It requires the
items to be stored in "Name=Value" format, but that is not how headers are
actually stored.  Since you are trying to output the header list in
"Name=Value" format manually, use the ConvertToStdValues() method to convert
the TIdHeaderList to an intermediate TStringList instead, ie:

    procedure TMyThread.IdHttpHeaders(Sender: TObject; AHeaders:
TIdHeaderList; var VContinue: Boolean);
    var
        tmp: TStringList;
        I: Integer;
        ...
    begin
        tmp := TStringList.Create;
        AHeaders.ConvertToStdValues(tmp);
        ...
        for I := 0 to tmp.Count - 1 do
            Txt := tmp[I];

        ...
        tmp.Free;
    end;

Gambit

Replies

None

In response to

Bug in TIdHeaderList ? posted by Ted on Tue, 5 Aug 2008