小编Mic*_*ael的帖子

来自php的内容长度标题被覆盖!

我试图弄清楚为什么php的Content-Length标头会被覆盖.这是demo.php

<?php
header("Content-Length: 21474836470");die;
?>
Run Code Online (Sandbox Code Playgroud)

获取标头的请求

curl -I http://someserver.com/demo.php
HTTP/1.1 200 OK
Date: Tue, 19 Jul 2011 13:44:11 GMT
Server: Apache/2.2.16 (Debian)
X-Powered-By: PHP/5.3.3-7+squeeze3
Content-Length: 2147483647
Cache-Control: must-revalidate
Content-Type: text/html; charset=UTF-8
Run Code Online (Sandbox Code Playgroud)

看内容长度?最大值为2147483647字节,即2GB.

现在如果像这样修改demo.php

<?php
header("Dummy-header: 21474836470");die;
?>
Run Code Online (Sandbox Code Playgroud)

标题不会被覆盖.

HTTP/1.1 200 OK
Date: Tue, 19 Jul 2011 13:49:11 GMT
Server: Apache/2.2.16 (Debian)
X-Powered-By: PHP/5.3.3-7+squeeze3
Dummy-header: : 21474836470
Cache-Control: must-revalidate
Content-Type: text/html; charset=UTF-8
Run Code Online (Sandbox Code Playgroud)

这是加载的模块

root@pat:/etc/apache2# ls /etc/apache2/mods-enabled/
alias.conf        authz_host.load  dav_fs.load    expires.load  php5.conf    reqtimeout.load  status.conf
alias.load        authz_user.load  dav.load       headers.load  php5.load    rewrite.load     status.load
auth_basic.load …
Run Code Online (Sandbox Code Playgroud)

php apache large-files content-length http-headers

5
推荐指数
1
解决办法
1626
查看次数

标签 统计

apache ×1

content-length ×1

http-headers ×1

large-files ×1

php ×1