# Curl can response gzip but browser can't

**URL:** <https://www.ruby-forum.com/t/curl-can-response-gzip-but-browser-cant/225612>\
**Category:** NGINX\
**Created:** [January 18, 2013, 12:11pm UTC](https://www.ruby-forum.com/t/curl-can-response-gzip-but-browser-cant/225612 "2013-01-18T12:11:42Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![aris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/258eb7/32.png) [@aris](https://www.ruby-forum.com/u/aris)\
**Post date:** [January 18, 2013, 12:11pm UTC](https://www.ruby-forum.com/t/curl-can-response-gzip-but-browser-cant/225612/1 "2013-01-18T12:11:42Z")

</div>

my environment is nginx(1.3.11) + php-fpm

curl -I -H “Accept-Encoding: gzip,deflate” [http://www.ihezhu.com/](http://www.ihezhu.com/)

HTTP/1.1 200 OK  
Server: nginx  
Date: Fri, 18 Jan 2013 05:18:31 GMT  
Content-Type: text/html; charset=utf-8  
Connection: keep-alive  
Vary: Accept-Encoding  
Set-Cookie: PHPSESSID=2quqa651uglt62ku49re2nt1n4; path=/  
Expires: Thu, 19 Nov 1981 08:52:00 GMT  
Cache-Control: no-store, no-cache, must-revalidate, post-check=0,  
pre-check=0  
Pragma: no-cache  
Content-Encoding: gzip

but when use browser like chrome and it’s response not contain  
Content-Encoding, what’s wrong?

my nginx setting is

```
gzip on;
gzip_buffers 4 16k;
gzip_comp_level 3;
gzip_http_version 1.1;
gzip_min_length 1k;
gzip_proxied any;
gzip_types text/plain text/css application/json 

```

application/x-javascript  
text/xml application/xml application/xml+rss text/javascript;  
gzip\_vary on;  
gzip\_disable msie6;

thanks

Posted at Nginx Forum:

> **[curl can response gzip but browser can't](https://forum.nginx.org/read.php?2,235266,235266#msg-235266)**
>
> my environment is nginx(1.3.11) + php-fpm curl -I -H "Accept-Encoding: gzip,deflate" http://www.ihezhu.com/ HTTP/1.1 200 OK Server: nginx Date: Fri, 18 Jan 2013 05:18:31 GMT Content-Type: text/html; charset=utf-8 Connection: keep-al

---

<div class="post-metadata">

**Author:** ![wingoo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/dec6dc/32.png) [@wingoo](https://www.ruby-forum.com/u/wingoo)\
**Post date:** [January 21, 2013, 1:39am UTC](https://www.ruby-forum.com/t/curl-can-response-gzip-but-browser-cant/225612/2 "2013-01-21T01:39:01Z")

</div>

Hello!

On Fri, Jan 18, 2013 at 06:11:06AM -0500, wingoo wrote:

> Set-Cookie: PHPSESSID=2quqa651uglt62ku49re2nt1n4; path=/
> 
> thanks

It looks like something on your host interferes with normal  
request handling. Probably some firewall with content  
inspection and/or antivirus software.

I was able to simplify test case down to the LF vs CRLF difference  
in the following requests:

$ (printf “GET / HTTP/1.1\r\nHost: [www.ihezhu.com](http://www.ihezhu.com)\r\nAccept-Encoding:  
gzip\r\n\r\n”; sleep 1) | nc 210.51.54.180 80 | grep Content-Encoding  
$ (printf “GET / HTTP/1.1\nHost: [www.ihezhu.com](http://www.ihezhu.com)\nAccept-Encoding:  
gzip\n\n”; sleep 1) | nc 210.51.54.180 80 | grep -a Content-Encoding  
Content-Encoding: gzip

No gzip is returned with proper CRLF newlines, while with just  
bare LFs gzip is returned (likely because it bypasses content  
inspection in question).

Try disabling your antivirus software to see if it helps.

–  
Maxim D.

> **[F5 NGINX: Built for cloud-native apps. Ready for AI traffic.](https://www.f5.com/products/nginx)**
>
> Deliver modern applications with NGINX. Explore high-performance load balancing, API gateways, and web server solutions trusted by top global enterprises.
