From 76ffbb2bccc57bce9fc5c7bfd7dae444cdb13cc4 Mon Sep 17 00:00:00 2001 From: Kirill A. Korinskiy Date: Fri, 24 Apr 2009 18:02:29 +0400 Subject: [PATCH 1/2] Implement $uri_remainder Cc: catap@catap.ru --- src/http/ngx_http_core_module.c | 5 +++++ src/http/ngx_http_request.h | 1 + src/http/ngx_http_variables.c | 4 ++++ 3 files changed, 10 insertions(+), 0 deletions(-) diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c index 26f24b3..971329e 100644 --- a/src/http/ngx_http_core_module.c +++ b/src/http/ngx_http_core_module.c @@ -838,6 +838,11 @@ ngx_http_core_find_config_phase(ngx_http_request_t *r, clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); + if (!clcf->regex_locations) { + r->uri_remainder.len = r->uri.len - clcf->name.len; + r->uri_remainder.data = r->uri.data + clcf->name.len; + } + if (!r->internal && clcf->internal) { ngx_http_finalize_request(r, NGX_HTTP_NOT_FOUND); return NGX_OK; diff --git a/src/http/ngx_http_request.h b/src/http/ngx_http_request.h index 23a8846..6e8af66 100644 --- a/src/http/ngx_http_request.h +++ b/src/http/ngx_http_request.h @@ -373,6 +373,7 @@ struct ngx_http_request_s { ngx_str_t request_line; ngx_str_t uri; + ngx_str_t uri_remainder; ngx_str_t args; ngx_str_t exten; ngx_str_t unparsed_uri; diff --git a/src/http/ngx_http_variables.c b/src/http/ngx_http_variables.c index 106e45b..2051f46 100644 --- a/src/http/ngx_http_variables.c +++ b/src/http/ngx_http_variables.c @@ -164,6 +164,10 @@ static ngx_http_variable_t ngx_http_core_variables[] = { offsetof(ngx_http_request_t, uri), NGX_HTTP_VAR_NOCACHEABLE, 0 }, + { ngx_string("uri_remainder"), NULL, ngx_http_variable_request, + offsetof(ngx_http_request_t, uri_remainder), + NGX_HTTP_VAR_NOCACHEABLE, 0 }, + { ngx_string("document_uri"), NULL, ngx_http_variable_request, offsetof(ngx_http_request_t, uri), NGX_HTTP_VAR_NOCACHEABLE, 0 }, -- 1.6.2 From 9895f414613d437dad7f8264ba2adba1e5d976d7 Mon Sep 17 00:00:00 2001 From: Kirill A. Korinskiy Date: Tue, 28 Apr 2009 16:11:35 +0400 Subject: [PATCH 2/2] Reset uri_remainder for regex locations Cc: catap@catap.ru --- src/http/ngx_http_core_module.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c index 971329e..28f2cc1 100644 --- a/src/http/ngx_http_core_module.c +++ b/src/http/ngx_http_core_module.c @@ -841,6 +841,9 @@ ngx_http_core_find_config_phase(ngx_http_request_t *r, if (!clcf->regex_locations) { r->uri_remainder.len = r->uri.len - clcf->name.len; r->uri_remainder.data = r->uri.data + clcf->name.len; + } else { + r->uri_remainder.len = 0; + r->uri_remainder.data = NULL; } if (!r->internal && clcf->internal) { -- 1.6.2