Quantcast
Channel: Nginx Forum
Viewing all articles
Browse latest Browse all 53287

[PATCH] Add directive to always gunzip content

$
0
0
Use this by adding "gunzip_always on;" to configuration.
This was in the modules to-do list.
Cheers.

@@ -16,6 +16,7 @@
typedef struct {
ngx_flag_t enable;
ngx_bufs_t bufs;
+ ngx_flag_t always;
} ngx_http_gunzip_conf_t;


@@ -77,6 +78,13 @@
NGX_HTTP_LOC_CONF_OFFSET,
offsetof(ngx_http_gunzip_conf_t, bufs),
NULL },
+
+ { ngx_string("gunzip_always"),
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
+ ngx_conf_set_flag_slot,
+ NGX_HTTP_LOC_CONF_OFFSET,
+ offsetof(ngx_http_gunzip_conf_t, always),
+ NULL },

ngx_null_command
};
@@ -126,7 +134,7 @@
conf = ngx_http_get_module_loc_conf(r, ngx_http_gunzip_filter_module);

/* TODO support multiple content-codings */
- /* TODO always gunzip - due to configuration or module request */
+ /* TODO always gunzip - due to module request */
/* TODO ignore content encoding? */

if (!conf->enable
@@ -140,13 +148,16 @@

r->gzip_vary = 1;

- if (!r->gzip_tested) {
- if (ngx_http_gzip_ok(r) == NGX_OK) {
+ /* if configured to gunzip always, don't check request headers */
+ if (!conf->always) {
+ if (!r->gzip_tested) {
+ if (ngx_http_gzip_ok(r) == NGX_OK) {
+ return ngx_http_next_header_filter(r);
+ }
+
+ } else if (r->gzip_ok) {
return ngx_http_next_header_filter(r);
}
-
- } else if (r->gzip_ok) {
- return ngx_http_next_header_filter(r);
}

ctx = ngx_pcalloc(r->pool, sizeof(ngx_http_gunzip_ctx_t));
@@ -644,6 +655,7 @@
*/

conf->enable = NGX_CONF_UNSET;
+ conf->always = NGX_CONF_UNSET;

return conf;
}
@@ -656,6 +668,7 @@
ngx_http_gunzip_conf_t *conf = child;

ngx_conf_merge_value(conf->enable, prev->enable, 0);
+ ngx_conf_merge_value(conf->always, prev->always, 0);

ngx_conf_merge_bufs_value(conf->bufs, prev->bufs,
(128 * 1024) / ngx_pagesize, ngx_pagesize);



--

*Roy Reznik, VP R&D*

Adallom, 1 Ha'barzel st., Tel-Aviv, Israel

Mobile: +972 (54) 4524066

*roy@adallom.com, www.adallom.com*
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel

Viewing all articles
Browse latest Browse all 53287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>