ColdFusion - how to set Content-Length header

落花浮王杯 提交于 2019-12-05 09:42:16
Geoff

I believe I've solved it:

<cfheader name="Content-Length" value="#getPageContext().getCFOutput().getBuffer().size()#">

I stuck that in onRequestEnd() and the Cisco box is happily compressing away.

Thanks for the input folks.

I don't love this idea, but could you make some sort of wrapper with cfsavecontent and take the length of that?

Something like:

<cfsetting enablecfoutputonly="yes">
<cfsavecontent variable="testVar">
     <cfinclude template="myPage.cfm">
</cfsavecontent>
<cfheader name="Content-Length" value="#len(testVar)#">
<cfoutput>#testVar#</cfoutput>

I'm not sure if the count would be off due to white space issues.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!