Mercurial > hg > nginx-vendor-1-0
comparison src/http/modules/ngx_http_gzip_filter_module.c @ 122:d25a1d6034f1 NGINX_0_3_8
nginx 0.3.8
*) Security: nginx now checks URI got from a backend in
"X-Accel-Redirect" header line or in SSI file for the "/../" paths
and zeroes.
*) Change: nginx now does not treat the empty user name in the
"Authorization" header line as valid one.
*) Feature: the "ssl_session_timeout" directives of the
ngx_http_ssl_module and ngx_imap_ssl_module.
*) Feature: the "auth_http_header" directive of the
ngx_imap_auth_http_module.
*) Feature: the "add_header" directive.
*) Feature: the ngx_http_realip_module.
*) Feature: the new variables to use in the "log_format" directive:
$bytes_sent, $apache_bytes_sent, $status, $time_gmt, $uri,
$request_time, $request_length, $upstream_status,
$upstream_response_time, $gzip_ratio, $uid_got, $uid_set,
$connection, $pipe, and $msec. The parameters in the "%name" form
will be canceled soon.
*) Change: now the false variable values in the "if" directive are the
empty string "" and string starting with "0".
*) Bugfix: while using proxied or FastCGI-server nginx may leave
connections and temporary files with client requests in open state.
*) Bugfix: the worker processes did not flush the buffered logs on
graceful exit.
*) Bugfix: if the request URI was changes by the "rewrite" directive
and the request was proxied in location given by regular expression,
then the incorrect request was transferred to backend; bug appeared
in 0.2.6.
*) Bugfix: the "expires" directive did not remove the previous
"Expires" header.
*) Bugfix: nginx may stop to accept requests if the "rtsig" method and
several worker processes were used.
*) Bugfix: the "\"" and "\'" escape symbols were incorrectly handled in
SSI commands.
*) Bugfix: if the response was ended just after the SSI command and
gzipping was used, then the response did not transferred complete or
did not transferred at all.
author | Igor Sysoev <http://sysoev.ru> |
---|---|
date | Wed, 09 Nov 2005 00:00:00 +0300 |
parents | f63280c59dd5 |
children | df17fbafec8f |
comparison
equal
deleted
inserted
replaced
121:737953b238a4 | 122:d25a1d6034f1 |
---|---|
77 static void ngx_http_gzip_error(ngx_http_gzip_ctx_t *ctx); | 77 static void ngx_http_gzip_error(ngx_http_gzip_ctx_t *ctx); |
78 | 78 |
79 static u_char *ngx_http_gzip_log_ratio(ngx_http_request_t *r, u_char *buf, | 79 static u_char *ngx_http_gzip_log_ratio(ngx_http_request_t *r, u_char *buf, |
80 ngx_http_log_op_t *op); | 80 ngx_http_log_op_t *op); |
81 | 81 |
82 static ngx_int_t ngx_http_gzip_add_log_formats(ngx_conf_t *cf); | 82 static ngx_int_t ngx_http_gzip_add_variables(ngx_conf_t *cf); |
83 static ngx_int_t ngx_http_gzip_ratio_variable(ngx_http_request_t *r, | |
84 ngx_http_variable_value_t *v, uintptr_t data); | |
83 | 85 |
84 static ngx_int_t ngx_http_gzip_filter_init(ngx_cycle_t *cycle); | 86 static ngx_int_t ngx_http_gzip_filter_init(ngx_cycle_t *cycle); |
85 static void *ngx_http_gzip_create_conf(ngx_conf_t *cf); | 87 static void *ngx_http_gzip_create_conf(ngx_conf_t *cf); |
86 static char *ngx_http_gzip_merge_conf(ngx_conf_t *cf, | 88 static char *ngx_http_gzip_merge_conf(ngx_conf_t *cf, |
87 void *parent, void *child); | 89 void *parent, void *child); |
197 ngx_null_command | 199 ngx_null_command |
198 }; | 200 }; |
199 | 201 |
200 | 202 |
201 static ngx_http_module_t ngx_http_gzip_filter_module_ctx = { | 203 static ngx_http_module_t ngx_http_gzip_filter_module_ctx = { |
202 ngx_http_gzip_add_log_formats, /* preconfiguration */ | 204 ngx_http_gzip_add_variables, /* preconfiguration */ |
203 NULL, /* postconfiguration */ | 205 NULL, /* postconfiguration */ |
204 | 206 |
205 NULL, /* create main configuration */ | 207 NULL, /* create main configuration */ |
206 NULL, /* init main configuration */ | 208 NULL, /* init main configuration */ |
207 | 209 |
254 }; | 256 }; |
255 | 257 |
256 #endif | 258 #endif |
257 | 259 |
258 | 260 |
261 static ngx_str_t ngx_http_gzip_ratio = ngx_string("gzip_ratio"); | |
259 static ngx_str_t ngx_http_gzip_no_cache = ngx_string("no-cache"); | 262 static ngx_str_t ngx_http_gzip_no_cache = ngx_string("no-cache"); |
260 static ngx_str_t ngx_http_gzip_no_store = ngx_string("no-store"); | 263 static ngx_str_t ngx_http_gzip_no_store = ngx_string("no-store"); |
261 static ngx_str_t ngx_http_gzip_private = ngx_string("private"); | 264 static ngx_str_t ngx_http_gzip_private = ngx_string("private"); |
262 | 265 |
263 | 266 |
954 return; | 957 return; |
955 } | 958 } |
956 | 959 |
957 | 960 |
958 static ngx_int_t | 961 static ngx_int_t |
959 ngx_http_gzip_add_log_formats(ngx_conf_t *cf) | 962 ngx_http_gzip_add_variables(ngx_conf_t *cf) |
960 { | 963 { |
964 ngx_http_variable_t *var; | |
961 ngx_http_log_op_name_t *op; | 965 ngx_http_log_op_name_t *op; |
966 | |
967 var = ngx_http_add_variable(cf, &ngx_http_gzip_ratio, 0); | |
968 if (var == NULL) { | |
969 return NGX_ERROR; | |
970 } | |
971 | |
972 var->handler = ngx_http_gzip_ratio_variable; | |
962 | 973 |
963 for (op = ngx_http_gzip_log_fmt_ops; op->name.len; op++) { /* void */ } | 974 for (op = ngx_http_gzip_log_fmt_ops; op->name.len; op++) { /* void */ } |
964 op->run = NULL; | 975 op->run = NULL; |
965 | 976 |
966 for (op = ngx_http_log_fmt_ops; op->run; op++) { | 977 for (op = ngx_http_log_fmt_ops; op->run; op++) { |
968 op = (ngx_http_log_op_name_t *) op->run; | 979 op = (ngx_http_log_op_name_t *) op->run; |
969 } | 980 } |
970 } | 981 } |
971 | 982 |
972 op->run = (ngx_http_log_op_run_pt) ngx_http_gzip_log_fmt_ops; | 983 op->run = (ngx_http_log_op_run_pt) ngx_http_gzip_log_fmt_ops; |
984 | |
985 return NGX_OK; | |
986 } | |
987 | |
988 | |
989 static ngx_int_t | |
990 ngx_http_gzip_ratio_variable(ngx_http_request_t *r, | |
991 ngx_http_variable_value_t *v, uintptr_t data) | |
992 { | |
993 ngx_uint_t zint, zfrac; | |
994 ngx_http_gzip_ctx_t *ctx; | |
995 | |
996 v->valid = 1; | |
997 v->no_cachable = 0; | |
998 v->not_found = 0; | |
999 | |
1000 ctx = ngx_http_get_module_ctx(r, ngx_http_gzip_filter_module); | |
1001 | |
1002 if (ctx == NULL || ctx->zout == 0) { | |
1003 v->not_found = 1; | |
1004 return NGX_OK; | |
1005 } | |
1006 | |
1007 v->data = ngx_palloc(r->pool, NGX_INT32_LEN + 3); | |
1008 if (v->data == NULL) { | |
1009 return NGX_ERROR; | |
1010 } | |
1011 | |
1012 zint = (ngx_uint_t) (ctx->zin / ctx->zout); | |
1013 zfrac = (ngx_uint_t) ((ctx->zin * 100 / ctx->zout) % 100); | |
1014 | |
1015 if ((ctx->zin * 1000 / ctx->zout) % 10 > 4) { | |
1016 | |
1017 /* the rounding, e.g., 2.125 to 2.13 */ | |
1018 | |
1019 zfrac++; | |
1020 | |
1021 if (zfrac > 99) { | |
1022 zint++; | |
1023 zfrac = 0; | |
1024 } | |
1025 } | |
1026 | |
1027 v->len = ngx_sprintf(v->data, "%ui.%02ui", zint, zfrac) - v->data; | |
973 | 1028 |
974 return NGX_OK; | 1029 return NGX_OK; |
975 } | 1030 } |
976 | 1031 |
977 | 1032 |