Fix TFPHTTPConnectionThread.Execute repeat loop

This commit is contained in:
Ondrej Pokorny 2021-08-14 07:40:47 +02:00 committed by Michaël Van Canneyt
parent 8fc1bc276f
commit 410916ab6b

View File

@ -85,14 +85,8 @@ Type
Property Server : TFPCustomHTTPServer Read FServer;
Property OnRequestError : TRequestErrorHandler Read FOnError Write FOnError;
Property LookupHostNames : Boolean Read GetLookupHostNames;
<<<<<<< HEAD
Property EnableKeepAlive: Boolean read FEnableKeepAlive write FEnableKeepAlive;
Property KeepAliveEnabled: Boolean read FKeepAliveEnabled write FKeepAliveEnabled;
=======
// Set to true if you want to support HTTP 1.1 connection: keep-alive - only available for threaded server
Property EnableKeepAlive: Boolean read FEnableKeepAlive write FEnableKeepAlive;
>>>>>>> Remove the KeepAlive* properties from TFPCustomHttpServer, rename KeepAliveEnabled to EnableKeepAlive
// time-out for keep-alive: how many ms should the server keep the connection alive after a request has been handled
Property KeepAliveTimeout: Integer read FKeepAliveTimeout write FKeepAliveTimeout;
// is the current connection set up for KeepAlive?
@ -235,13 +229,10 @@ Type
Property OnGetSocketHandler : TGetSocketHandlerEvent Read FOnGetSocketHandler Write FOnGetSocketHandler;
// Called after create socket handler was created, with the created socket handler.
Property AfterSocketHandlerCreate : TSocketHandlerCreatedEvent Read FAfterSocketHandlerCreated Write FAfterSocketHandlerCreated;
<<<<<<< HEAD
// Set to true if you want to support HTTP 1.1 connection: keep-alive - only available for threaded server
Property KeepAliveEnabled: Boolean read FKeepAliveEnabled write FKeepAliveEnabled;
// time-out for keep-alive: how many ms should the server keep the connection alive after a request has been handled
Property KeepAliveTimeout: Integer read FKeepAliveTimeout write FKeepAliveTimeout;
=======
>>>>>>> Remove the KeepAlive* properties from TFPCustomHttpServer, rename KeepAliveEnabled to EnableKeepAlive
end;
TFPHttpServer = Class(TFPCustomHttpServer)
@ -581,7 +572,7 @@ begin
Try
if FSetupSocket then
begin
SetupSocket;
SetupSocket;
FSetupSocket:=False;
end;
// Read headers.
@ -659,8 +650,8 @@ begin
if not Terminated and Connection.EnableKeepAlive and Connection.KeepAlive
and not Connection.Socket.CanRead(Connection.KeepAliveTimeout) then
break;
FConnection.HandleRequest;
until not (Terminated and FConnection.EnableKeepAlive and FConnection.KeepAlive and (FConnection.Socket.LastError=0));
FConnection.HandleRequest;
until not (not Terminated and FConnection.EnableKeepAlive and FConnection.KeepAlive and (FConnection.Socket.LastError=0));
finally
FreeAndNil(FConnection);
if Assigned(FThreadList) then
@ -988,7 +979,7 @@ begin
try
for I:= ThreadList.Count-1 downto 0 do
try
CloseSocket(TFPHTTPConnectionThread(ThreadList[I]).Connection.Socket.Handle);
CloseSocket(TFPHTTPConnectionThread(ThreadList[I]).Connection.Socket.Handle);
except
// ignore exceptions during CloseSocket
end