Browse Source

* check for LastError coming from CanRead()

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

+ 4 - 1
packages/fcl-web/src/base/fphttpclient.pp

@@ -704,12 +704,15 @@ 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
   if IOTimeout>0 then
   if IOTimeout>0 then
     BreakUTC := IncMilliSecond(NowUTC, IOTimeout);
     BreakUTC := IncMilliSecond(NowUTC, IOTimeout);
-  while not Terminated and not FSocket.CanRead(10) do
+  while not Terminated and not FSocket.CanRead(10) and (FSocket.LastError=0) do
     begin
     begin
     DoOnIdle;
     DoOnIdle;
     if (IOTimeout>0) and (CompareDateTime(NowUTC, BreakUTC)>0) then // we exceeded the timeout -> read error
     if (IOTimeout>0) and (CompareDateTime(NowUTC, BreakUTC)>0) then // we exceeded the timeout -> read error
       Raise EHTTPClientSocketRead.Create(SErrReadingSocket);
       Raise EHTTPClientSocketRead.Create(SErrReadingSocket);
     end;
     end;
+
+  if FSocket.LastError<>0 then
+    Raise EHTTPClientSocketRead.Create(SErrReadingSocket);
 end;
 end;
 
 
 function TFPCustomHTTPClient.AllowHeader(var AHeader: String): Boolean;
 function TFPCustomHTTPClient.AllowHeader(var AHeader: String): Boolean;