diff options
author | Igor Sysoev <igor@sysoev.ru> | 2010-10-04 15:03:00 +0000 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2010-10-04 15:03:00 +0000 |
commit | 5fffff997f30e5c56dd95309bb3615f798f8c7c6 (patch) | |
tree | f20db6c16487b4182b49521ce0a8014dec395674 /src | |
parent | 81aa52829ae021dc226b4d25330c63c2ff31149a (diff) | |
download | nginx-5fffff997f30e5c56dd95309bb3615f798f8c7c6.tar.gz nginx-5fffff997f30e5c56dd95309bb3615f798f8c7c6.zip |
gzip_disable degradation
Diffstat (limited to 'src')
-rw-r--r-- | src/http/modules/ngx_http_gzip_filter_module.c | 12 | ||||
-rw-r--r-- | src/http/ngx_http_core_module.c | 52 | ||||
-rw-r--r-- | src/http/ngx_http_core_module.h | 3 |
3 files changed, 59 insertions, 8 deletions
diff --git a/src/http/modules/ngx_http_gzip_filter_module.c b/src/http/modules/ngx_http_gzip_filter_module.c index e2b204ba2..d624e36ff 100644 --- a/src/http/modules/ngx_http_gzip_filter_module.c +++ b/src/http/modules/ngx_http_gzip_filter_module.c @@ -258,6 +258,18 @@ ngx_http_gzip_header_filter(ngx_http_request_t *r) r->gzip_vary = 1; +#if (NGX_HTTP_DEGRADATION) + { + ngx_http_core_loc_conf_t *clcf; + + clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); + + if (clcf->gzip_disable_degradation && ngx_http_degraded(r)) { + return ngx_http_next_header_filter(r); + } + } +#endif + if (!r->gzip_tested) { if (ngx_http_gzip_ok(r) != NGX_OK) { return ngx_http_next_header_filter(r); diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c index 73cde3d82..f6d22482f 100644 --- a/src/http/ngx_http_core_module.c +++ b/src/http/ngx_http_core_module.c @@ -3113,6 +3113,9 @@ ngx_http_core_create_loc_conf(ngx_conf_t *cf) clcf->gzip_disable = NGX_CONF_UNSET_PTR; #endif clcf->gzip_disable_msie6 = 3; +#if (NGX_HTTP_DEGRADATION) + clcf->gzip_disable_degradation = 3; +#endif #endif return clcf; @@ -3373,6 +3376,15 @@ ngx_http_core_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child) (prev->gzip_disable_msie6 == 3) ? 0 : prev->gzip_disable_msie6; } +#if (NGX_HTTP_DEGRADATION) + + if (conf->gzip_disable_degradation == 3) { + conf->gzip_disable_degradation = + (prev->gzip_disable_degradation == 3) ? + 0 : prev->gzip_disable_degradation; + } + +#endif #endif return NGX_CONF_OK; @@ -4394,6 +4406,15 @@ ngx_http_gzip_disable(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) continue; } +#if (NGX_HTTP_DEGRADATION) + + if (ngx_strcmp(value[i].data, "degradation") == 0) { + clcf->gzip_disable_degradation = 1; + continue; + } + +#endif + re = ngx_array_push(clcf->gzip_disable); if (re == NULL) { return NGX_CONF_ERROR; @@ -4414,20 +4435,35 @@ ngx_http_gzip_disable(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) return NGX_CONF_OK; #else - ngx_str_t *value; + ngx_str_t *value; + ngx_uint_t i; value = cf->args->elts; - if (cf->args->nelts == 2 && ngx_strcmp(value[1].data, "msie6") == 0) { - clcf->gzip_disable_msie6 = 1; - return NGX_CONF_OK; + for (i = 1; i < cf->args->nelts; i++) { + if (ngx_strcmp(value[i].data, "msie6") == 0) { + clcf->gzip_disable_msie6 = 1; + continue; + } + +#if (NGX_HTTP_DEGRADATION) + + if (ngx_strcmp(value[i].data, "degradation") == 0) { + clcf->gzip_disable_degradation = 1; + continue; + } + +#endif + + ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, + "without PCRE library \"gzip_disable\" supports " + "builtin \"msie6\" and \"degradation\" mask only"); + + return NGX_CONF_ERROR; } - ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, - "without PCRE library \"gzip_disable\" supports " - "builtin \"msie6\" mask only"); + return NGX_CONF_OK; - return NGX_CONF_ERROR; #endif } diff --git a/src/http/ngx_http_core_module.h b/src/http/ngx_http_core_module.h index f163e9aeb..273586b1c 100644 --- a/src/http/ngx_http_core_module.h +++ b/src/http/ngx_http_core_module.h @@ -295,6 +295,9 @@ struct ngx_http_core_loc_conf_s { unsigned auto_redirect:1; #if (NGX_HTTP_GZIP) unsigned gzip_disable_msie6:2; +#if (NGX_HTTP_DEGRADATION) + unsigned gzip_disable_degradation:2; +#endif #endif ngx_http_location_tree_node_t *static_locations; |