ColdFusion - 如何设置 Content-Length 标头

发布于 2024-09-27 12:26:29 字数 254 浏览 0 评论 0原文

有没有人成功地将 Content-Length 标头添加到常规 ColdFusion(我使用的是 CF9)页面?我正在 Cisco 负载均衡器后面设置一台带有压缩功能的新服务器 - 盒子拒绝压缩没有此标头的任何内容,但 CF 默认情况下不会通过它。

将设置标头,但找到正确的值是一个问题。

任何指示将不胜感激。

Has anyone successfully added a Content-Length header to regular ColdFusion (I'm using CF9) pages? I'm setting up a new server behind a Cisco load balancer with compression - the box refuses to compress anything without this header, but CF doesn't pass it by default.

<cfheader name="Content-Length" value="something"> will set the header, but finding the right value is a problem.

Any pointers would be much appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

临风闻羌笛 2024-10-04 12:26:30

我相信我已经解决了它:

我卡住了onRequestEnd() 中的内容和 Cisco 盒子正在愉快地压缩。

感谢大家的意见。

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.

深巷少女 2024-10-04 12:26:30

我不喜欢这个想法,但是你能用 cfsavecontent 制作某种包装器并获取其长度吗?

比如:

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

我不确定计数是否会由于空白问题而关闭。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文