Skip to content

Bug in TIdCustomHTTPServer.DoExecute (at least when used with TIdHTTPWebBrokerBridge) #661

@RenzoTel

Description

@RenzoTel

I found a bug in TIdCustomHTTPServer.DoExecute, which I believe is related to its use with TIdHTTPWebBrokerBridge: when the connection is closed by the remote client before the response has been written, the stream field of the TIdHTTPResponseInfo object can be assigned but is no longer valid (due to a mechanism I haven't explored that causes WebBroker to free the stream when the connection is closed). This causes an access violation in WriteContent and the system becomes very unstable.
I found that checking connected adding this line at current line 1500 of IdCustomHTTPServer.pas, (before the call to writeContent) solve the problem:

         if not LConn.Socket.Connected then
            break;

before of:

          // Write even though WriteContent will, may be a redirect or other
          if not LResponseInfo.HeaderHasBeenWritten then begin
            LResponseInfo.WriteHeader;
          end;

Metadata

Metadata

Assignees

No one assigned

    Labels

    Element: WebBrokerIssues related to TIdHTTPWebBrokerBridgeStatus: Review NeededIssue needs further review to decide next statusType: BugIssue is a bug in existing code

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions