* don't execute DoBeforeDataRead unless OnIdle is set

This commit is contained in:
Ondrej Pokorny 2021-08-29 19:16:18 +02:00 committed by Ondrej Pokorny
parent 35c45dfbe5
commit ae0cf1b50f

View File

@ -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