Procházet zdrojové kódy

* check for LastError coming from CanRead()

Ondrej Pokorny před 4 roky
rodič
revize
1083746abf
1 změnil soubory, kde provedl 4 přidání a 1 odebrání
  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;