HTTP Get, connection closed gracefully problem with Indy10

Giganews Newsgroups
Subject: HTTP Get, connection closed gracefully problem with Indy10
Posted by:  Chris Ueberall (CUebera…@web.de)
Date: Tue, 22 Jul 2008

the following method works fine with Indy9/D7 but fails with Indy10/D2007 when calling it more than once:

// idHTTPClient is of type TidHTTP

procedure TfrmMain.btnGetClick(Sender: TObject);
var
  ms    : TMemoryStream;
begin
  ms    := nil;
  try
    ms    := TMemoryStream.Create;

    idHTTPClient.Request.Host      := '192.168.178.30';
    idHTTPClient.Request.URL        := '/cgi/jpg/image.cgi?resolution=1280x1024';

    idHTTPClient.Get('http://192.168.178.30/cgi/jpg/image.cgi?resolution=1280x1024', ms);
  finally
    ms.Free;
  end;
end;

An EIdConnClosedGracefully will be raised when I call it the second time.
Disconnecting doesn't disconnect, IOHandler.Disconnect has no effect.
Connect fails because already connected.
Creating the TidHTTP class for every call works.
Why?

Here the call stack:

1517 TIdIOHandler.RaiseConnClosedGracefully
402 TIdIOHandlerStack.CheckForDisconnect
1859 TIdIOHandler.WriteDirect
827 TIdIOHandler.WriteBufferFlush
1841 TIdIOHandler.WriteBufferFlush
816 TIdIOHandler.WriteBufferClose
1748 TIdHTTPProtocol.BuildAndSendRequest
1281 TIdCustomHTTP.ConnectToHost
2068 TIdCustomHTTP.DoRequest
2036 TIdCustomHTTP.Get
694 TIdCustomHTTP.Get
133 TfrmMain.btnGetClick

--

Replies