2011-07-19 35 views
5

我想知道爲什麼PHP的Content-Length標題被覆蓋。 這是demo.php來自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 

見的Content-Length的請求?它的最大值爲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 

這裏是模塊加載

[email protected]:/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 

這裏是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 

希望有人能幫助!

歡呼

+0

它仍然是一個32位的Apache有32位PHP - PHP的削減你的BIGINT成32位簽署INT,因此截斷。 –

+0

只是猜測:PHP會自動覆蓋此標題。可能你使用32位系統,所以PHP無法使用更大的整數。 – Karolis

回答

0

好像PHP的播放內容長度爲int

+0

是的,我發現這樣的東西:https://bugs.php.net/bug.php?id = 51723 – Michael

0

是它肯定是一個32位的事情。那麼我不想調整PHP,重新編譯或什麼,所以暫時,我會檢查文件大小,如果它超過2GB,我不會發送標題。

感謝大家的輸入