remove r->root_length
diff --git a/src/http/modules/ngx_http_autoindex_module.c b/src/http/modules/ngx_http_autoindex_module.c
index 1c77093..f5944c4 100644
--- a/src/http/modules/ngx_http_autoindex_module.c
+++ b/src/http/modules/ngx_http_autoindex_module.c
@@ -135,7 +135,7 @@
{
u_char *last, *filename, scale;
off_t length;
- size_t len, copy, allocated;
+ size_t len, copy, allocated, root;
ngx_tm_t tm;
ngx_err_t err;
ngx_buf_t *b;
@@ -174,7 +174,8 @@
/* NGX_DIR_MASK_LEN is lesser than NGX_HTTP_AUTOINDEX_PREALLOCATE */
- last = ngx_http_map_uri_to_path(r, &path, NGX_HTTP_AUTOINDEX_PREALLOCATE);
+ last = ngx_http_map_uri_to_path(r, &path, &root,
+ NGX_HTTP_AUTOINDEX_PREALLOCATE);
if (last == NULL) {
return NGX_HTTP_INTERNAL_SERVER_ERROR;
}
diff --git a/src/http/modules/ngx_http_dav_module.c b/src/http/modules/ngx_http_dav_module.c
index 02dd388..81c1dc4 100644
--- a/src/http/modules/ngx_http_dav_module.c
+++ b/src/http/modules/ngx_http_dav_module.c
@@ -102,6 +102,7 @@
ngx_http_dav_handler(ngx_http_request_t *r)
{
char *failed;
+ size_t root;
ngx_int_t rc;
ngx_str_t path;
ngx_file_info_t fi;
@@ -152,7 +153,7 @@
return rc;
}
- ngx_http_map_uri_to_path(r, &path, 0);
+ ngx_http_map_uri_to_path(r, &path, &root, 0);
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
"http delete filename: \"%s\"", path.data);
@@ -219,7 +220,7 @@
return rc;
}
- ngx_http_map_uri_to_path(r, &path, 0);
+ ngx_http_map_uri_to_path(r, &path, &root, 0);
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
"http mkcol path: \"%s\"", path.data);
@@ -245,6 +246,7 @@
{
char *failed;
u_char *name;
+ size_t root;
time_t date;
ngx_err_t err;
ngx_str_t *temp, path;
@@ -252,7 +254,7 @@
ngx_file_info_t fi;
ngx_http_dav_loc_conf_t *dlcf;
- ngx_http_map_uri_to_path(r, &path, 0);
+ ngx_http_map_uri_to_path(r, &path, &root, 0);
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
"http put filename: \"%s\"", path.data);
diff --git a/src/http/modules/ngx_http_index_module.c b/src/http/modules/ngx_http_index_module.c
index cd1c51e..3af8026 100644
--- a/src/http/modules/ngx_http_index_module.c
+++ b/src/http/modules/ngx_http_index_module.c
@@ -28,6 +28,8 @@
ngx_str_t path;
ngx_str_t index;
+ size_t root;
+
ngx_uint_t tested; /* unsigned tested:1 */
} ngx_http_index_ctx_t;
@@ -200,7 +202,7 @@
if (len > (size_t) (ctx->path.data + ctx->path.len - ctx->index.data)) {
- last = ngx_http_map_uri_to_path(r, &ctx->path, len);
+ last = ngx_http_map_uri_to_path(r, &ctx->path, &ctx->root, len);
if (last == NULL) {
return NGX_ERROR;
}
@@ -291,7 +293,7 @@
uri.len = r->uri.len + ctx->index.len - 1;
if (!clcf->alias) {
- uri.data = ctx->path.data + r->root_length;
+ uri.data = ctx->path.data + ctx->root;
} else {
uri.data = ngx_palloc(r->pool, uri.len);
diff --git a/src/http/modules/ngx_http_static_module.c b/src/http/modules/ngx_http_static_module.c
index f9df46e..bc150bf 100644
--- a/src/http/modules/ngx_http_static_module.c
+++ b/src/http/modules/ngx_http_static_module.c
@@ -73,6 +73,7 @@
ngx_http_static_handler(ngx_http_request_t *r)
{
u_char *last, *location;
+ size_t root;
ngx_fd_t fd;
ngx_int_t rc;
ngx_uint_t level;
@@ -112,7 +113,7 @@
* so we do not need to reserve memory for '/' for possible redirect
*/
- last = ngx_http_map_uri_to_path(r, &path, 0);
+ last = ngx_http_map_uri_to_path(r, &path, &root, 0);
if (last == NULL) {
return NGX_HTTP_INTERNAL_SERVER_ERROR;
}
diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c
index 0cc9c7f..9dc2069 100644
--- a/src/http/ngx_http_core_module.c
+++ b/src/http/ngx_http_core_module.c
@@ -794,6 +794,7 @@
ngx_http_core_content_phase(ngx_http_request_t *r,
ngx_http_phase_handler_t *ph)
{
+ size_t root;
ngx_int_t rc;
ngx_str_t path;
@@ -830,7 +831,7 @@
if (r->uri.data[r->uri.len - 1] == '/' && !r->zero_in_uri) {
- if (ngx_http_map_uri_to_path(r, &path, 0) != NULL) {
+ if (ngx_http_map_uri_to_path(r, &path, &root, 0) != NULL) {
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
"directory index of \"%V\" is forbidden", &path);
}
@@ -1157,7 +1158,7 @@
u_char *
ngx_http_map_uri_to_path(ngx_http_request_t *r, ngx_str_t *path,
- size_t reserved)
+ size_t *root_length, size_t reserved)
{
u_char *last;
size_t alias;
@@ -1178,7 +1179,7 @@
if (clcf->root_lengths == NULL) {
- r->root_length = clcf->root.len;
+ *root_length = clcf->root.len;
path->len = clcf->root.len + reserved;
@@ -1201,8 +1202,8 @@
return NULL;
}
- r->root_length = path->len - reserved;
- last = path->data + r->root_length;
+ *root_length = path->len - reserved;
+ last = path->data + *root_length;
}
last = ngx_cpystrn(last, r->uri.data + alias, r->uri.len - alias + 1);
diff --git a/src/http/ngx_http_core_module.h b/src/http/ngx_http_core_module.h
index f8ea328..c468fa3 100644
--- a/src/http/ngx_http_core_module.h
+++ b/src/http/ngx_http_core_module.h
@@ -301,7 +301,7 @@
ngx_int_t ngx_http_set_content_type(ngx_http_request_t *r);
ngx_int_t ngx_http_set_exten(ngx_http_request_t *r);
u_char *ngx_http_map_uri_to_path(ngx_http_request_t *r, ngx_str_t *name,
- size_t reserved);
+ size_t *root_length, size_t reserved);
ngx_int_t ngx_http_auth_basic_user(ngx_http_request_t *r);
ngx_int_t ngx_http_subrequest(ngx_http_request_t *r,
diff --git a/src/http/ngx_http_request.h b/src/http/ngx_http_request.h
index 204d62f..6c0796b 100644
--- a/src/http/ngx_http_request.h
+++ b/src/http/ngx_http_request.h
@@ -357,8 +357,6 @@
ngx_http_variable_value_t *variables;
- size_t root_length;
-
size_t limit_rate;
/* used to learn the Apache compatible response length without a header */
diff --git a/src/http/ngx_http_variables.c b/src/http/ngx_http_variables.c
index 0f1587b..ecf20c3 100644
--- a/src/http/ngx_http_variables.c
+++ b/src/http/ngx_http_variables.c
@@ -852,9 +852,10 @@
ngx_http_variable_request_filename(ngx_http_request_t *r,
ngx_http_variable_value_t *v, uintptr_t data)
{
+ size_t root;
ngx_str_t path;
- if (ngx_http_map_uri_to_path(r, &path, 0) == NULL) {
+ if (ngx_http_map_uri_to_path(r, &path, &root, 0) == NULL) {
return NGX_ERROR;
}