Search code examples
delphidelphi-xe7datasnap

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?


Solution

  • 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;