Pārlūkot izejas kodu

* Some responses do not allow a message body, so attempting to read them is not needed, even if content-length is not specified

git-svn-id: trunk@34062 -
michael 9 gadi atpakaļ
vecāks
revīzija
c8354993c1
1 mainītis faili ar 7 papildinājumiem un 1 dzēšanām
  1. 7 1
      packages/fcl-web/src/base/fphttpclient.pp

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

@@ -101,6 +101,7 @@ Type
     Procedure SetRequestHeaders(const AValue: TStrings);
     procedure SetIOTimeout(AValue: Integer);
   protected
+    Function NoContentAllowed(ACode : Integer) : Boolean;
     // True if we need to use a proxy: ProxyData Assigned and Hostname Set
     Function ProxyActive : Boolean;
     // Override this if you want to create a custom instance of proxy.
@@ -457,6 +458,11 @@ begin
     FSocket.IOTimeout:=AValue;
 end;
 
+function TFPCustomHTTPClient.NoContentAllowed(ACode: Integer): Boolean;
+begin
+  Result:=((ACode div 100)=1) or ((ACode=204) or (ACode=304))
+end;
+
 function TFPCustomHTTPClient.ProxyActive: Boolean;
 begin
   Result:=Assigned(FProxy) and (FProxy.Host<>'') and (FProxy.Port>0);
@@ -1034,7 +1040,7 @@ begin
         L:=L-R;
       until (L=0) or (R=0);
       end
-    else if L<0 then
+    else if (L<0) and (Not NoContentAllowed(ResponseStatusCode)) then
       begin
       // No content-length, so we read till no more data available.
       Repeat