Are request header values automatically put somewh...
# box-products
a
Are request header values automatically put somewhere in ColdBox apps where I can access them in the handlers?
s
Try
event.getHTTPHeader( required header, defaultValue = '' )
a
Aha! That sounds like what I'm looking for. Thanks!
s
event
in a Coldbox handler is
RequestContext.cfc
if you ever want to look for keywords like 'header' or other cool things it can do (and there are a lot of them)
including fun little comments like this one
Copy code
// ADOBE FIX YOUR ISNULL BS
		if ( headers.keyExists( arguments.header ) ) {
			return headers[ arguments.header ];
		}
😁 1
a
haha, yup, I feel that pain
these might be response headers though
s
I don't think so, looking at the code
It calls
getHTTPRequestData()
there's a bunch of other stuff in there for response headers
a
Yes, I see it now. getHttpHeader() looks like the ticket I'm looking for. Thanks Samuel!
b
@aaronstoddard And just to clarify, ColdBox doesn't "put them" anywhere per se, it just provides a wrapper for accessing them
a
Got it. Never know when you guys have some magical thingy that we can leverage.
b
This comes in especially handy when doing integration tests where you may want to spoof anything in the HTTP request such as the HTTP method, query string, headers, etc.
a
I'm specifically checking for an auth header for some restful routes.
b
You can mock that method in your test suite and then the entire framework behaves as though that data was in the actual HTTP request
👍 1
a
Perfect. Thanks again!