comparison src/http/modules/ngx_http_gzip_filter_module.c @ 2051:115e6f029fcc

"gzip_vary on" always sends "Vary: Accept-Encoding" header
author Igor Sysoev <igor@sysoev.ru>
date Fri, 20 Jun 2008 14:41:03 +0000
parents 2a92804f4109
children 723df5089c05
comparison
equal deleted inserted replaced
2050:c0bafb136d7b 2051:115e6f029fcc
202 202
203 203
204 static ngx_int_t 204 static ngx_int_t
205 ngx_http_gzip_header_filter(ngx_http_request_t *r) 205 ngx_http_gzip_header_filter(ngx_http_request_t *r)
206 { 206 {
207 ngx_str_t *type; 207 ngx_str_t *type;
208 ngx_uint_t i; 208 ngx_uint_t i;
209 ngx_table_elt_t *h; 209 ngx_table_elt_t *h;
210 ngx_http_gzip_ctx_t *ctx; 210 ngx_http_gzip_ctx_t *ctx;
211 ngx_http_gzip_conf_t *conf; 211 ngx_http_gzip_conf_t *conf;
212 ngx_http_core_loc_conf_t *clcf;
213 212
214 conf = ngx_http_get_module_loc_conf(r, ngx_http_gzip_filter_module); 213 conf = ngx_http_get_module_loc_conf(r, ngx_http_gzip_filter_module);
215 214
216 if (!conf->enable 215 if (!conf->enable
217 || (r->headers_out.status != NGX_HTTP_OK 216 || (r->headers_out.status != NGX_HTTP_OK
262 h->value.len = sizeof("gzip") - 1; 261 h->value.len = sizeof("gzip") - 1;
263 h->value.data = (u_char *) "gzip"; 262 h->value.data = (u_char *) "gzip";
264 263
265 r->headers_out.content_encoding = h; 264 r->headers_out.content_encoding = h;
266 265
267 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
268
269 if (clcf->gzip_vary) {
270 h = ngx_list_push(&r->headers_out.headers);
271 if (h == NULL) {
272 return NGX_ERROR;
273 }
274
275 h->hash = 1;
276 h->key.len = sizeof("Vary") - 1;
277 h->key.data = (u_char *) "Vary";
278 h->value.len = sizeof("Accept-Encoding") - 1;
279 h->value.data = (u_char *) "Accept-Encoding";
280 }
281
282 ctx->length = r->headers_out.content_length_n; 266 ctx->length = r->headers_out.content_length_n;
283 267
284 r->main_filter_need_in_memory = 1; 268 r->main_filter_need_in_memory = 1;
285 269
286 ngx_http_clear_content_length(r); 270 ngx_http_clear_content_length(r);