In the delphi rest server project wizard evidently there is a bug that causes it to always return json.
I found a post on board that said to add this code to override it as in code below. As shown i have set it to text/htm; charset=utf8 and that does cause it to return document with html wrapper. After setting this i take the string and convert it to a stream using stringtostream also shown below. The problem is even though the string and the resultant stream contain line seperators with 0D0A, the data that comes back in the browser is lacking the carriage return (has 0A only). Makes for hard reading in some editors.
Any ideas of why it would remove the cr?
================================================
procedure TWebModule1.WebModuleAfterDispatch(Sender: TObject;
Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
begin
if ContentTypeHeaderToUse<>'' then begin
Response.ContentType := 'text/html; charset=utf-8';//ContentTypeHeaderToUse;
ContentTypeHeaderToUse := ''; // Reset global variable
end;
end;
=====================
function TServerMethods1.StringToStream(s: String) : tStream;
var
st : tStringStream;
begin
st:=tStringStream.Create(s);
result:=st;
end;