From fa7d06ee4f31823f65c5aecea3a273940770bc9d Mon Sep 17 00:00:00 2001 From: Igor Sysoev Date: Thu, 22 Apr 2010 14:02:45 +0000 Subject: [PATCH] change processing variables accessed by SSI and perl module: *) the indexed variables are always flushed *) never show warning for not found variables --- src/http/modules/ngx_http_ssi_filter_module.c | 8 +++----- src/http/modules/perl/nginx.xs | 2 +- src/http/ngx_http_variables.c | 10 ++-------- src/http/ngx_http_variables.h | 2 +- 4 files changed, 7 insertions(+), 15 deletions(-) diff --git a/src/http/modules/ngx_http_ssi_filter_module.c b/src/http/modules/ngx_http_ssi_filter_module.c index 3f3899ae9..7a2beede1 100644 --- a/src/http/modules/ngx_http_ssi_filter_module.c +++ b/src/http/modules/ngx_http_ssi_filter_module.c @@ -14,7 +14,6 @@ #define NGX_HTTP_SSI_ADD_PREFIX 1 #define NGX_HTTP_SSI_ADD_ZERO 2 -#define NGX_HTTP_SSI_EXPR_TEST 4 typedef struct { @@ -1701,8 +1700,7 @@ ngx_http_ssi_evaluate_string(ngx_http_request_t *r, ngx_http_ssi_ctx_t *ctx, val = ngx_http_ssi_get_variable(r, &var, key); if (val == NULL) { - vv = ngx_http_get_variable(r, &var, key, - flags & NGX_HTTP_SSI_EXPR_TEST); + vv = ngx_http_get_variable(r, &var, key); if (vv == NULL) { return NGX_ERROR; } @@ -2110,7 +2108,7 @@ ngx_http_ssi_echo(ngx_http_request_t *r, ngx_http_ssi_ctx_t *ctx, value = ngx_http_ssi_get_variable(r, var, key); if (value == NULL) { - vv = ngx_http_get_variable(r, var, key, 1); + vv = ngx_http_get_variable(r, var, key); if (vv == NULL) { return NGX_HTTP_SSI_ERROR; @@ -2361,7 +2359,7 @@ ngx_http_ssi_if(ngx_http_request_t *r, ngx_http_ssi_ctx_t *ctx, p++; } - flags = (p == last) ? NGX_HTTP_SSI_EXPR_TEST : 0; + flags = 0; ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "left: \"%V\"", &left); diff --git a/src/http/modules/perl/nginx.xs b/src/http/modules/perl/nginx.xs index 357b1b9ae..aef4c8b03 100644 --- a/src/http/modules/perl/nginx.xs +++ b/src/http/modules/perl/nginx.xs @@ -848,7 +848,7 @@ variable(r, name, value = NULL) #endif - vv = ngx_http_get_variable(r, &var, hash, 1); + vv = ngx_http_get_variable(r, &var, hash); if (vv == NULL) { XSRETURN_UNDEF; } diff --git a/src/http/ngx_http_variables.c b/src/http/ngx_http_variables.c index eee997b19..c8d1c8dcb 100644 --- a/src/http/ngx_http_variables.c +++ b/src/http/ngx_http_variables.c @@ -441,8 +441,7 @@ ngx_http_get_flushed_variable(ngx_http_request_t *r, ngx_uint_t index) ngx_http_variable_value_t * -ngx_http_get_variable(ngx_http_request_t *r, ngx_str_t *name, ngx_uint_t key, - ngx_uint_t nowarn) +ngx_http_get_variable(ngx_http_request_t *r, ngx_str_t *name, ngx_uint_t key) { ngx_http_variable_t *v; ngx_http_variable_value_t *vv; @@ -454,7 +453,7 @@ ngx_http_get_variable(ngx_http_request_t *r, ngx_str_t *name, ngx_uint_t key, if (v) { if (v->flags & NGX_HTTP_VAR_INDEXED) { - return ngx_http_get_indexed_variable(r, v->index); + return ngx_http_get_flushed_variable(r, v->index); } else { @@ -526,11 +525,6 @@ ngx_http_get_variable(ngx_http_request_t *r, ngx_str_t *name, ngx_uint_t key, vv->not_found = 1; - if (nowarn == 0) { - ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, - "unknown \"%V\" variable", name); - } - return vv; } diff --git a/src/http/ngx_http_variables.h b/src/http/ngx_http_variables.h index 80ce49321..9d4b29e08 100644 --- a/src/http/ngx_http_variables.h +++ b/src/http/ngx_http_variables.h @@ -50,7 +50,7 @@ ngx_http_variable_value_t *ngx_http_get_flushed_variable(ngx_http_request_t *r, ngx_uint_t index); ngx_http_variable_value_t *ngx_http_get_variable(ngx_http_request_t *r, - ngx_str_t *name, ngx_uint_t key, ngx_uint_t nowarn); + ngx_str_t *name, ngx_uint_t key); ngx_int_t ngx_http_variable_unknown_header(ngx_http_variable_value_t *v, ngx_str_t *var, ngx_list_part_t *part, size_t prefix);