简体   繁体   中英

How to disable Content-Length on LAMP

I need disable sending of Content-length an make other different settings in headers. How to perform that on LAMP configs?

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
  header("Transfer-encoding: chunked");
  flush();
?>

This has been solved before on SO: How to make PHP generate Chunked response

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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