Jefferson Rudolf
Jefferson Rudolf

Reputation: 161

How to access request headers in DataSnap Server?

I am using Delphi XE7. I need to access the request headers in DataSnap Server, but it does no seem to have this option. In DataSnap REST, it is possible, because TWebModule is available.

This code does not work, like in REST:

function TServerMethods1.EchoString(Value: string): string;
var
   Module: TWebModule;
begin
  Module := GetDataSnapWebModule;
  Result := Module.Request.RemoteIP + ': ' + Value;
end;

Does anyone have an idea about DataSnap Server?

Upvotes: 2

Views: 1699

Answers (1)

Jefferson Rudolf
Jefferson Rudolf

Reputation: 161

I update my project for REST, and resolved my problem in access Header. With the following code:

Need declare Web.HTTPApp at uses

var
  oWebModule: TWebModule;
  sHeader: String;
begin
  oWebModule := GetDataSnapWebModule;
  sHeader := oWebModule.Request.Content;
end;

Upvotes: 1

Related Questions