[英]content-length header from php is overwritten !
我試圖弄清楚為什么 php 的 Content-Length header 被覆蓋。 這是演示。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;
?>
header 未被覆蓋。
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
這是一個 unname -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
希望有人能幫忙!
干杯
好像 php 將 Content-length 轉換為 int
是的,它肯定是一個 32 位的東西。 好吧,我不想調整 PHP,重新編譯什么的,所以暫時我會檢查文件大小,如果超過 2GB,我不會發送 header。
謝謝大家的意見
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.