Question
· Jan 28, 2023

How to get HTTP header Authorization in EnsLib.HTTP.InboundAdapter service

I am using ens.BusinessService with associated adapter EnsLib.HTTP.InboundAdapter. is it possible to get the header details like Authorization and custom header that are part of the HTTP Post? 

 

Or, do i have to use a different service to get the payload along with the header details?

Product version: IRIS 2022.1
Discussion (2)1
Log in or sign up to continue

Hi Ravi,

Variables that start with "%" for example %request, %session and %request may be in scope from adapter interactions. Otherwise the Adaptor helpfully adds a lot to the Stream Attributes

The following may give ideas for Headers available:

Class Test.HTTP.Service Extends EnsLib.HTTP.Service
{
Parameter ADAPTER = "EnsLib.HTTP.InboundAdapter";
Method OnProcessInput(pInput As %Stream.Object, Output pOutput As %Stream.Object) As %Status
{
#dim %request as %CSP.Request
set pOutput=##class(%Stream.TmpCharacter).%New()
do pOutput.Write("<p>AUTH:"_%session.HttpAuthorization_"</p>")
do pOutput.Write("</hr>")
set attribute=""
for {
set attribute=$Order(pInput.Attributes(attribute),1,data)
quit:attribute="" do pOutput.Write("attribute:"_attribute_" was "_data_"</br>")
}
do pOutput.Write("<hr/>")
set attribute=""
for {
set attribute=$O(%request.CgiEnvs(attribute),1,data)
quit:attribute="" do pOutput.Write("attribute:"_attribute_" was "_data_"</br>")
}
do pOutput.Write("</hr>")
do pOutput.Write("<p>Username:"_$USERNAME_"</p>")
do pOutput.Rewind()
Quit $$$OK
} }

Accessed with Enable-Standard-Resuests=True. With request sent to CSP Application with password authentication.

http://localhost:[portnumber]/csp/healthshare/[namespace]/Test.HTTP.Serv...

Where "TestHTTP" was the Production Item name.

Couldn't see the AUTH Header BUT can see the resulting validated Username in $USERNAME special variable.

Hope this gives some ideas.

Cheers,

Alex