Browse Source

Read out KeepAlive only if enabled

Ondrej Pokorny 4 years ago
parent
commit
c67a44c07a
1 changed files with 10 additions and 7 deletions
  1. 10 7
      packages/fcl-web/src/base/fphttpserver.pp

+ 10 - 7
packages/fcl-web/src/base/fphttpserver.pp

@@ -583,12 +583,15 @@ begin
       If Req.ContentLength>0 then
       If Req.ContentLength>0 then
         ReadRequestContent(Req);
         ReadRequestContent(Req);
       Req.InitRequestVars;
       Req.InitRequestVars;
-      // Read out keep-alive
-      FKeepAlive:=Req.HttpVersion='1.1'; // keep-alive is default on HTTP 1.1
-      if SameText(Req.GetHeader(hhConnection),'close') then
-        FKeepAlive:=False
-      else if SameText(Req.GetHeader(hhConnection),'keep-alive') then
-        FKeepAlive:=True;
+      if KeepAliveSupport then
+        begin
+        // Read out keep-alive
+        FKeepAlive:=Req.HttpVersion='1.1'; // keep-alive is default on HTTP 1.1
+        if SameText(Req.GetHeader(hhConnection),'close') then
+          FKeepAlive:=False
+        else if SameText(Req.GetHeader(hhConnection),'keep-alive') then
+          FKeepAlive:=True;
+        end;
       // Create Response
       // Create Response
       Resp:= Server.CreateResponse(Req);
       Resp:= Server.CreateResponse(Req);
       try
       try
@@ -600,7 +603,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 FKeepAlive and (Req.HttpVersion='1.0') and not Resp.HeaderIsSet(hhConnection) then
+          if KeepAliveSupport and 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;