如何禁用与Apache的内容长度响应头? [英] How to disable the Content-Length response header with Apache?

查看:126
本文介绍了如何禁用与Apache的内容长度响应头?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最后说,我只是想暂时禁用头和我充分认识到影响到浏览器的缓存机制等如果标题是不是present让我preface这个问题。

Let me preface this question by stating that I only want to temporarily disable the header and am fully aware of the implications to browsers, cache mechanisms, etc if the header is not present.

我需要测试一些缓存行为当的Content-Length 头是不是在HTTP响应present。有没有一种方法来禁用的页眉?

I have need to test some caching behavior when the Content-Length header is not present in an HTTP response. Is there a way to disable the header?

我第一次尝试是简单地尝试将它设置为 0 使用PHP和标题(内容长度:0,真正的); 但这不是一样完全除去从响应的报头

My first attempt was to simply try to set it to 0 using PHP and header("Content-Length: 0", true); but this is not the same as completely removing the header from the response.

时可以禁用/删除页眉?

Is it possible to disable/remove the header?

推荐答案

添加内容长度是东西标志着在RFC 2616(HTTP 1.1)也应。这意味着Web服务器通常被设计为不离开它。

Adding Content-Length is something marked in RFC 2616 (HTTP 1.1) as SHOULD. That means web servers generally are designed not to leave it out.

有关实例与Apache HTTP服务器,你需要修改的模块/ HTTP / http_filters.c。搜索从源文件内容长度几乎展示了如何强制取消它(仔细看看在大约1255行)。只需添加未设置到过滤器链的末端和你设置。

For instance with Apache HTTP Server you have to modify modules/http/http_filters.c. Searching for Content-Length from the source file practically shows you how to unset it forcibly (take a closer look at around line 1255). Just add the unset to the end of the filter chain and you're set.

您其他替代方法是使用除了阿帕奇一个其他网络服务器,或者是更容易修改或不尊重2616为好。

Your other alternative is to use an other web server besides Apache that is either easier to modify or doesn't respect RFC 2616 as well.

这篇关于如何禁用与Apache的内容长度响应头?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆