# HG changeset patch # User Igor Sysoev # Date 1160660214 0 # Node ID c3ebeee31026f0b678e637be7670c0c2bb3d08e7 # Parent 843412b22ba2f206182930fce4064e4096123724 remove r->root_length diff --git a/src/http/modules/ngx_http_autoindex_module.c b/src/http/modules/ngx_http_autoindex_module.c --- a/src/http/modules/ngx_http_autoindex_module.c +++ b/src/http/modules/ngx_http_autoindex_module.c @@ -135,7 +135,7 @@ ngx_http_autoindex_handler(ngx_http_requ { 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_http_autoindex_handler(ngx_http_requ /* 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 --- a/src/http/modules/ngx_http_dav_module.c +++ b/src/http/modules/ngx_http_dav_module.c @@ -102,6 +102,7 @@ static ngx_int_t 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 @@ ngx_http_dav_handler(ngx_http_request_t 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 @@ ngx_http_dav_handler(ngx_http_request_t 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 @@ ngx_http_dav_put_handler(ngx_http_reques { 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_http_dav_put_handler(ngx_http_reques 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 --- a/src/http/modules/ngx_http_index_module.c +++ b/src/http/modules/ngx_http_index_module.c @@ -28,6 +28,8 @@ typedef struct { 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 @@ ngx_http_index_handler(ngx_http_request_ 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 @@ ngx_http_index_handler(ngx_http_request_ 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 --- a/src/http/modules/ngx_http_static_module.c +++ b/src/http/modules/ngx_http_static_module.c @@ -73,6 +73,7 @@ static ngx_int_t 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 @@ ngx_http_static_handler(ngx_http_request * 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 --- a/src/http/ngx_http_core_module.c +++ b/src/http/ngx_http_core_module.c @@ -794,6 +794,7 @@ ngx_int_t 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 @@ ngx_http_core_content_phase(ngx_http_req 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 @@ ngx_http_output_filter(ngx_http_request_ 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 @@ ngx_http_map_uri_to_path(ngx_http_reques 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 @@ ngx_http_map_uri_to_path(ngx_http_reques 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 --- 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_core_content_phase(ng 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 --- a/src/http/ngx_http_request.h +++ b/src/http/ngx_http_request.h @@ -357,8 +357,6 @@ struct ngx_http_request_s { 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 --- a/src/http/ngx_http_variables.c +++ b/src/http/ngx_http_variables.c @@ -852,9 +852,10 @@ static ngx_int_t 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; }