|
@@ -65,7 +65,7 @@ Type
|
|
FSocket: TSocketStream;
|
|
FSocket: TSocketStream;
|
|
FSetupSocket : Boolean;
|
|
FSetupSocket : Boolean;
|
|
FBuffer : Ansistring;
|
|
FBuffer : Ansistring;
|
|
- FEnableKeepAlive : Boolean;
|
|
|
|
|
|
+ FKeepAliveEnabled : Boolean;
|
|
FKeepAlive : Boolean;
|
|
FKeepAlive : Boolean;
|
|
FKeepAliveTimeout : Integer;
|
|
FKeepAliveTimeout : Integer;
|
|
procedure InterPretHeader(ARequest: TFPHTTPConnectionRequest; const AHeader: String);
|
|
procedure InterPretHeader(ARequest: TFPHTTPConnectionRequest; const AHeader: String);
|
|
@@ -85,8 +85,8 @@ Type
|
|
Property Server : TFPCustomHTTPServer Read FServer;
|
|
Property Server : TFPCustomHTTPServer Read FServer;
|
|
Property OnRequestError : TRequestErrorHandler Read FOnError Write FOnError;
|
|
Property OnRequestError : TRequestErrorHandler Read FOnError Write FOnError;
|
|
Property LookupHostNames : Boolean Read GetLookupHostNames;
|
|
Property LookupHostNames : Boolean Read GetLookupHostNames;
|
|
- // 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;
|
|
Property EnableKeepAlive: Boolean read FEnableKeepAlive write FEnableKeepAlive;
|
|
|
|
+ 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
|
|
// 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;
|
|
Property KeepAliveTimeout: Integer read FKeepAliveTimeout write FKeepAliveTimeout;
|
|
// is the current connection set up for KeepAlive?
|
|
// is the current connection set up for KeepAlive?
|
|
@@ -136,7 +136,7 @@ Type
|
|
FConnectionThreadList: TThreadList;
|
|
FConnectionThreadList: TThreadList;
|
|
FConnectionCount : Integer;
|
|
FConnectionCount : Integer;
|
|
FUseSSL: Boolean;
|
|
FUseSSL: Boolean;
|
|
- FKeepAliveSupport: Boolean;
|
|
|
|
|
|
+ FKeepAliveEnabled: Boolean;
|
|
FKeepAliveTimeout: Integer;
|
|
FKeepAliveTimeout: Integer;
|
|
procedure DoCreateClientHandler(Sender: TObject; out AHandler: TSocketHandler);
|
|
procedure DoCreateClientHandler(Sender: TObject; out AHandler: TSocketHandler);
|
|
function GetActive: Boolean;
|
|
function GetActive: Boolean;
|
|
@@ -232,7 +232,7 @@ Type
|
|
// Called after create socket handler was created, with the created socket handler.
|
|
// Called after create socket handler was created, with the created socket handler.
|
|
Property AfterSocketHandlerCreate : TSocketHandlerCreatedEvent Read FAfterSocketHandlerCreated Write FAfterSocketHandlerCreated;
|
|
Property AfterSocketHandlerCreate : TSocketHandlerCreatedEvent Read FAfterSocketHandlerCreated Write FAfterSocketHandlerCreated;
|
|
// Set to true if you want to support HTTP 1.1 connection: keep-alive - only available for threaded server
|
|
// Set to true if you want to support HTTP 1.1 connection: keep-alive - only available for threaded server
|
|
- Property KeepAliveSupport: Boolean read FKeepAliveSupport write FKeepAliveSupport;
|
|
|
|
|
|
+ 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
|
|
// 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;
|
|
Property KeepAliveTimeout: Integer read FKeepAliveTimeout write FKeepAliveTimeout;
|
|
end;
|
|
end;
|
|
@@ -586,7 +586,7 @@ begin
|
|
If Req.ContentLength>0 then
|
|
If Req.ContentLength>0 then
|
|
ReadRequestContent(Req);
|
|
ReadRequestContent(Req);
|
|
Req.InitRequestVars;
|
|
Req.InitRequestVars;
|
|
- if EnableKeepAlive then
|
|
|
|
|
|
+ if KeepAliveEnabled then
|
|
begin
|
|
begin
|
|
// Read out keep-alive
|
|
// Read out keep-alive
|
|
FKeepAlive:=Req.HttpVersion='1.1'; // keep-alive is default on HTTP 1.1
|
|
FKeepAlive:=Req.HttpVersion='1.1'; // keep-alive is default on HTTP 1.1
|
|
@@ -606,7 +606,7 @@ begin
|
|
if Assigned(Resp) and (not Resp.ContentSent) then
|
|
if Assigned(Resp) and (not Resp.ContentSent) then
|
|
begin
|
|
begin
|
|
// Add connection header for HTTP 1.0 keep-alive
|
|
// Add connection header for HTTP 1.0 keep-alive
|
|
- if KeepAliveSupport and FKeepAlive and (Req.HttpVersion='1.0') and not Resp.HeaderIsSet(hhConnection) then
|
|
|
|
|
|
+ if FKeepAlive and (Req.HttpVersion='1.0') and not Resp.HeaderIsSet(hhConnection) then
|
|
Resp.SetHeader(hhConnection,'keep-alive');
|
|
Resp.SetHeader(hhConnection,'keep-alive');
|
|
Resp.SendContent;
|
|
Resp.SendContent;
|
|
end;
|
|
end;
|
|
@@ -842,7 +842,7 @@ begin
|
|
Con.OnRequestError:=@HandleRequestError;
|
|
Con.OnRequestError:=@HandleRequestError;
|
|
if Threaded then
|
|
if Threaded then
|
|
begin
|
|
begin
|
|
- Con.KeepAliveSupport:=KeepAliveSupport;
|
|
|
|
|
|
+ Con.KeepAliveEnabled:=KeepAliveEnabled;
|
|
Con.KeepAliveTimeout:=KeepAliveTimeout;
|
|
Con.KeepAliveTimeout:=KeepAliveTimeout;
|
|
CreateConnectionThread(Con);
|
|
CreateConnectionThread(Con);
|
|
end
|
|
end
|