How can I make setHeader overwrite an existing header?

I am working on a CF interface with the ChromeLogger extension (a shameless plugin ) that uses HTTP headers to log data from the server language into the Chrome console.

You can call the log() method several times during the request. For each call, I write the header in the format that is necessary for the data to be displayed correctly in ChromeLogger. In CF10, this works fine - each subsequent call to setHeader() overwrites the previously set header with the same name. However, in CF9, I see several headers with the same name.

This code example demonstrates the problem:

 <cfscript> pc = getPageContext().getResponse(); pc.setHeader( "test-header", "value 1" ); pc.setHeader( "test-header", "value 2" ); pc.setHeader( "test-header", "value 3" ); </cfscript> 

In CF9, I see three headers called "test-header", each of which has its own meaning. In CF10, I see one header named "test-header" with a value of "value 3." According to the Java docs for this method, the latter is true (my attention):

Sets the response header with the given name and value. If the header is already set, the new value overwrites the previous one . The containsHeader method can be used to check for the presence of a header before setting its value.

Using the cfheader tag has the same results, presumably because it simply wraps the setHeader() method.

I know that I can create a header during the request and then call setHeader() once at the end via onRequestEnd() , but I would like this component to be as autonomous as possible - the less the end user needs to change his the code to implement it is better.

Is there another way in CF9 to overwrite an existing header?

+7
source share
1 answer

It looks like this could be a bug in ColdFusion 9. https://bugbase.adobe.com/index.cfm?event=bug&id=3041696 This bug was introduced by Adam Cameron back in June 2010 for version 9.0 (as far as I can tell) . It is indicated with a Deferred status and a NotEnoughTime cause.

+3
source

All Articles