1
votes

I have built a standalone (Delphi EXE) DataSnap server using TDSServer, TDSServerClass etc. I want to be able to send custom HTTP headers in the response from my server methods. I can see I can use GetInvocationMetadata() to customise the response status code, message, content and the Content-Type header, but can't see any way of adding my own response headers. Is this possible?

1
Unfortunately not, that looks like the WebBroker framework which is not what I'm using - I don't have a TWebModule or TWebResponse.Jonathan Wareham
If you use the Server Wizard to build a Datasnap server (REST), you'd have more opportunity to investigate the possibilities.nolaspeaker

1 Answers

0
votes

Example:

function TControllerAplicacao.EchoString(Value: string): string;
var
 objWebModule: TWebModule; //need Web.HTTPApp
begin
  //the Solution
  objWebModule := GetDataSnapWebModule; //need Datasnap.DSHTTPWebBroker
  objWebModule.Response.SetCustomHeader('MY-CUSTOM-HEADER','ABCD12324');
  //do the test using postman, and see on HEADERS

 Result := Value; //from original datasnap example EchoString

end;