Apache 发送传输编码:分块

rta*_*oni 2 apache-2.2

Solaris 上有一个 Apache 服务器正在发送“Transfer-Encoding: chunked”,而不发送我在 PHP 中的“Content-Length”标头(用于下载文件)。你知道有什么方法可以防止这种情况吗?

谢谢

请参阅:https ://stackoverflow.com/questions/1334471/content-length-header-always-zero

我已经尝试过该指令

 SetEnvIfNoCase Request_URI get_file\.php$ no-gzip dont-vary
Run Code Online (Sandbox Code Playgroud)

现在我得到一个与原始文件大小相同的文件,但该文件已损坏。以下是从服务器收到的标头:

http://example.com/output_file_download.php?fileID=130

GET /output_file_download.php?fileID=130 HTTP/1.1
Host: example.com
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 (.NET CLR 3.5.30729)
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-gb,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Cookie: user_id=7C%25R; intrauser=kE06Ub%238+2dHT%29U0t%28B%2A; intrakey=rtacconi; PHPSESSID=5a3f8edff822474f3b95b6a6e5c87ad2


HTTP/1.x 200 OK
Date: Thu, 03 Sep 2009 10:02:05 GMT
Server: Apache
Expires: 0
Cache-Control: private
Pragma: public
Content-Description: File Transfer
Content-Disposition: attachment; filename=alfresco-logo.gif
Content-Transfer-Encoding: binary
Content-Length: 2401
Keep-Alive: timeout=15, max=500
Connection: Keep-Alive
Content-Type: application/octet-stream
Run Code Online (Sandbox Code Playgroud)

And*_*ndy 5

当 Apache 在发送之前不知道总输出大小时,就会发生分块输出,就像压缩传输的情况一样(当数据达到一定大小时,Apache 将数据压缩成块,然后在脚本仍在执行时将它们发送到浏览器/请求者) )。您可能会看到此内容,因为您有mod_deflatemod_gzip处于活动状态。您可以在此处验证这是否是您的问题。

mod_deflate您可以像这样禁用每个文件(更多此处

    SetEnvIfNoCase Request_URI get_file\.php$ no-gzip dont-vary

一般情况下最好保留它,因为它可以大大提高数据传输速度。