简体   繁体   English

如何在LAMP上禁用Content-Length

[英]How to disable Content-Length on LAMP

I need disable sending of Content-length an make other different settings in headers. 我需要禁用Content-length发送,并在标头中进行其他设置。 How to perform that on LAMP configs? 如何在LAMP配置上执行该操作?

At all, I need to make it like this 根本就需要这样

Cache-Control:no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Connection:Keep-Alive
Content-Type:text/html
Date:Tue, 21 Jul 2015 05:58:49 GMT
Expires:Thu, 19 Nov 1981 08:52:00 GMT
Keep-Alive:timeout=15, max=97
Pragma:no-cache
Server:Apache
Transfer-Encoding:chunked

But now I have this 但是现在我有了这个

Cache-Control:no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Connection:Keep-Alive
Content-Encoding:gzip
Content-Language:ru-RU
Content-Length:2640
Content-Type:text/html; charset=utf-8
Date:Tue, 21 Jul 2015 05:58:44 GMT
Expires:Thu, 19 Nov 1981 08:52:00 GMT
Keep-Alive:timeout=5, max=95
Pragma:no-cache
Server:Apache/2.2.22 (Debian)
Vary:Accept-Encoding
X-Powered-By:PHP/5.4.41-0+deb7u1

Assuming you wish to accomplish this in PHP (I'm guessing from the headers that you are using PHP), you need to tell httpd that the encoding is chunked: 假设您希望在PHP中完成此操作(从您使用的标头中猜测),您需要告诉httpd编码已分块:

<?php
  header("Transfer-encoding: chunked");
  flush();
?>

This has been solved before on SO: How to make PHP generate Chunked response 之前在SO上已经解决了这一问题: 如何使PHP生成Chunked响应

While you may do this with PHP, I would advise you do not do this for static files, as that would kind of ruin the whole point of the protocol. 尽管您可以使用PHP进行此操作,但我建议您不要对静态文件执行此操作,因为那样会破坏协议的整个内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM