help with gunzip filter

Maxim Dounin mdounin at mdounin.ru
Thu Oct 18 09:10:02 UTC 2012


Hello!

On Thu, Oct 18, 2012 at 01:08:26PM +0800, honwel wrote:

> hi,all
>     i recently download the nginx-1.3.7 source from www.nginx.org, and i debug the gunzip module because i want unzip content from server and filter the content(use subs filter module-weibin yao), but gunzip nerver work , so i tracking the code, and see this line from function ngx_http_gunzip_header_filter(ngx_http_request_t *r)
> static ngx_int_t
> 1 ngx_http_gunzip_header_filter(ngx_http_request_t *r)
> 2 {
>    ......
>    ......
> 3    if (!r->gzip_tested) {
> 4        if (ngx_http_gzip_ok(r) == NGX_OK) {
> 5            return ngx_http_next_header_filter(r);
> 6        }
> 7    } else if (!r->gzip_ok) {
> 8        return ngx_http_next_header_filter(r);
>     }
> ......
> ......
> }
>  
> l think line 4 should be    "if (ngx_http_gzip_ok(r) != NGX_OK) 
> { ...  }" and change it , then i recomplie source code, make and 
> debug use gdb tool, so function is run ok,  is there a bug?

If you want to gunzip content always you have to omit this block 
entirely.  As of now gunzip only gunzips responses if client does 
not support gzipped responses, hence the check.

The bug seems to be present in line 7 though, it should be

--- a/src/http/modules/ngx_http_gunzip_filter_module.c
+++ b/src/http/modules/ngx_http_gunzip_filter_module.c
@@ -145,7 +145,7 @@ ngx_http_gunzip_header_filter(ngx_http_r
             return ngx_http_next_header_filter(r);
         }
 
-    } else if (!r->gzip_ok) {
+    } else if (r->gzip_ok) {
         return ngx_http_next_header_filter(r);
     }
 

I don't think this code path can be triggered by using stock nginx 
modules, but fixing this won't hurt anyway.  Thanks for pointing 
this.


-- 
Maxim Dounin
http://nginx.com/support.html



More information about the nginx-devel mailing list