Gzip: clearing of c->buffered if all data are flushed.

This allows to finalize unfinished responses while still sending as
much data as available.
diff --git a/src/http/modules/ngx_http_gzip_filter_module.c b/src/http/modules/ngx_http_gzip_filter_module.c
index 35dd07e..837b0bc 100644
--- a/src/http/modules/ngx_http_gzip_filter_module.c
+++ b/src/http/modules/ngx_http_gzip_filter_module.c
@@ -368,6 +368,8 @@
         if (ngx_chain_add_copy(r->pool, &ctx->in, in) != NGX_OK) {
             goto failed;
         }
+
+        r->connection->buffered |= NGX_HTTP_GZIP_BUFFERED;
     }
 
     if (ctx->nomem) {
@@ -620,8 +622,6 @@
         return NGX_ERROR;
     }
 
-    r->connection->buffered |= NGX_HTTP_GZIP_BUFFERED;
-
     ctx->last_out = &ctx->out;
     ctx->crc32 = crc32(0L, Z_NULL, 0);
     ctx->flush = Z_NO_FLUSH;
@@ -854,6 +854,8 @@
         *ctx->last_out = cl;
         ctx->last_out = &cl->next;
 
+        r->connection->buffered &= ~NGX_HTTP_GZIP_BUFFERED;
+
         return NGX_OK;
     }