Is there a way to replace the default HTTP header info with <cfcontent>?

View: New views
3 Messages — Rating Filter:   Alert me  

Is there a way to replace the default HTTP header info with <cfcontent>?

by Asaf Peleg :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hi,

I have posted previously about an issue with Internet Explorer that I discovered when I switched my site over to HTTPS.  Basically, dynamically generated excel/CSV files using the <cfheader> and <cfcontent> (see examples below) throw an error in Internet Explorer (both IE7 & IE8) when you click to download them but there is no issue with Firefox.  In addition to dynamically generated excel/CSV files my website also generates dynamically generated reports using the Coldfusion Report Builder but for some reason these files still work under HTTPS and Internet Explorer.  I started suspecting something in the HTTP Header was the culprit for the error so I used Fiddler to grab the headers from the two HTTP responses and I noticed several differences (see examples below).  I tried editing my HTTP headers by adding more <cfheader>'s but instead of replacing the default HTTP headers it added a duplicate.  I'm basically trying to isolate the issue by trying to mirror the HTTP header in the Coldfusion Report Builder file but I'm concerned these duplicates are getting in my way.  Does anyone know how to overwrite or remove the default headers?

<!---ORIGINAL HEADERS--->
<cfheader NAME="Content-Disposition" VALUE="inline; filename=TimberlineRprt_#DateFormat(month,'mm_yy')#.csv">
<CFCONTENT TYPE="application/vnd.ms-excel" reset="yes">

<!---HTTP HEADER COMPARISON--->
<!---<CFCONTENT> Header--->
HTTP/1.1 200 OK
Connection: close
Date: Fri, 06 Nov 2009 16:19:39 GMT
Server: Microsoft-IIS/6.0
MicrosoftOfficeWebServer: 5.0_Pub
X-Powered-By: ASP.NET
Pragma: no-cache
Content-Disposition: inline; filename="TimberlineRprt_11_09.csv"
Expires: -1
Content-Type: application/vnd.ms-excel
cache-control: no-cache, no-store, must-revalidate

<!---CF Report Builder Header--->
HTTP/1.1 200 OK
Date: Fri, 06 Nov 2009 15:58:45 GMT
Server: Microsoft-IIS/6.0
MicrosoftOfficeWebServer: 5.0_Pub
X-Powered-By: ASP.NET
Pragma: public
Content-disposition: inline;filename="reports.NYSERDA.xls"
Expires: 0
Content-Type: application/vnd.ms-excel
cache-control: must-revalidate, post-check=0, pre-check=0
Content-Length: 12800

<!---ADDED HEADERS--->
<cfheader NAME="Pragma" VALUE="public">
<cfheader NAME="Expires" VALUE="0">
<cfheader NAME="Cache-control" VALUE="must-revalidate, post-check=0, pre-check=0">

<!---ADDED HEADERS HTTP HEADER COMPARISON--->
HTTP/1.1 200 OK
Connection: close
Date: Fri, 06 Nov 2009 16:19:39 GMT
Server: Microsoft-IIS/6.0
MicrosoftOfficeWebServer: 5.0_Pub
X-Powered-By: ASP.NET
Pragma: no-cache
Pragma: public
Content-Disposition: inline; filename="TimberlineRprt_11_09.csv"
Expires: -1
Expires: 0
Content-Type: application/vnd.ms-excel
cache-control: no-cache, no-store, must-revalidate
cache-control: must-revalidate, post-check=0, pre-check=0

Thanks,
Asaf

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists
Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:328088
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.4

Re: Is there a way to replace the default HTTP header info with <cfcontent>?

by Dave Watts :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


> I have posted previously about an issue with Internet Explorer that I discovered when I
> switched my site over to HTTPS.  Basically, dynamically generated excel/CSV files using
> the <cfheader> and <cfcontent> (see examples below) throw an error in Internet Explorer
> (both IE7 & IE8) when you click to download them but there is no issue with Firefox.  In
> addition to dynamically generated excel/CSV files my website also generates dynamically
> generated reports using the Coldfusion Report Builder but for some reason these files still
> work under HTTPS and Internet Explorer.  I started suspecting something in the HTTP
> Header was the culprit for the error so I used Fiddler to grab the headers from the two
> HTTP responses and I noticed several differences (see examples below).  I tried editing my
> HTTP headers by adding more <cfheader>'s but instead of replacing the default HTTP
> headers it added a duplicate.  I'm basically trying to isolate the issue by trying to mirror
> the HTTP header in the Coldfusion Report Builder file but I'm concerned these duplicates
> are getting in my way.  Does anyone know how to overwrite or remove the default headers?

You can simply use CFHEADER instead of CFCONTENT, if CFCONTENT is
writing something you want written differently.

Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/

Fig Leaf Software provides the highest caliber vendor-authorized
instruction at our training centers in Washington DC, Atlanta,
Chicago, Baltimore, Northern Virginia, or on-site at your location.
Visit http://training.figleaf.com/ for more inform

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists
Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:328090
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.4

Re: Is there a way to replace the default HTTP header info with <cfcontent>?

by Asaf Peleg :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Thanks for your suggestion.  I'm sure your solution would have worked but I started messing with getPageContext() and was able to use that to overwrite the existing headers.

I found that by doing the following after <cfcontent> it corrected my problem.
<cfset getPageContext().getResponse().setHeader("Cache-control","must-revalidate, post-check=0, pre-check=0")>
<cfset getPageContext().getResponse().setHeader("Pragma","public")>

Thanks,
Asaf

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists
Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:328102
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.4