From 5a8a3ddc21239759277c8e1f6651068a2b7f692b Mon Sep 17 00:00:00 2001 From: michael Date: Wed, 21 Mar 2018 10:22:34 +0000 Subject: [PATCH] * Fix content sending git-svn-id: trunk@38585 - --- packages/fcl-web/src/base/fphtml.pp | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/packages/fcl-web/src/base/fphtml.pp b/packages/fcl-web/src/base/fphtml.pp index a7e629da12..c9d84804a2 100644 --- a/packages/fcl-web/src/base/fphtml.pp +++ b/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);