In TFPHTTPConnectionResponse there is a property Content: RawByteString. We can set here what should be output by our web server. Works fine for text content but not so much for binary (even though RawByteString would suggest it's safe for binary data).
Alternatively we can use ContentStream and put our binary data here but I think it would be nice for Content to support binary data.
Why doesn't it? Because:
file HttpDefs.pas:
function TResponse.GetContent: RawByteString;
begin
Result:=Contents.Text;
end;
procedure TResponse.SetContent(const AValue: RawByteString);
...
FContents.Text:=AValue;
Property .Text converts line breaks to #13#10 and corrupts binary data.
My suggestion:
FContents.Delimiter := #13;
FContents.StrictDelimiter := True;
FContents.DelimitedText := AValue;
But I don't know if it won't break something else somewhere.