0
votes

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

1

1 Answers

0
votes

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;