【发布时间】:2012-05-24 04:31:09
【问题描述】:
我需要手动解压缩以下页面的响应:http://muaban.net/ho-chi-minh.html
我在做
echo -e "GET /ho-chi-minh.html HTTP/1.1\r\nHost: muaban.net\r\nAccept-Encoding: gzip\r\n" | nc muaban.net 80 > response.txt
直到响应实际包含Content-Encoding: gzip 或Content-Encoding: deflate 标头(有时只是纯文本),然后
cat response.txt | sed '1,14d' | zcat
但它说输入不是 gzip 格式。
这是标题:
HTTP/1.1 200 OK
Cache-Control: public, max-age=67
Content-Type: text/html
Content-Encoding: deflate
Expires: Wed, 16 May 2012 15:20:31 GMT
Last-Modified: Wed, 16 May 2012 15:18:31 GMT
Vary: *
Server: Microsoft-IIS/7.5
X-AspNet-Version: 2.0.50727
X-Powered-By: ASP.NET
X-Proxy: 162
Date: Wed, 16 May 2012 15:19:23 GMT
Content-Length: 12618
【问题讨论】:
-
返回的数据是什么样的?它有
Transfer-Encoding: chunked标头吗? -
在帖子中添加了标题。在他们之后,它只是一个压缩的数据块。
-
适合我吗? [tmp]$ echo -e "GET /ho-chi-minh.html HTTP/1.1\r\nHost: muaban.net\r\nAccept-Encoding: gzip\r\n" | nc muaban.net 80 > response.txt [tmp]$ cat response.txt | sed '1,14d' | zcat > response.html gzip: stdin: 文件意外结束 [tmp]$ head -n 2 response.html ttp://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" rel="nofollow" target="_blank">w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-
[tmp]$ zcat --version zcat (gzip) 1.4 版权所有 (C) 2007, 2009-2010 Free Software Foundation, Inc. 这是免费软件。您可以根据 GNU 通用公共许可证 gnu.org/licenses/gpl.html> 的条款重新分发它的副本。在法律允许的范围内,不提供任何保证。由 Paul Eggert 撰写。
标签: bash unix gzip deflate zcat