Possible to send HTTP 1.1 Footers from PHP using Transfer-Encoding: chunked?
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, whic开发者_如何学编程h 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!)
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".
精彩评论