Mercurial > hg > nginx-vendor-0-6
comparison src/http/modules/ngx_http_gzip_filter_module.c @ 260:0effe91f6083 NGINX_0_5_0
nginx 0.5.0
*) Change: the parameters in the "%name" form in the "log_format"
directive are not supported anymore.
*) Change: the "proxy_upstream_max_fails",
"proxy_upstream_fail_timeout", "fastcgi_upstream_max_fails",
"fastcgi_upstream_fail_timeout", "memcached_upstream_max_fails", and
"memcached_upstream_fail_timeout" directives are not supported
anymore.
*) Feature: the "server" directive in the "upstream" context supports
the "max_fails", "fail_timeout", and "down" parameters.
*) Feature: the "ip_hash" directive inside the "upstream" block.
*) Feature: the WAIT status in the "Auth-Status" header line of the
IMAP/POP3 proxy authentication server response.
*) Bugfix: nginx could not be built on 64-bit platforms; bug appeared
in 0.4.14.
author | Igor Sysoev <http://sysoev.ru> |
---|---|
date | Mon, 04 Dec 2006 00:00:00 +0300 |
parents | 38e7b94d63ac |
children | 10cc350ed8a1 |
comparison
equal
deleted
inserted
replaced
259:c68f18041059 | 260:0effe91f6083 |
---|---|
73 ngx_http_gzip_conf_t *conf); | 73 ngx_http_gzip_conf_t *conf); |
74 static void *ngx_http_gzip_filter_alloc(void *opaque, u_int items, | 74 static void *ngx_http_gzip_filter_alloc(void *opaque, u_int items, |
75 u_int size); | 75 u_int size); |
76 static void ngx_http_gzip_filter_free(void *opaque, void *address); | 76 static void ngx_http_gzip_filter_free(void *opaque, void *address); |
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 | |
79 static u_char *ngx_http_gzip_log_ratio(ngx_http_request_t *r, u_char *buf, | |
80 ngx_http_log_op_t *op); | |
81 | 78 |
82 static ngx_int_t ngx_http_gzip_add_variables(ngx_conf_t *cf); | 79 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, | 80 static ngx_int_t ngx_http_gzip_ratio_variable(ngx_http_request_t *r, |
84 ngx_http_variable_value_t *v, uintptr_t data); | 81 ngx_http_variable_value_t *v, uintptr_t data); |
85 | 82 |
226 NULL, /* exit thread */ | 223 NULL, /* exit thread */ |
227 NULL, /* exit process */ | 224 NULL, /* exit process */ |
228 NULL, /* exit master */ | 225 NULL, /* exit master */ |
229 NGX_MODULE_V1_PADDING | 226 NGX_MODULE_V1_PADDING |
230 }; | 227 }; |
231 | |
232 | |
233 static ngx_http_log_op_name_t ngx_http_gzip_log_fmt_ops[] = { | |
234 { ngx_string("gzip_ratio"), NGX_INT32_LEN + 3, | |
235 NULL, NULL, ngx_http_gzip_log_ratio }, | |
236 { ngx_null_string, 0, NULL, NULL, NULL } | |
237 }; | |
238 | |
239 | 228 |
240 | 229 |
241 static u_char gzheader[10] = { 0x1f, 0x8b, Z_DEFLATED, 0, 0, 0, 0, 0, 0, 3 }; | 230 static u_char gzheader[10] = { 0x1f, 0x8b, Z_DEFLATED, 0, 0, 0, 0, 0, 0, 3 }; |
242 | 231 |
243 #if (NGX_HAVE_LITTLE_ENDIAN && NGX_HAVE_NONALIGNED) | 232 #if (NGX_HAVE_LITTLE_ENDIAN && NGX_HAVE_NONALIGNED) |
905 "gzip free: %p", address); | 894 "gzip free: %p", address); |
906 #endif | 895 #endif |
907 } | 896 } |
908 | 897 |
909 | 898 |
910 static u_char * | |
911 ngx_http_gzip_log_ratio(ngx_http_request_t *r, u_char *buf, | |
912 ngx_http_log_op_t *op) | |
913 { | |
914 ngx_uint_t zint, zfrac; | |
915 ngx_http_gzip_ctx_t *ctx; | |
916 | |
917 ctx = ngx_http_get_module_ctx(r, ngx_http_gzip_filter_module); | |
918 | |
919 if (ctx == NULL || ctx->zout == 0) { | |
920 *buf = '-'; | |
921 return buf + 1; | |
922 } | |
923 | |
924 zint = (ngx_uint_t) (ctx->zin / ctx->zout); | |
925 zfrac = (ngx_uint_t) ((ctx->zin * 100 / ctx->zout) % 100); | |
926 | |
927 if ((ctx->zin * 1000 / ctx->zout) % 10 > 4) { | |
928 | |
929 /* the rounding, e.g., 2.125 to 2.13 */ | |
930 | |
931 zfrac++; | |
932 | |
933 if (zfrac > 99) { | |
934 zint++; | |
935 zfrac = 0; | |
936 } | |
937 } | |
938 | |
939 return ngx_sprintf(buf, "%ui.%02ui", zint, zfrac); | |
940 } | |
941 | |
942 | |
943 static void | 899 static void |
944 ngx_http_gzip_error(ngx_http_gzip_ctx_t *ctx) | 900 ngx_http_gzip_error(ngx_http_gzip_ctx_t *ctx) |
945 { | 901 { |
946 deflateEnd(&ctx->zstream); | 902 deflateEnd(&ctx->zstream); |
947 | 903 |
959 | 915 |
960 | 916 |
961 static ngx_int_t | 917 static ngx_int_t |
962 ngx_http_gzip_add_variables(ngx_conf_t *cf) | 918 ngx_http_gzip_add_variables(ngx_conf_t *cf) |
963 { | 919 { |
964 ngx_http_variable_t *var; | 920 ngx_http_variable_t *var; |
965 ngx_http_log_op_name_t *op; | |
966 | 921 |
967 var = ngx_http_add_variable(cf, &ngx_http_gzip_ratio, NGX_HTTP_VAR_NOHASH); | 922 var = ngx_http_add_variable(cf, &ngx_http_gzip_ratio, NGX_HTTP_VAR_NOHASH); |
968 if (var == NULL) { | 923 if (var == NULL) { |
969 return NGX_ERROR; | 924 return NGX_ERROR; |
970 } | 925 } |
971 | 926 |
972 var->get_handler = ngx_http_gzip_ratio_variable; | 927 var->get_handler = ngx_http_gzip_ratio_variable; |
973 | |
974 for (op = ngx_http_gzip_log_fmt_ops; op->name.len; op++) { /* void */ } | |
975 op->run = NULL; | |
976 | |
977 for (op = ngx_http_log_fmt_ops; op->run; op++) { | |
978 if (op->name.len == 0) { | |
979 op = (ngx_http_log_op_name_t *) op->run; | |
980 } | |
981 } | |
982 | |
983 op->run = (ngx_http_log_op_run_pt) ngx_http_gzip_log_fmt_ops; | |
984 | 928 |
985 return NGX_OK; | 929 return NGX_OK; |
986 } | 930 } |
987 | 931 |
988 | 932 |