我已经使用TDSServer
,TDSServerClass
等构建了独立的(Delphi EXE)DataSnap服务器。我希望能够在服务器方法的响应中发送自定义HTTP标头。我可以看到可以使用GetInvocationMetadata()
自定义响应状态代码,消息,内容和Content-Type
标头,但是看不到添加我自己的响应标头的任何方式。这可能吗?
示例:
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;