diff options
| author | Igor Sysoev <igor@sysoev.ru> | 2005-10-24 15:09:41 +0000 |
|---|---|---|
| committer | Igor Sysoev <igor@sysoev.ru> | 2005-10-24 15:09:41 +0000 |
| commit | 9ac946bcc9f8f3735af8eb253c1e89f177db5827 (patch) | |
| tree | 0d42898bfbe5931131d4544699b18c9d697d2cef /src/http/modules | |
| parent | 51d8bcc28b729a8a3056a0c98e2c44e466351141 (diff) | |
| download | nginx-release-0.3.6.tar.gz nginx-release-0.3.6.tar.bz2 | |
nginx-0.3.6-RELEASE importrelease-0.3.6
*) Change: now the IMAP/POP3 proxy do not send the empty login to
authorization server.
*) Feature: the "log_format" supports the variables in the $name form.
*) Bugfix: if at least in one server was no the "listen" directive,
then nginx did not listen on the 80 port; the bug had appeared in
0.3.3.
*) Bugfix: if the URI part is omitted in "proxy_pass" directive, the
the 80 port was always used.
Diffstat (limited to '')
| -rw-r--r-- | src/http/modules/ngx_http_log_module.c (renamed from src/http/ngx_http_log_module.c) | 125 | ||||
| -rw-r--r-- | src/http/modules/ngx_http_log_module.h (renamed from src/http/ngx_http_log_module.h) | 0 | ||||
| -rw-r--r-- | src/http/modules/ngx_http_ssi_filter_module.c | 16 |
3 files changed, 112 insertions, 29 deletions
diff --git a/src/http/ngx_http_log_module.c b/src/http/modules/ngx_http_log_module.c index 617d46a7f..6e7772e56 100644 --- a/src/http/ngx_http_log_module.c +++ b/src/http/modules/ngx_http_log_module.c @@ -83,6 +83,7 @@ static char *ngx_http_log_set_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); static char *ngx_http_log_set_format(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); +static ngx_int_t ngx_http_log_init(ngx_cycle_t *cycle); static ngx_command_t ngx_http_log_commands[] = { @@ -126,7 +127,7 @@ ngx_module_t ngx_http_log_module = { ngx_http_log_commands, /* module directives */ NGX_HTTP_MODULE, /* module type */ NULL, /* init master */ - NULL, /* init module */ + ngx_http_log_init, /* init module */ NULL, /* init process */ NULL, /* init thread */ NULL, /* exit thread */ @@ -140,8 +141,14 @@ static ngx_str_t http_access_log = ngx_string(NGX_HTTP_LOG_PATH); static ngx_str_t ngx_http_combined_fmt = - ngx_string("%addr - - [%time] \"%request\" %status %apache_length " - "\"%{Referer}i\" \"%{User-Agent}i\""); +#if 0 + ngx_string("$remote_addr - $remote_user [%time] " + "\"$request\" %status %apache_length " + "\"$http_referer\" \"$http_user_agent\""); +#endif + ngx_string("%addr - - [%time] " + "\"%request\" %status %apache_length " + "\"%{referer}i\" \"%{user-agent}i\""); ngx_http_log_op_name_t ngx_http_log_fmt_ops[] = { @@ -824,7 +831,7 @@ ngx_http_log_create_main_conf(ngx_conf_t *cf) } if (ngx_array_init(&conf->formats, cf->pool, 4, sizeof(ngx_http_log_fmt_t)) - == NGX_ERROR) + == NGX_ERROR) { return NGX_CONF_ERROR; } @@ -836,6 +843,9 @@ ngx_http_log_create_main_conf(ngx_conf_t *cf) return NGX_CONF_ERROR; } + value->len = 0; + value->data = NULL; + value = ngx_array_push(cf->args); if (value == NULL) { return NGX_CONF_ERROR; @@ -853,7 +863,7 @@ ngx_http_log_create_main_conf(ngx_conf_t *cf) rc = ngx_http_log_set_format(cf, NULL, conf); if (rc != NGX_CONF_OK) { - return NULL; + return NGX_CONF_ERROR; } return conf; @@ -993,10 +1003,10 @@ ngx_http_log_set_format(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) { ngx_http_log_main_conf_t *lmcf = conf; - ngx_uint_t s, f, invalid; - u_char *data, *p, *fname; + u_char *data, *p, *fname, ch; size_t i, len, fname_len; - ngx_str_t *value, arg, *a; + ngx_str_t *value, var, arg, *a; + ngx_uint_t s, f, bracket; ngx_http_log_op_t *op; ngx_http_log_fmt_t *fmt; ngx_http_log_op_name_t *name; @@ -1024,11 +1034,9 @@ ngx_http_log_set_format(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) return NGX_CONF_ERROR; } - invalid = 0; - data = NULL; arg.data = NULL; - for (s = 2; s < cf->args->nelts && !invalid; s++) { + for (s = 2; s < cf->args->nelts; s++) { i = 0; @@ -1045,8 +1053,7 @@ ngx_http_log_set_format(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) i++; if (i == value[s].len) { - invalid = 1; - break; + goto invalid; } if (value[s].data[i] == '{') { @@ -1061,8 +1068,7 @@ ngx_http_log_set_format(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) arg.len = &value[s].data[i] - arg.data; if (i == value[s].len || arg.len == 0) { - invalid = 1; - break; + goto invalid; } i++; @@ -1083,8 +1089,7 @@ ngx_http_log_set_format(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) fname_len = &value[s].data[i] - fname; if (fname_len == 0) { - invalid = 1; - break; + goto invalid; } for (name = ngx_http_log_fmt_ops; name->run; name++) { @@ -1135,14 +1140,71 @@ ngx_http_log_set_format(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) } if (name->name.len == 0) { - invalid = 1; + goto invalid; + } + + } else if (value[s].data[i] == '$') { + + if (++i == value[s].len) { + goto invalid; + } + + if (value[s].data[i] == '{') { + bracket = 1; + + if (++i == value[s].len) { + goto invalid; + } + + var.data = &value[s].data[i]; + + } else { + bracket = 0; + var.data = &value[s].data[i]; + } + + for (var.len = 0; i < value[s].len; i++, var.len++) { + ch = value[s].data[i]; + + if (ch == '}' && bracket) { + i++; + bracket = 0; + break; + } + + if ((ch >= 'A' && ch <= 'Z') + || (ch >= 'a' && ch <= 'z') + || (ch >= '0' && ch <= '9') + || ch == '_') + { + continue; + } + break; } + if (bracket) { + ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, + "the closing bracket in \"%V\" " + "variable is missing", &var); + return NGX_CONF_ERROR; + } + + if (var.len == 0) { + goto invalid; + } + + if (ngx_http_log_variable_compile(cf, op, &var) != NGX_OK) { + return NGX_CONF_ERROR; + } + } else { i++; - while (i < value[s].len && value[s].data[i] != '%') { + while (i < value[s].len + && value[s].data[i] != '$' + && value[s].data[i] != '%') + { i++; } @@ -1178,11 +1240,24 @@ ngx_http_log_set_format(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) } } - if (invalid) { - ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, - "invalid parameter \"%s\"", data); - return NGX_CONF_ERROR; - } - return NGX_CONF_OK; + +invalid: + + ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "invalid parameter \"%s\"", data); + + return NGX_CONF_ERROR; +} + + +static ngx_int_t +ngx_http_log_init(ngx_cycle_t *cycle) +{ + ngx_http_core_main_conf_t *cmcf; + + cmcf = ngx_http_cycle_get_module_main_conf(cycle, ngx_http_core_module); + + cmcf->log_handler = ngx_http_log_handler; + + return NGX_OK; } diff --git a/src/http/ngx_http_log_module.h b/src/http/modules/ngx_http_log_module.h index c414bc4ac..c414bc4ac 100644 --- a/src/http/ngx_http_log_module.h +++ b/src/http/modules/ngx_http_log_module.h diff --git a/src/http/modules/ngx_http_ssi_filter_module.c b/src/http/modules/ngx_http_ssi_filter_module.c index af82b0e8b..80de6910c 100644 --- a/src/http/modules/ngx_http_ssi_filter_module.c +++ b/src/http/modules/ngx_http_ssi_filter_module.c @@ -229,9 +229,8 @@ ngx_module_t ngx_http_ssi_filter_module = { }; -static ngx_int_t (*ngx_http_next_header_filter) (ngx_http_request_t *r); -static ngx_int_t (*ngx_http_next_body_filter) (ngx_http_request_t *r, - ngx_chain_t *in); +static ngx_http_output_header_filter_pt ngx_http_next_header_filter; +static ngx_http_output_body_filter_pt ngx_http_next_body_filter; static u_char ngx_http_ssi_string[] = "<!--"; @@ -407,6 +406,7 @@ ngx_http_ssi_body_filter(ngx_http_request_t *r, ngx_chain_t *in) ngx_buf_t *b; ngx_chain_t *cl; ngx_table_elt_t *param; + ngx_connection_t *c; ngx_http_ssi_ctx_t *ctx; ngx_http_ssi_conf_t *conf; ngx_http_ssi_param_t *prm; @@ -650,7 +650,15 @@ ngx_http_ssi_body_filter(ngx_http_request_t *r, ngx_chain_t *in) } } - if (cmd->handler(r, ctx, params) == NGX_OK) { + c = r->connection; + + rc = cmd->handler(r, ctx, params); + + if (c->closed) { + return NGX_DONE; + } + + if (rc == NGX_OK) { continue; } } |
