Browse Source

* Make sure error content is sent

git-svn-id: trunk@42262 -
michael 6 years ago
parent
commit
ce528e1808
1 changed files with 4 additions and 1 deletions
  1. 4 1
      packages/fcl-web/src/restbridge/sqldbrestbridge.pp

+ 4 - 1
packages/fcl-web/src/restbridge/sqldbrestbridge.pp

@@ -817,6 +817,9 @@ begin
   IO.Response.Code:=aCode;
   IO.Response.CodeText:=aExtraMessage;
   IO.RestOutput.CreateErrorContent(aCode,aExtraMessage);
+  IO.RESTOutput.FinalizeOutput;
+  IO.Response.ContentStream.Position:=0;
+  IO.Response.ContentLength:=IO.Response.ContentStream.Size;
   IO.Response.SendResponse;
 end;
 
@@ -1971,7 +1974,7 @@ begin
     // Make sure there is a document in case of error
     if (aResponse.ContentStream.Size=0) and Not ((aResponse.Code div 100)=2) then
       IO.RESTOutput.CreateErrorContent(aResponse.Code,aResponse.CodeText);
-    if Not (IO.Operation in [roOptions,roHEAD]) then
+    if Not ((IO.Operation in [roOptions,roHEAD]) or aResponse.ContentSent) then
       IO.RestOutput.FinalizeOutput;
     aResponse.ContentStream.Position:=0;
     aResponse.ContentLength:=aResponse.ContentStream.Size;