Keep-Alive broken

Giganews Newsgroups
Subject: Keep-Alive broken
Posted by:  Alex Ivlev (aivl…@cox.net)
Date: Thu, 6 Jan 2005

Looks like the Keep-Alive option never works. And here is why:

IdHTTP.pas (rev 1.57), line 828:

function TIdCustomHTTP.SetHostAndPort: TIdHTTPConnectionType;
var
  LHost:string;
  LPort:integer;
begin

  FPort := StrToIntDef(URL.Port,80);
  FHost := URL.Host;
  LPort := FPort;

Notice that the local variable LHost is not assigned any value and remains
an empty string. Later in the same function it is used like this:

    if ((not TextIsSame(LHost, URL.Host)) or
      (LPort <> StrToInt(URL.Port))) then begin
      if Connected then begin
        Disconnect;
      end;

Obviously, this results in a Disconnect call every single time. I'm unsure
of what its value should be. Maybe it should be assigned as 'LHost := FHost'
like its LPort counterpart, but then what would be the purpose of checking
it against URL.Host which is the same? But this needs to be fixed somehow.

Alex

Replies