0

I have a datasnap REST server that receives trafic from webhook or client. Incoming request contains header fields, with tokens, I need to access to auth the user request.

I use the following method to do some processing.

procedure TWebModule1.WebModuleBeforeDispatch(Sender: TObject; Request: TWebRequest; Response: TWebResponse; var Handled: Boolean); begin

How can I access the incoming header tokens

Tokens passed for example: enter image description here

Jan Doggen
  • 8,799
  • 13
  • 70
  • 144
Happy
  • 1
  • 2

1 Answers1

0

I modified the below: Delphi 10.4 Enumerate TWebRequest HTTP header fields

uses
IdHTTPWebBrokerBridge,IdCustomHTTPServer;

type
  TIdHTTPAppRequestHelper =  class helper for TIdHTTPAppRequest
  public
    function GetRequestInfo : TIdHTTPRequestInfo;
  end;

implementation

function TIdHTTPAppRequestHelper.GetRequestInfo: TIdHTTPRequestInfo;
begin
  Result := FRequestInfo;
end;

procedure TWebModule1.WebModuleBeforeDispatch(Sender: TObject;
  Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
var
  lString : String;
begin
  //code is the header, lstring is the value  
  lString := TIdHTTPAppRequest(Request).GetRequestInfo.RawHeaders.Values['code'];
end;
Jan Doggen
  • 8,799
  • 13
  • 70
  • 144
Happy
  • 1
  • 2