remove r->root_length

This commit is contained in:
Igor Sysoev 2006-10-12 13:36:54 +00:00
parent ae8b56c96e
commit 888f0963a3
8 changed files with 23 additions and 17 deletions

View File

@ -135,7 +135,7 @@ ngx_http_autoindex_handler(ngx_http_request_t *r)
{
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_request_t *r)
/* 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;
}

View File

@ -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 *r)
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 *r)
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_request_t *r)
{
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_request_t *r)
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);

View File

@ -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_t *r)
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_t *r)
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);

View File

@ -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_t *r)
* 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;
}

View File

@ -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_request_t *r,
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_t *r, ngx_chain_t *in)
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_request_t *r, ngx_str_t *path,
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_request_t *r, ngx_str_t *path,
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);

View File

@ -301,7 +301,7 @@ ngx_int_t ngx_http_core_content_phase(ngx_http_request_t *r,
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,

View File

@ -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 */

View File

@ -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;
}