KeepAlive with SSL / Problem in TIdCustomHTTP.ConnectToHost ?

Giganews Newsgroups
Subject: KeepAlive with SSL / Problem in TIdCustomHTTP.ConnectToHost ?
Posted by:  Thomas Bergerot (nospam@nospam.fr)
Date: Tue, 02 Oct 2007

As i said in my previous post, i have problem using KeepAlive with
TIdHttpServer and TIdHttp.

I asked Eldos' support (SSLBlackBox), and they did further tests.

It seems that there is a problem in TIdCustomHTTP.ConnectToHost, which
contains following code :

  case ARequest.UseProxy of
    ctNormal:
      if (ProtocolVersion = pv1_0) and (Length(ARequest.Connection) = 0)
then
        ARequest.Connection := 'keep-alive';      {do not localize}
    ctSSL, ctSSLProxy: ARequest.Connection := '';
    ctProxy:
      if (ProtocolVersion = pv1_0) and (Length(ARequest.Connection) = 0)
then
      begin
        ARequest.ProxyConnection := 'keep-alive'; {do not localize}
      end;
  end;

As we can see, the ARequest.Connection value is set to empty string if
SSL is used.  From the other side, TIdHTTPServer server uses the
following code to detect if he should close the connection:

    LResponseInfo.CloseConnection := not (FKeepAlive and
      TextIsSame(LRequestInfo.Connection, 'Keep-alive')); {Do not Localize}

I.e. TIdHTTPServer closes the connection if 'Connection' header is not
equal to 'keep-alive'. But the value of this header has been already set
to the empty string by the TIdHTTP object.

They tried to comment the "ARequest.Connection := '';" line in the code
of TIdCustomHTTP.ConnectToHost() method and everything began to work
fine for them.

As they recommended to me, it might be better to ask the Indy team if
this is not a problem in Indy, that might be corrected ?

Best regards,

Thomas

Replies