diff options
author | Igor Sysoev <igor@sysoev.ru> | 2005-05-19 17:25:22 +0400 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2005-05-19 17:25:22 +0400 |
commit | e31e90b3e10ca2afafccae9a57910133d93b2d37 (patch) | |
tree | 7177a8f48a555733b170bfcad4e9e7072ea8c027 /src/http/modules | |
parent | b1a641cafa2ef042035155f68e5f571303853dfc (diff) |
nginx-0.1.32-RELEASE importrelease-0.1.32
*) Bugfix: the arguments were omitted in the redirects, issued by the
"rewrite" directive; the bug had appeared in 0.1.29.
*) Feature: the "if" directive supports the captures in regular
expressions.
*) Feature: the "set" directive supports the variables and the captures
of regular expressions.
*) Feature: the "X-Accel-Redirect" response header line is supported in
proxy and FastCGI mode.
Diffstat (limited to 'src/http/modules')
-rw-r--r-- | src/http/modules/ngx_http_fastcgi_module.c | 2 | ||||
-rw-r--r-- | src/http/modules/ngx_http_proxy_module.c | 4 | ||||
-rw-r--r-- | src/http/modules/ngx_http_rewrite_module.c | 95 |
3 files changed, 68 insertions, 33 deletions
diff --git a/src/http/modules/ngx_http_fastcgi_module.c b/src/http/modules/ngx_http_fastcgi_module.c index cf9d008a5..0e74528d7 100644 --- a/src/http/modules/ngx_http_fastcgi_module.c +++ b/src/http/modules/ngx_http_fastcgi_module.c @@ -33,7 +33,7 @@ typedef enum { ngx_http_fastcgi_st_padding_length, ngx_http_fastcgi_st_reserved, ngx_http_fastcgi_st_data, - ngx_http_fastcgi_st_padding, + ngx_http_fastcgi_st_padding } ngx_http_fastcgi_state_e; diff --git a/src/http/modules/ngx_http_proxy_module.c b/src/http/modules/ngx_http_proxy_module.c index 5504610e6..a24be2444 100644 --- a/src/http/modules/ngx_http_proxy_module.c +++ b/src/http/modules/ngx_http_proxy_module.c @@ -542,7 +542,9 @@ ngx_http_proxy_create_request(ngx_http_request_t *r) while (*(uintptr_t *) le.ip) { lcode = *(ngx_http_script_len_code_pt *) le.ip; - lcode(&le); + + /* skip the header line name length */ + (void) lcode(&le); if (*(ngx_http_script_len_code_pt *) le.ip) { diff --git a/src/http/modules/ngx_http_rewrite_module.c b/src/http/modules/ngx_http_rewrite_module.c index 2dc7a7fff..47ff8c536 100644 --- a/src/http/modules/ngx_http_rewrite_module.c +++ b/src/http/modules/ngx_http_rewrite_module.c @@ -16,16 +16,10 @@ typedef struct { typedef struct { - ngx_str_t *name; - ngx_http_variable_value_t *value; -} ngx_http_rewrite_variable_t; - - -typedef struct { ngx_array_t *codes; /* uintptr_t */ ngx_array_t *referers; /* ngx_http_rewrite_referer_t */ - ngx_uint_t max_captures; + ngx_uint_t captures; ngx_uint_t stack_size; ngx_flag_t log; @@ -159,8 +153,8 @@ ngx_http_rewrite_handler(ngx_http_request_t *r) return NGX_HTTP_INTERNAL_SERVER_ERROR; } - if (cf->max_captures) { - e->captures = ngx_palloc(r->pool, cf->max_captures * sizeof(int)); + if (cf->captures) { + e->captures = ngx_palloc(r->pool, cf->captures * sizeof(int)); if (e->captures == NULL) { return NGX_HTTP_INTERNAL_SERVER_ERROR; } @@ -542,10 +536,10 @@ ngx_http_rewrite(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) if (regex->ncaptures) { regex->ncaptures = (regex->ncaptures + 1) * 3; - } - if (lcf->max_captures < regex->ncaptures) { - lcf->max_captures = regex->ncaptures; + if (lcf->captures < regex->ncaptures) { + lcf->captures = regex->ncaptures; + } } regex_end = ngx_http_script_add_code(lcf->codes, @@ -735,7 +729,7 @@ static char * ngx_http_rewrite_if_condition(ngx_conf_t *cf, ngx_http_rewrite_loc_conf_t *lcf) { ngx_str_t *value, err; - ngx_uint_t cur, last; + ngx_uint_t cur, last, n; ngx_http_script_regex_code_t *regex; u_char errstr[NGX_MAX_CONF_ERRSTR]; @@ -823,6 +817,16 @@ ngx_http_rewrite_if_condition(ngx_conf_t *cf, ngx_http_rewrite_loc_conf_t *lcf) regex->test = 1; regex->name = value[last]; + n = ngx_regex_capture_count(regex->regex); + + if (n) { + regex->ncaptures = (n + 1) * 3; + + if (lcf->captures < regex->ncaptures) { + lcf->captures = regex->ncaptures; + } + } + return NGX_CONF_OK; } @@ -977,11 +981,13 @@ ngx_http_rewrite_set(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) { ngx_http_rewrite_loc_conf_t *lcf = conf; - ngx_int_t n, index; - ngx_str_t *value; - ngx_http_variable_t *v; - ngx_http_script_var_code_t *var; - ngx_http_script_value_code_t *val; + ngx_int_t n, index; + ngx_str_t *value; + ngx_http_variable_t *v; + ngx_http_script_compile_t sc; + ngx_http_script_var_code_t *var; + ngx_http_script_value_code_t *val; + ngx_http_script_complex_value_code_t *complex; value = cf->args->elts; @@ -1007,22 +1013,49 @@ ngx_http_rewrite_set(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) v->handler = ngx_http_rewrite_var; v->data = index; - val = ngx_http_script_start_code(cf->pool, &lcf->codes, - sizeof(ngx_http_script_value_code_t)); - if (val == NULL) { - return NGX_CONF_ERROR; - } + n = ngx_http_script_variables_count(&value[2]); + + if (n == 0) { + val = ngx_http_script_start_code(cf->pool, &lcf->codes, + sizeof(ngx_http_script_value_code_t)); + if (val == NULL) { + return NGX_CONF_ERROR; + } - n = ngx_atoi(value[2].data, value[2].len); + n = ngx_atoi(value[2].data, value[2].len); - if (n == NGX_ERROR) { - n = 0; - } + if (n == NGX_ERROR) { + n = 0; + } + + val->code = ngx_http_script_value_code; + val->value = (uintptr_t) n; + val->text_len = (uintptr_t) value[2].len; + val->text_data = (uintptr_t) value[2].data; + + } else { + complex = ngx_http_script_start_code(cf->pool, &lcf->codes, + sizeof(ngx_http_script_complex_value_code_t)); + if (complex == NULL) { + return NGX_CONF_ERROR; + } + + complex->code = ngx_http_script_complex_value_code; + complex->lengths = NULL; + + ngx_memzero(&sc, sizeof(ngx_http_script_compile_t)); + + sc.cf = cf; + sc.source = &value[2]; + sc.lengths = &complex->lengths; + sc.values = &lcf->codes; + sc.variables = n; + sc.complete_lengths = 1; - val->code = ngx_http_script_value_code; - val->value = (uintptr_t) n; - val->text_len = (uintptr_t) value[2].len; - val->text_data = (uintptr_t) value[2].data; + if (ngx_http_script_compile(&sc) != NGX_OK) { + return NGX_CONF_ERROR; + } + } var = ngx_http_script_start_code(cf->pool, &lcf->codes, sizeof(ngx_http_script_var_code_t)); |