Mercurial > hg > nginx-vendor-0-7
comparison src/http/modules/ngx_http_gzip_filter_module.c @ 58:b55cbf18157e NGINX_0_1_29
nginx 0.1.29
*) Feature: the ngx_http_ssi_module supports "include virtual" command.
*) Feature: the ngx_http_ssi_module supports the condition command like
'if expr="$NAME"' and "else" and "endif" commands. Only one nested
level is supported.
*) Feature: the ngx_http_ssi_module supports the DATE_LOCAL and
DATE_GMT variables and "config timefmt" command.
*) Feature: the "ssi_ignore_recycled_buffers" directive.
*) Bugfix: the "echo" command did not show the default value for the
empty QUERY_STRING variable.
*) Change: the ngx_http_proxy_module was rewritten.
*) Feature: the "proxy_redirect", "proxy_pass_request_headers",
"proxy_pass_request_body", and "proxy_method" directives.
*) Feature: the "proxy_set_header" directive. The "proxy_x_var" was
canceled and must be replaced with the proxy_set_header directive.
*) Change: the "proxy_preserve_host" is canceled and must be replaced
with the "proxy_set_header Host $host" and the "proxy_redirect off"
directives, the "proxy_set_header Host $host:$proxy_port" directive
and the appropriate proxy_redirect directives.
*) Change: the "proxy_set_x_real_ip" is canceled and must be replaced
with the "proxy_set_header X-Real-IP $remote_addr" directive.
*) Change: the "proxy_add_x_forwarded_for" is canceled and must be
replaced with
the "proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for"
directive.
*) Change: the "proxy_set_x_url" is canceled and must be replaced with
the "proxy_set_header X-URL http://$host:$server_port$request_uri"
directive.
*) Feature: the "fastcgi_param" directive.
*) Change: the "fastcgi_root", "fastcgi_set_var" and "fastcgi_params"
directive are canceled and must be replaced with the fastcgi_param
directives.
*) Feature: the "index" directive can use the variables.
*) Feature: the "index" directive can be used at http and server levels.
*) Change: the last index only in the "index" directive can be absolute.
*) Feature: the "rewrite" directive can use the variables.
*) Feature: the "internal" directive.
*) Feature: the CONTENT_LENGTH, CONTENT_TYPE, REMOTE_PORT, SERVER_ADDR,
SERVER_PORT, SERVER_PROTOCOL, DOCUMENT_ROOT, SERVER_NAME,
REQUEST_METHOD, REQUEST_URI, and REMOTE_USER variables.
*) Change: nginx now passes the invalid lines in a client request
headers or a backend response header.
*) Bugfix: if the backend did not transfer response for a long time and
the "send_timeout" was less than "proxy_read_timeout", then nginx
returned the 408 response.
*) Bugfix: the segmentation fault was occurred if the backend sent an
invalid line in response header; bug appeared in 0.1.26.
*) Bugfix: the segmentation fault may occurred in FastCGI fault
tolerance configuration.
*) Bugfix: the "expires" directive did not remove the previous
"Expires" and "Cache-Control" headers.
*) Bugfix: nginx did not take into account trailing dot in "Host"
header line.
*) Bugfix: the ngx_http_auth_module did not work under Linux.
*) Bugfix: the rewrite directive worked incorrectly, if the arguments
were in a request.
*) Bugfix: nginx could not be built on MacOS X.
author | Igor Sysoev <http://sysoev.ru> |
---|---|
date | Thu, 12 May 2005 00:00:00 +0400 |
parents | 72eb30262aac |
children | 0790a8599248 |
comparison
equal
deleted
inserted
replaced
57:5df375c55338 | 58:b55cbf18157e |
---|---|
205 ngx_null_command | 205 ngx_null_command |
206 }; | 206 }; |
207 | 207 |
208 | 208 |
209 static ngx_http_module_t ngx_http_gzip_filter_module_ctx = { | 209 static ngx_http_module_t ngx_http_gzip_filter_module_ctx = { |
210 ngx_http_gzip_add_log_formats, /* pre conf */ | 210 ngx_http_gzip_add_log_formats, /* preconfiguration */ |
211 NULL, /* postconfiguration */ | |
211 | 212 |
212 NULL, /* create main configuration */ | 213 NULL, /* create main configuration */ |
213 NULL, /* init main configuration */ | 214 NULL, /* init main configuration */ |
214 | 215 |
215 NULL, /* create server configuration */ | 216 NULL, /* create server configuration */ |
219 ngx_http_gzip_merge_conf /* merge location configuration */ | 220 ngx_http_gzip_merge_conf /* merge location configuration */ |
220 }; | 221 }; |
221 | 222 |
222 | 223 |
223 ngx_module_t ngx_http_gzip_filter_module = { | 224 ngx_module_t ngx_http_gzip_filter_module = { |
224 NGX_MODULE, | 225 NGX_MODULE_V1, |
225 &ngx_http_gzip_filter_module_ctx, /* module context */ | 226 &ngx_http_gzip_filter_module_ctx, /* module context */ |
226 ngx_http_gzip_filter_commands, /* module directives */ | 227 ngx_http_gzip_filter_commands, /* module directives */ |
227 NGX_HTTP_MODULE, /* module type */ | 228 NGX_HTTP_MODULE, /* module type */ |
228 ngx_http_gzip_filter_init, /* init module */ | 229 ngx_http_gzip_filter_init, /* init module */ |
229 NULL /* init process */ | 230 NULL /* init process */ |
255 }; | 256 }; |
256 | 257 |
257 #endif | 258 #endif |
258 | 259 |
259 | 260 |
261 static ngx_str_t ngx_http_gzip_no_cache = ngx_string("no-cache"); | |
262 static ngx_str_t ngx_http_gzip_no_store = ngx_string("no-store"); | |
263 static ngx_str_t ngx_http_gzip_private = ngx_string("private"); | |
264 | |
265 | |
260 static ngx_http_output_header_filter_pt ngx_http_next_header_filter; | 266 static ngx_http_output_header_filter_pt ngx_http_next_header_filter; |
261 static ngx_http_output_body_filter_pt ngx_http_next_body_filter; | 267 static ngx_http_output_body_filter_pt ngx_http_next_body_filter; |
262 | 268 |
263 | 269 |
264 static ngx_int_t | 270 static ngx_int_t |
274 if (!conf->enable | 280 if (!conf->enable |
275 || (r->headers_out.status != NGX_HTTP_OK | 281 || (r->headers_out.status != NGX_HTTP_OK |
276 && r->headers_out.status != NGX_HTTP_FORBIDDEN | 282 && r->headers_out.status != NGX_HTTP_FORBIDDEN |
277 && r->headers_out.status != NGX_HTTP_NOT_FOUND) | 283 && r->headers_out.status != NGX_HTTP_NOT_FOUND) |
278 || r->header_only | 284 || r->header_only |
285 || r->main | |
279 || r->http_version < conf->http_version | 286 || r->http_version < conf->http_version |
280 || r->headers_out.content_type == NULL | 287 || r->headers_out.content_type.len == 0 |
281 || (r->headers_out.content_encoding | 288 || (r->headers_out.content_encoding |
282 && r->headers_out.content_encoding->value.len) | 289 && r->headers_out.content_encoding->value.len) |
283 || r->headers_in.accept_encoding == NULL | 290 || r->headers_in.accept_encoding == NULL |
284 || (r->headers_out.content_length_n != -1 | 291 || (r->headers_out.content_length_n != -1 |
285 && r->headers_out.content_length_n < conf->min_length) | 292 && r->headers_out.content_length_n < conf->min_length) |
292 | 299 |
293 found = 0; | 300 found = 0; |
294 type = conf->types->elts; | 301 type = conf->types->elts; |
295 | 302 |
296 for (i = 0; i < conf->types->nelts; i++) { | 303 for (i = 0; i < conf->types->nelts; i++) { |
297 if (r->headers_out.content_type->value.len >= type[i].name.len | 304 if (r->headers_out.content_type.len >= type[i].name.len |
298 && ngx_strncasecmp(r->headers_out.content_type->value.data, | 305 && ngx_strncasecmp(r->headers_out.content_type.data, |
299 type[i].name.data, type[i].name.len) == 0) | 306 type[i].name.data, type[i].name.len) == 0) |
300 { | 307 { |
301 found = 1; | 308 found = 1; |
302 break; | 309 break; |
303 } | 310 } |
344 r->headers_out.content_encoding = ngx_list_push(&r->headers_out.headers); | 351 r->headers_out.content_encoding = ngx_list_push(&r->headers_out.headers); |
345 if (r->headers_out.content_encoding == NULL) { | 352 if (r->headers_out.content_encoding == NULL) { |
346 return NGX_ERROR; | 353 return NGX_ERROR; |
347 } | 354 } |
348 | 355 |
356 r->headers_out.content_encoding->hash = 1; | |
349 r->headers_out.content_encoding->key.len = sizeof("Content-Encoding") - 1; | 357 r->headers_out.content_encoding->key.len = sizeof("Content-Encoding") - 1; |
350 r->headers_out.content_encoding->key.data = (u_char *) "Content-Encoding"; | 358 r->headers_out.content_encoding->key.data = (u_char *) "Content-Encoding"; |
351 r->headers_out.content_encoding->value.len = sizeof("gzip") - 1; | 359 r->headers_out.content_encoding->value.len = sizeof("gzip") - 1; |
352 r->headers_out.content_encoding->value.data = (u_char *) "gzip"; | 360 r->headers_out.content_encoding->value.data = (u_char *) "gzip"; |
353 | 361 |
354 ctx->length = r->headers_out.content_length_n; | 362 ctx->length = r->headers_out.content_length_n; |
355 r->headers_out.content_length_n = -1; | 363 r->headers_out.content_length_n = -1; |
364 | |
356 if (r->headers_out.content_length) { | 365 if (r->headers_out.content_length) { |
357 r->headers_out.content_length->key.len = 0; | 366 r->headers_out.content_length->hash = 0; |
358 r->headers_out.content_length = NULL; | 367 r->headers_out.content_length = NULL; |
359 } | 368 } |
369 | |
360 r->filter_need_in_memory = 1; | 370 r->filter_need_in_memory = 1; |
361 | 371 |
362 return ngx_http_next_header_filter(r); | 372 return ngx_http_next_header_filter(r); |
363 } | 373 } |
364 | 374 |
402 } | 412 } |
403 | 413 |
404 return NGX_DECLINED; | 414 return NGX_DECLINED; |
405 } | 415 } |
406 | 416 |
407 if (r->headers_out.cache_control) { | 417 if (r->headers_out.cache_control.elts) { |
408 | 418 |
409 if ((conf->proxied & NGX_HTTP_GZIP_PROXIED_NO_CACHE) | 419 if ((conf->proxied & NGX_HTTP_GZIP_PROXIED_NO_CACHE) |
410 && ngx_strstr(r->headers_out.cache_control->value.data, "no-cache")) | 420 && ngx_http_parse_multi_header_lines(&r->headers_out.cache_control, |
421 &ngx_http_gzip_no_cache, NULL) >= 0) | |
411 { | 422 { |
412 return NGX_OK; | 423 return NGX_OK; |
413 } | 424 } |
414 | 425 |
415 if ((conf->proxied & NGX_HTTP_GZIP_PROXIED_NO_STORE) | 426 if ((conf->proxied & NGX_HTTP_GZIP_PROXIED_NO_STORE) |
416 && ngx_strstr(r->headers_out.cache_control->value.data, "no-store")) | 427 && ngx_http_parse_multi_header_lines(&r->headers_out.cache_control, |
428 &ngx_http_gzip_no_store, NULL) >= 0) | |
417 { | 429 { |
418 return NGX_OK; | 430 return NGX_OK; |
419 } | 431 } |
420 | 432 |
421 if ((conf->proxied & NGX_HTTP_GZIP_PROXIED_PRIVATE) | 433 if ((conf->proxied & NGX_HTTP_GZIP_PROXIED_PRIVATE) |
422 && ngx_strstr(r->headers_out.cache_control->value.data, "private")) | 434 && ngx_http_parse_multi_header_lines(&r->headers_out.cache_control, |
435 &ngx_http_gzip_private, NULL) >= 0) | |
423 { | 436 { |
424 return NGX_OK; | 437 return NGX_OK; |
425 } | 438 } |
426 | 439 |
427 return NGX_DECLINED; | 440 return NGX_DECLINED; |
482 * decreases a number of syscalls (sbrk() and so on). | 495 * decreases a number of syscalls (sbrk() and so on). |
483 * Besides we free this memory as soon as the gzipping will complete | 496 * Besides we free this memory as soon as the gzipping will complete |
484 * and do not wait while a whole response will be sent to a client. | 497 * and do not wait while a whole response will be sent to a client. |
485 * | 498 * |
486 * 8K is for zlib deflate_state, it takes | 499 * 8K is for zlib deflate_state, it takes |
487 * * 5816 bytes on x86 and sparc64 (32-bit mode) | 500 * *) 5816 bytes on i386 and sparc64 (32-bit mode) |
488 * * 5920 bytes on amd64 and sparc64 | 501 * *) 5920 bytes on amd64 and sparc64 |
489 */ | 502 */ |
490 | 503 |
491 ctx->allocated = 8192 + (1 << (wbits + 2)) + (1 << (memlevel + 9)); | 504 ctx->allocated = 8192 + (1 << (wbits + 2)) + (1 << (memlevel + 9)); |
492 | 505 |
493 ctx->preallocated = ngx_palloc(r->pool, ctx->allocated); | 506 ctx->preallocated = ngx_palloc(r->pool, ctx->allocated); |
694 | 707 |
695 ctx->redo = 0; | 708 ctx->redo = 0; |
696 | 709 |
697 if (ctx->flush == Z_SYNC_FLUSH) { | 710 if (ctx->flush == Z_SYNC_FLUSH) { |
698 | 711 |
699 ctx->out_buf->flush = 0; | 712 ctx->zstream.avail_out = 0; |
713 ctx->out_buf->flush = 1; | |
700 ctx->flush = Z_NO_FLUSH; | 714 ctx->flush = Z_NO_FLUSH; |
701 | 715 |
702 cl = ngx_alloc_chain_link(r->pool); | 716 cl = ngx_alloc_chain_link(r->pool); |
703 if (cl == NULL) { | 717 if (cl == NULL) { |
704 ngx_http_gzip_error(ctx); | 718 ngx_http_gzip_error(ctx); |