|
@@ -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);
|