1

在尝试并未能在 PHP 中使用 gzipped Content-Encoding 手动实现分块传输编码后,我现在又回到了在 Apache 中使用 mod_deflate,它做得很好。

唯一的问题是,我想连同回复一起发送一些页脚(比如 Last-Modified 或 ETag,所以我可以 304 请求相同的内容)。HTTP 1.1 规范在分块响应中提供了页脚(就像标题一样,只是它们排在最后)——但 PHP 似乎没有提供该功能。

可能的?

(手动实现很棒——除了我不是 gzip 大师,而且 PHP 提供的各种 zlib 函数不包括创建有效 gzip 块的函数。我设法让它在大约 50% 的时间内工作 - 但其他 50%会坏的。Doh!)

4

1 回答 1

0

AFAIK, php is fired after the post, and before the chunk encoding. The only way I know how to do it, is install an output handler thats above the chunking. I've only been able to do such things through either a C module, or mod_perl, since it allows you to install handlers at any point of the request. I had a similar problem with trying to allow large uploads, because php never fires until after the post is done. So there is no way to check "is it a logged in user" or "allow only this script to get large post data".

于 2011-06-24T05:40:58.913 回答