comparison src/http/modules/ngx_http_gzip_filter_module.c @ 665:0b460e61bdcd default tip

Merge with nginx 1.0.0.
author Maxim Dounin <mdounin@mdounin.ru>
date Mon, 25 Apr 2011 04:22:17 +0400
parents c5122335e41d
children
comparison
equal deleted inserted replaced
572:06419a2298a9 665:0b460e61bdcd
244 244
245 if (!conf->enable 245 if (!conf->enable
246 || (r->headers_out.status != NGX_HTTP_OK 246 || (r->headers_out.status != NGX_HTTP_OK
247 && r->headers_out.status != NGX_HTTP_FORBIDDEN 247 && r->headers_out.status != NGX_HTTP_FORBIDDEN
248 && r->headers_out.status != NGX_HTTP_NOT_FOUND) 248 && r->headers_out.status != NGX_HTTP_NOT_FOUND)
249 || r->header_only
250 || (r->headers_out.content_encoding 249 || (r->headers_out.content_encoding
251 && r->headers_out.content_encoding->value.len) 250 && r->headers_out.content_encoding->value.len)
252 || (r->headers_out.content_length_n != -1 251 || (r->headers_out.content_length_n != -1
253 && r->headers_out.content_length_n < conf->min_length) 252 && r->headers_out.content_length_n < conf->min_length)
254 || ngx_http_test_content_type(r, &conf->types) == NULL 253 || ngx_http_test_content_type(r, &conf->types) == NULL
255 || ngx_http_gzip_ok(r) != NGX_OK) 254 || r->header_only)
256 { 255 {
256 return ngx_http_next_header_filter(r);
257 }
258
259 r->gzip_vary = 1;
260
261 #if (NGX_HTTP_DEGRADATION)
262 {
263 ngx_http_core_loc_conf_t *clcf;
264
265 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
266
267 if (clcf->gzip_disable_degradation && ngx_http_degraded(r)) {
268 return ngx_http_next_header_filter(r);
269 }
270 }
271 #endif
272
273 if (!r->gzip_tested) {
274 if (ngx_http_gzip_ok(r) != NGX_OK) {
275 return ngx_http_next_header_filter(r);
276 }
277
278 } else if (!r->gzip_ok) {
257 return ngx_http_next_header_filter(r); 279 return ngx_http_next_header_filter(r);
258 } 280 }
259 281
260 ctx = ngx_pcalloc(r->pool, sizeof(ngx_http_gzip_ctx_t)); 282 ctx = ngx_pcalloc(r->pool, sizeof(ngx_http_gzip_ctx_t));
261 if (ctx == NULL) { 283 if (ctx == NULL) {
273 if (h == NULL) { 295 if (h == NULL) {
274 return NGX_ERROR; 296 return NGX_ERROR;
275 } 297 }
276 298
277 h->hash = 1; 299 h->hash = 1;
278 h->key.len = sizeof("Content-Encoding") - 1; 300 ngx_str_set(&h->key, "Content-Encoding");
279 h->key.data = (u_char *) "Content-Encoding"; 301 ngx_str_set(&h->value, "gzip");
280 h->value.len = sizeof("gzip") - 1;
281 h->value.data = (u_char *) "gzip";
282
283 r->headers_out.content_encoding = h; 302 r->headers_out.content_encoding = h;
284 303
285 r->main_filter_need_in_memory = 1; 304 r->main_filter_need_in_memory = 1;
286 305
287 ngx_http_clear_content_length(r); 306 ngx_http_clear_content_length(r);
1111 ngx_conf_merge_size_value(conf->wbits, prev->wbits, MAX_WBITS); 1130 ngx_conf_merge_size_value(conf->wbits, prev->wbits, MAX_WBITS);
1112 ngx_conf_merge_size_value(conf->memlevel, prev->memlevel, 1131 ngx_conf_merge_size_value(conf->memlevel, prev->memlevel,
1113 MAX_MEM_LEVEL - 1); 1132 MAX_MEM_LEVEL - 1);
1114 ngx_conf_merge_value(conf->min_length, prev->min_length, 20); 1133 ngx_conf_merge_value(conf->min_length, prev->min_length, 20);
1115 1134
1116 if (ngx_http_merge_types(cf, conf->types_keys, &conf->types, 1135 if (ngx_http_merge_types(cf, &conf->types_keys, &conf->types,
1117 prev->types_keys, &prev->types, 1136 &prev->types_keys, &prev->types,
1118 ngx_http_html_default_types) 1137 ngx_http_html_default_types)
1119 != NGX_OK) 1138 != NGX_OK)
1120 { 1139 {
1121 return NGX_CONF_ERROR; 1140 return NGX_CONF_ERROR;
1122 } 1141 }