可以使用 Transfer-Encoding: chunked 从 PHP 发送 HTTP 1.1 页脚吗?
在尝试在 PHP 中使用 gzipped Content-Encoding 手动实现分块传输编码但失败后,我现在又回到在 Apache 中使用 mod_deflate,它做得很好。
唯一的问题是,我想将一些页脚与回复一起发送(例如,Last-Modified 或 ETag,这样我就可以对相同内容进行 304 请求)。 HTTP 1.1 规范在分块响应中提供了页脚(就像页眉一样,只是它们位于最后) - 但 PHP 似乎没有提供该功能。
可能的?
(手动实现很棒 - 除了我不是 gzip 大师,而且 PHP 提供的各种 zlib 函数不包括创建有效 gzip 块的函数。我设法让它在大约 50% 的时间内工作 - 但其他 50%会坏的!)
Having tried and failed to get a manual implementation of chunked Transfer-Encoding with gzipped Content-Encoding working in PHP, I'm now back to using mod_deflate in Apache, which does a nice job.
Only problem is, there are some footers I'd like to send along with the reply (say, Last-Modified or ETag, so I can 304 requests for the same content). The HTTP 1.1 spec provides for footers (just like headers, only they come last) in chunked responses - but PHP doesn't seem to offer the functionality.
Possible?
(The manual implementation was great - except I'm no gzip master and the various zlib funcs PHP provides don't include one that creates valid gzipped chunks. I managed to get it working ~50% of the time - but the other 50% would break. Doh!)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
AFAIK,php 在发布之后、块编码之前被触发。我知道如何做到这一点的唯一方法是在分块之上安装一个输出处理程序。我只能通过 C 模块或 mod_perl 来完成此类操作,因为它允许您在请求的任何点安装处理程序。我在尝试允许大量上传时遇到了类似的问题,因为 php 在帖子完成后才会触发。因此无法检查“是否是登录用户”或“仅允许此脚本获取大量发布数据”。
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".