从PHP Content-Length头被覆盖! [英] content-length header from php is overwritten !

查看:152
本文介绍了从PHP Content-Length头被覆盖!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图找出为什么PHP的Content-Length头被覆盖。
这是demo.php

I'm trying to figure why the Content-Length header of php gets overwritten. This is 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。

See Content-Length ? It maxes out at 2147483647 bytes, that is 2GB.

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

Now if modify demo.php like so

<?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

Here is a phpinfo() : http://pastehtml.com/view/b0z02p8zc.html

Apache的不支持文件超过2GB,因为我没有任何问题,直接访问大型文件:

Apache does support files over 2GB, as I don't have any problem accessing large file directly :

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

下面是一个的uname -a

Here is a uname -a

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

希望有人能帮助!

Hope somebody can help !

欢呼声

推荐答案

是的它肯定是一个32位的事情。好吧,我不希望调整PHP,编译或东西,所以暂时,我会检查文件的大小,如果它超过2GB,我不发送头。

Yes it's certainly a 32 bits thing. Well I don't want to tweak PHP, recompile or something, so for the time being, I will check the file size, and if it's over 2GB, I'm not sending the header.

感谢大家的输入

这篇关于从PHP Content-Length头被覆盖!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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