Browse Source

* don't execute DoBeforeDataRead unless OnIdle is set

Ondrej Pokorny 4 years ago
parent
commit
ae0cf1b50f
1 changed files with 5 additions and 2 deletions
  1. 5 2
      packages/fcl-web/src/base/fphttpclient.pp

+ 5 - 2
packages/fcl-web/src/base/fphttpclient.pp

@@ -136,7 +136,7 @@ Type
     // Called before data is read.
     Procedure DoBeforeDataRead; virtual;
     // Called when the client is waiting for the server.
-    Procedure DoOnIdle; virtual;
+    Procedure DoOnIdle;
     // Called whenever data is read.
     Procedure DoDataRead; virtual;
     // Called whenever data is written.
@@ -704,7 +704,10 @@ procedure TFPCustomHTTPClient.DoBeforeDataRead;
 var
   BreakUTC: TDateTime;
 begin
-  // use CanRead to keep the client responsive in case the server needs a lot of time to respond
+  // Use CanRead to keep the client responsive in case the server needs a lot of time to respond.
+  // The request can be terminated in OnIdle - therefore it makes sense only if FOnIdle is set
+  If not Assigned(FOnIdle) Then
+    Exit;
   if IOTimeout>0 then
     BreakUTC := IncMilliSecond(NowUTC, IOTimeout);
   while not Terminated and not FSocket.CanRead(10) and (FSocket.LastError=0) do