Browse Source

* Avoid unnecessary calls to ProduceContent. (ie: avoid generating the website twice)

git-svn-id: trunk@8103 -
joost 18 years ago
parent
commit
4ecda7164f
1 changed files with 8 additions and 5 deletions
  1. 8 5
      packages/fcl-web/src/fphttp.pp

+ 8 - 5
packages/fcl-web/src/fphttp.pp

@@ -42,7 +42,7 @@ Type
   Public
     Procedure GetContent(ARequest : TRequest; Content : TStream; Var Handled : Boolean);
     Function  HaveContent : Boolean; virtual;
-    Procedure ContentToStream(Stream : TStream); virtual;
+    function ContentToStream(Stream : TStream) : boolean; virtual;
   end;
   
   { TCustomWebAction }
@@ -243,9 +243,7 @@ end;
 
 procedure THTTPContentProducer.DoGetContent(ARequest: TRequest; Content: TStream; Var Handled : Boolean);
 begin
-  Handled:=HaveContent;
-  If Handled then
-    ContentToStream(Content);
+  Handled:=ContentToStream(Content);
 end;
 
 function THTTPContentProducer.ProduceContent: String;
@@ -258,7 +256,7 @@ begin
   Result:=(ProduceContent<>'');
 end;
 
-procedure THTTPContentProducer.ContentToStream(Stream: TStream);
+function THTTPContentProducer.ContentToStream(Stream: TStream) : boolean;
 
 Var
   S : String;
@@ -266,7 +264,12 @@ Var
 begin
   S:=ProduceContent;
   If length(S)>0 then
+    begin
     Stream.WriteBuffer(S[1],Length(S));
+    Result := True;
+    end
+  else
+    Result := False;
 end;
 
 { TCustomWebAction }