[ANNOUNCE] gunzip filter module 0.3

theromis1 nginx-forum at nginx.us
Tue Apr 20 01:15:16 MSD 2010


Perfect Max,

understood your style of module, right now I'm working hard to deploy it just with small hacks.

Actually we don't need to do unzipping always, we need unzip only for 200 upstream responses and only for text/html answers for reducing load on server. Looks like better to have coordination with your way of development, so I need small instructions how better to do it, and I'll send my patch for it.

--- /home/roman/work/ngx_http_gunzip_filter_module-0.3/ngx_http_gunzip_filter_module.c	2010-03-22 11:11:16.000000000 -0700
+++ ngx_http_gunzip_filter_module.c	2010-04-16 16:37:01.000000000 -0700
@@ -132,6 +132,7 @@
     if (!conf->enable
         || r->headers_out.content_encoding == NULL
         || r->headers_out.content_encoding->value.len != 4
+        || r->upstream->state->status != 200
         || ngx_strncasecmp(r->headers_out.content_encoding->value.data,
                            (u_char *) "gzip", 4) != 0)
     {
@@ -142,6 +143,9 @@
 
     r->gzip_vary = 1;
 
+    r->gzip_tested = 1;
+    r->gzip_ok = 1;
+
     if (!r->gzip_tested) {
         if (ngx_http_gzip_ok(r) == NGX_OK) {
             return ngx_http_next_header_filter(r);
@@ -315,7 +319,7 @@
     ctx->zstream.opaque = ctx;
 
     /* windowBits +16 to decode gzip, zlib 1.2.0.4+ */
-    rc = inflateInit2(&ctx->zstream, MAX_WBITS + 16);
+    rc = inflateInit2(&ctx->zstream, MAX_WBITS + 32); // yahoo looks weird with previous init
 
     if (rc != Z_OK) {
         ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0,

If not apply r->upstream->state->status != 200 in headers processing I'm getting a lot of errors in log, one of it is http://yandex.ru/yandsearch?text=sunken , which sends 302 redirect url with gzipped content, I've tried to fix it, but found just error in zlib, when I've stored dumped data and used 'gzip -d' on it all decompressed fine, and I've got normal HTML. How better to debug it? What advice you can give me?

sincerely Roman Vasilyev

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,66713,76730#msg-76730




More information about the nginx mailing list