From 6c49a5afcfa76ea5ed1ca5801bf955b102b2b597 Mon Sep 17 00:00:00 2001 From: Igor Sysoev Date: Thu, 12 Nov 2009 13:41:56 +0000 Subject: refactor gzip_vary handling --- src/http/modules/ngx_http_gzip_filter_module.c | 14 ++++++++++++-- src/http/modules/ngx_http_gzip_static_module.c | 3 ++- 2 files changed, 14 insertions(+), 3 deletions(-) (limited to 'src/http/modules') diff --git a/src/http/modules/ngx_http_gzip_filter_module.c b/src/http/modules/ngx_http_gzip_filter_module.c index 62b430b71..4c0c0d201 100644 --- a/src/http/modules/ngx_http_gzip_filter_module.c +++ b/src/http/modules/ngx_http_gzip_filter_module.c @@ -251,12 +251,22 @@ ngx_http_gzip_header_filter(ngx_http_request_t *r) && r->headers_out.content_encoding->value.len) || (r->headers_out.content_length_n != -1 && r->headers_out.content_length_n < conf->min_length) - || ngx_http_test_content_type(r, &conf->types) == NULL - || ngx_http_gzip_ok(r) != NGX_OK) + || ngx_http_test_content_type(r, &conf->types) == NULL) { return ngx_http_next_header_filter(r); } + r->gzip_vary = 1; + + 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); + } + ctx = ngx_pcalloc(r->pool, sizeof(ngx_http_gzip_ctx_t)); if (ctx == NULL) { return NGX_ERROR; diff --git a/src/http/modules/ngx_http_gzip_static_module.c b/src/http/modules/ngx_http_gzip_static_module.c index cff23e02a..a928d16ae 100644 --- a/src/http/modules/ngx_http_gzip_static_module.c +++ b/src/http/modules/ngx_http_gzip_static_module.c @@ -145,7 +145,6 @@ ngx_http_gzip_static_handler(ngx_http_request_t *r) case NGX_ENOTDIR: case NGX_ENAMETOOLONG: - r->gzip = 0; return NGX_DECLINED; case NGX_EACCES: @@ -165,6 +164,8 @@ ngx_http_gzip_static_handler(ngx_http_request_t *r) return NGX_DECLINED; } + r->gzip_vary = 1; + if (rc != NGX_OK) { return NGX_DECLINED; } -- cgit