curl 可以看到能输出gzip 但是在浏览器下却没有输出


环境 nginx + php-fpm

curl -v -I -H "Accept-Encoding: gzip,deflate" http://www.ihezhu.com/

* About to connect() to www.ihezhu.com port 80 (#0)
*   Trying 210.51.54.180... connected
> HEAD / HTTP/1.1
> User-Agent: curl/7.22.0 (i686-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3
> Host: www.ihezhu.com
> Accept: */*
> Accept-Encoding: gzip,deflate
> 
< HTTP/1.1 200 OK
HTTP/1.1 200 OK
< Server: nginx
Server: nginx
< Date: Fri, 18 Jan 2013 10:13:19 GMT
Date: Fri, 18 Jan 2013 10:13:19 GMT
< Content-Type: text/html; charset=utf-8
Content-Type: text/html; charset=utf-8
< Connection: keep-alive
Connection: keep-alive
< Vary: Accept-Encoding
Vary: Accept-Encoding
< Set-Cookie: PHPSESSID=i6nkkd79n7uenikq2727u8rln6; path=/
Set-Cookie: PHPSESSID=i6nkkd79n7uenikq2727u8rln6; path=/
< Expires: Thu, 19 Nov 1981 08:52:00 GMT
Expires: Thu, 19 Nov 1981 08:52:00 GMT
< Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
< Pragma: no-cache
Pragma: no-cache
< Content-Encoding: gzip
Content-Encoding: gzip
* no chunk, no close, no size. Assume close to signal end

< 
* Closing connection #0

但直接浏览器却没有看到输出Content-Encoding 大概怎么回事?
谢谢

====update
原因暂时还不明, 说下我做的测试
用fiddler访问, 不输出
用fiddler按照curl构造参数, 不输出
用chrome插件模拟curl请求, 不输出
在本机模拟了服务器配置一致的环境(php.ini, fastcgi, nginx.conf以及站点配置), 可以输出
现在准备在curl中模拟browser的请求, 看看怎样

gzip nginx php

我爱党党爱我 11 years, 3 months ago

建议你用wireshark抓包看看,可能只是chrome没显示这个出来。

感觉chrome的开发者工具不那么靠谱,比如显示出了 Transfer-Encoding: chunked,但是显示出来的却找不是原始的response(不是chunked的格式)。

Tim634 answered 11 years, 3 months ago

Your Answer