Jelajahi Sumber

* Fix content sending

git-svn-id: trunk@38585 -
michael 7 tahun lalu
induk
melakukan
5a8a3ddc21
1 mengubah file dengan 16 tambahan dan 12 penghapusan
  1. 16 12
      packages/fcl-web/src/base/fphtml.pp

+ 16 - 12
packages/fcl-web/src/base/fphtml.pp

@@ -1158,6 +1158,7 @@ Var
   FWriter : THTMLWriter;
   B : Boolean;
   M : TMemoryStream;
+
   
 begin
   FDocument := CreateDocument;
@@ -1168,20 +1169,23 @@ begin
       If Assigned(OnGetContent) then
         OnGetContent(Self,ARequest,FWriter,B);
       If Not B then
-        begin
         Actions.HandleRequest(ARequest,FWriter,B);
-        If Not B then
-          Raise EHTMLError.Create(SErrRequestNotHandled);
-        end
-      else
+      If Not B then
+        Raise EHTMLError.Create(SErrRequestNotHandled);
+      If (AResponse.ContentStream=Nil) then
         begin
-        If (AResponse.ContentStream=Nil) then
-          begin
-          M:=TMemoryStream.Create;
-          AResponse.ContentStream:=M;
-          AResponse.FreeContentStream:=True;
-          FDocument.SaveToStream(AResponse.ContentStream);
-          end;
+        M:=TMemoryStream.Create;
+        AResponse.ContentStream:=M;
+        AResponse.FreeContentStream:=True;
+        end;
+      if not AResponse.ContentSent then
+        begin
+        FDocument.SaveToStream(AResponse.ContentStream);
+        AResponse.ContentStream.Position:=0;
+        if (AResponse.ContentType='') then
+           AResponse.ContentType:='text/html';
+        AResponse.ContentLength:=AResponse.ContentStream.Size;
+        AResponse.SendContent;
         end;
     Finally
       FreeAndNil(FWriter);