我想知道为什么php的内容长度头会被覆盖。
这是demo.php
<?php
header("Content-Length: 21474836470");die;
?>
获取标题的请求
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
看到内容长度了吗?它的最大值是2147483647字节,即2GB。
现在如果像这样修改demo.php
<?php
header("Dummy-header: 21474836470");die;
?>
标题不会被覆盖。
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
下面是加载的模块
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 autoindex.conf dav_lock.load mime.conf proxy.conf setenvif.conf
authn_file.load autoindex.load dir.conf mime.load proxy_http.load setenvif.load
authz_default.load cgi.load dir.load negotiation.conf proxy.load ssl.conf
authz_groupfile.load dav_fs.conf env.load negotiation.load reqtimeout.conf ssl.load
这里有一个phpinfo():http://pastehtml.com/view/b0z02p8zc.html
apache确实支持2GB以上的文件,因为我直接访问大文件没有任何问题:
curl -I http://www.someserver.com/somehugefile.zip (5.3 Gig)
HTTP/1.1 200 OK
Date: Tue, 19 Jul 2011 14:00:25 GMT
Server: Apache/2.2.16 (Debian)
Last-Modified: Fri, 15 Jul 2011 08:50:22 GMT
ETag: "301911-1548e4b11-4a817bd63ef80"
Accept-Ranges: bytes
Content-Length: 5713578769
Cache-Control: must-revalidate
Content-Type: application/zip
这是联阿援助团
Linux pat.someserver.com 2.6.38.2-grsec-xxxx-grs-ipv6-32 #1 SMP Fri Apr 15 17:41:28 UTC 2011 i686 GNU/Linux
希望有人能帮忙!
干杯
最佳答案
似乎php将内容长度强制转换为int