Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can CFHEADER values be read by other code?

The code

<cfheader name="Test" value="1">
<cfheader name="Test" value="2">

results in the header "Test: 2" being sent to the browser (as seen using HttpFox).

Is there a way for the second line of code to determine if a header with the same name has already been written using CFHEADER?

Thanks!

like image 393
Aidan Whitehall Avatar asked Jun 15 '10 11:06

Aidan Whitehall


1 Answers

What version of ColdFusion are you using? When I run your code on ColdFusion 9, I get the header value (As seen using FireBug):

test: 1, 2

As for whether or not you can tell what, if any, existing values there might be for the response header, I haven't yet found a way. I'll keep looking, though.

Update: Found it.

getPageContext().getResponse().containsHeader("test")

For example:

<cfif getPageContext().getResponse().containsHeader("test") eq "NO">
    <cfheader name="test" value="2" />
</cfif>
like image 114
Adam Tuttle Avatar answered Oct 16 '22 00:10

Adam Tuttle