HTTP chunked+gzip及浏览器兼容测试_ifreax_新浪博客
HTTP chunked+gzip及浏览器兼容测
简述:
QQ空间提出一个需求,要求qzhttp支持chunked+gzip。每个chunk是一个独立的gzip压缩包,并提到雅虎是这么实现的。
分析结论:1.雅虎的chunked+gzip的方式,每个chunk并不是一个独立的gzip压缩包。
2.如果采用chunked+gzip方式,并且每个chunk都是一个gzip压缩包的方式,浏览器不支持(用ie和chrome测试)。
一. 首先对于雅虎搜索chunked+gzip的一个抓包分析。如果将yahoo的http回包中头字段和chunk控制字段去掉保存起来,会得到一个标准的gzip包,可以用7-zip打开。
二. 关于对浏览器对chunked+gzip的支持测试。为了快速测试,用php脚本实现了一个简单的web server。(见下)
1. 每个chunk单独压缩。用cat参数启动server (server的php脚本见下)
./chunked_gzip.php cat
Chrome对此的反应同样的正确的。
三.
在wikipedia上有对于chunked+gzip是不是分段压缩的明确说明
原文:HTTP servers sometimes use
compression (gzip or deflate) to allow reducing time spent for
transmission. Chunked transfer encoding can be used to delimit
parts of the compressed object. In this case, it is worth
noting that the chunks are not individually compressed.Instead, the complete payload is compressed and
the output of the compression process is chunked using the scheme
described in this article.
译:http server
有时候用压缩来减少传输时间。Chunked方式可以将压缩后的数据分成好几块。在这种情况下,值得注意的是这些chunks并不是分别(独立)被压缩的,相反,整个压缩处理后的输出再用前面讲到的chunked方式传输。
http://en.wikipedia.org/wiki/Chunked_transfer_encoding
php测试脚本代码: