How to get Custom Header added during a request to Cache
We are trying to get a custom header that I have added to a request to Cache, and I have seen the following in another post, however it doesn't work for us:
You can do it as in any CSP page/class. With %request, which is object of class %CSP.Request
And headers available in property CgiEnvs, where every http header appear with a prefix HTTP_
So, you may try this code.
set ipCountry=%request.GetCgiEnv("HTTP_CF_IPCOUNTRY")
I have verified in Charles (a Mac equivalent to the Windows traffic sniffer 'Fiddler' program) that my client sent the following headers in the request to Cache:
GET /csp/portal/[Redacted].csp?Token=[Redacted] HTTP/1.1
Host: [Redacted]
MyCustomHeader: Version:0.0.3,Application:[Redacted],OS:iOS,Device:Tablet,Client:[Redacted].Controls.HybridWebView
Upgrade-Insecure-Requests: 1
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
User-Agent: Mozilla/5.0 (iPad; CPU OS 12_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/16B91
Accept-Language: en-us
Accept-Encoding: gzip, deflate
Connection: keep-alive
However using various script calls, we have not been able to get the MyCustomHeader header key nor value.
I have also looked at other API calls such as GetHeader() in https://docs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KEY... but the ones I have seen don't work, and my suspicion around why these calls don't work is the subtlety in wording of the API for these methods, regarding the use of the word 'main' in their method descriptions, vis-a-vis:
"Returns the current value for any main HTTP header that has been set in this request."
Does this mean that the API does not regard a custom request header as a 'main' header.
Any ideas how to extract a custom header from an incoming request to Cache?
Kind regards,
Anthony