Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nginx/nginx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src/http
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2004-07-26 20:21:18 +0400
committerIgor Sysoev <igor@sysoev.ru>2004-07-26 20:21:18 +0400
commitea52123c06a5c32a500e8ccb5ce9ae23db1d3a2b (patch)
tree9d21d6f4b6c657bab6eaa8f576c18c9f5beef147 /src/http
parent0599b11937990b169c05f95eeaed7cf22d823740 (diff)
nginx-0.0.8-2004-07-26-20:21:18 import
Diffstat (limited to 'src/http')
-rw-r--r--src/http/modules/ngx_http_index_handler.c49
-rw-r--r--src/http/modules/ngx_http_static_handler.c42
-rw-r--r--src/http/ngx_http_core_module.c22
3 files changed, 69 insertions, 44 deletions
diff --git a/src/http/modules/ngx_http_index_handler.c b/src/http/modules/ngx_http_index_handler.c
index ddd889404..acfd30850 100644
--- a/src/http/modules/ngx_http_index_handler.c
+++ b/src/http/modules/ngx_http_index_handler.c
@@ -107,7 +107,8 @@ ngx_int_t ngx_http_index_handler(ngx_http_request_t *r)
ngx_http_index_ctx_t *ctx;
ngx_http_core_loc_conf_t *clcf;
ngx_http_index_loc_conf_t *ilcf;
-#if (NGX_HTTP_CACHE)
+#if (NGX_HTTP_CACHE0)
+ /* crc must be in ctx !! */
uint32_t crc;
#endif
@@ -174,27 +175,17 @@ ngx_int_t ngx_http_index_handler(ngx_http_request_t *r)
#endif
if (clcf->alias) {
- if (clcf->root.len > clcf->name.len) {
- ctx->path.data = ngx_palloc(r->pool, clcf->root.len
- + r->uri.len
- - clcf->name.len
- + ilcf->max_index_len);
- if (ctx->path.data == NULL) {
- return NGX_HTTP_INTERNAL_SERVER_ERROR;
- }
-
- ctx->redirect.data = ctx->path.data + clcf->root.len + 1
- - clcf->name.len;
-
- } else {
- ctx->redirect.data = ngx_palloc(r->pool, r->uri.len
- + ilcf->max_index_len);
- if (ctx->redirect.data == NULL) {
- return NGX_HTTP_INTERNAL_SERVER_ERROR;
- }
+ ctx->path.data = ngx_palloc(r->pool, clcf->root.len
+ + r->uri.len + 1 - clcf->name.len
+ + ilcf->max_index_len);
+ if (ctx->path.data == NULL) {
+ return NGX_HTTP_INTERNAL_SERVER_ERROR;
+ }
- ctx->path.data = ctx->redirect.data + clcf->name.len
- - clcf->root.len;
+ ctx->redirect.data = ngx_palloc(r->pool, r->uri.len
+ + ilcf->max_index_len);
+ if (ctx->redirect.data == NULL) {
+ return NGX_HTTP_INTERNAL_SERVER_ERROR;
}
ngx_memcpy(ctx->path.data, clcf->root.data, clcf->root.len);
@@ -203,6 +194,7 @@ ngx_int_t ngx_http_index_handler(ngx_http_request_t *r)
r->uri.data + clcf->name.len,
r->uri.len + 1 - clcf->name.len);
+#if 0
/*
* aliases usually have trailling "/",
* set it in the start of the possible redirect
@@ -211,6 +203,7 @@ ngx_int_t ngx_http_index_handler(ngx_http_request_t *r)
if (*ctx->redirect.data != '/') {
ctx->redirect.data--;
}
+#endif
} else {
ctx->path.data = ngx_palloc(r->pool, clcf->root.len + r->uri.len
@@ -241,6 +234,9 @@ ngx_int_t ngx_http_index_handler(ngx_http_request_t *r)
name = ctx->path.data;
}
+ ngx_log_debug1(NGX_LOG_DEBUG_HTTP, log, 0,
+ "open index \"%s\"", name);
+
fd = ngx_open_file(name, NGX_FILE_RDONLY, NGX_FILE_OPEN);
if (fd == (ngx_fd_t) NGX_AGAIN) {
@@ -250,8 +246,8 @@ ngx_int_t ngx_http_index_handler(ngx_http_request_t *r)
if (fd == NGX_INVALID_FILE) {
err = ngx_errno;
- ngx_log_error(NGX_LOG_DEBUG, log, err,
- "debug: " ngx_open_file_n " %s failed", name);
+ ngx_log_debug1(NGX_LOG_DEBUG_HTTP, log, err,
+ ngx_open_file_n " %s failed", name);
if (err == NGX_ENOTDIR) {
return ngx_http_index_error(r, ctx, err);
@@ -293,11 +289,12 @@ ngx_int_t ngx_http_index_handler(ngx_http_request_t *r)
} else {
if (clcf->alias) {
- ngx_memcpy(ctx->redirect.data, clcf->name.data, clcf->name.len);
+ name = ngx_cpymem(ctx->redirect.data, r->uri.data, r->uri.len);
+ ngx_memcpy(name, index[ctx->index].data,
+ index[ctx->index].len + 1);
}
- ctx->redirect.len = r->uri.len + index[ctx->index].len
- - clcf->alias * clcf->name.len;
+ ctx->redirect.len = r->uri.len + index[ctx->index].len;
r->file.name.len = clcf->root.len + r->uri.len
- clcf->alias * clcf->name.len
+ index[ctx->index].len;
diff --git a/src/http/modules/ngx_http_static_handler.c b/src/http/modules/ngx_http_static_handler.c
index bc32cc539..9a1a814ef 100644
--- a/src/http/modules/ngx_http_static_handler.c
+++ b/src/http/modules/ngx_http_static_handler.c
@@ -115,18 +115,27 @@ static ngx_int_t ngx_http_static_handler(ngx_http_request_t *r)
* in a possible redirect and for the last '\0'
*/
- name.data = ngx_palloc(r->pool, clcf->root.len + r->uri.len + 2
- - clcf->alias * clcf->name.len);
- if (name.data == NULL) {
- return NGX_HTTP_INTERNAL_SERVER_ERROR;
- }
-
- location.data = ngx_cpymem(name.data, clcf->root.data, clcf->root.len);
-
if (clcf->alias) {
- last = ngx_cpystrn(location.data, r->uri.data + clcf->name.len,
+ name.data = ngx_palloc(r->pool, clcf->root.len + r->uri.len + 2
+ - clcf->name.len);
+ if (name.data == NULL) {
+ return NGX_HTTP_INTERNAL_SERVER_ERROR;
+ }
+
+ last = ngx_cpymem(name.data, clcf->root.data, clcf->root.len);
+ last = ngx_cpystrn(last, r->uri.data + clcf->name.len,
r->uri.len + 1 - clcf->name.len);
+ name.len = last - name.data;
+
+ location.data = ngx_palloc(r->pool, r->uri.len + 2);
+ if (location.data == NULL) {
+ return NGX_HTTP_INTERNAL_SERVER_ERROR;
+ }
+
+ last = ngx_cpystrn(location.data, r->uri.data, r->uri.len + 1);
+
+#if 0
/*
* aliases usually have trailling "/",
* set it in the start of the possible redirect
@@ -135,13 +144,22 @@ static ngx_int_t ngx_http_static_handler(ngx_http_request_t *r)
if (*location.data != '/') {
location.data--;
}
+#endif
+
+ location.len = last - location.data + 1;
} else {
+ name.data = ngx_palloc(r->pool, clcf->root.len + r->uri.len + 2);
+ if (name.data == NULL) {
+ return NGX_HTTP_INTERNAL_SERVER_ERROR;
+ }
+
+ location.data = ngx_cpymem(name.data, clcf->root.data, clcf->root.len);
last = ngx_cpystrn(location.data, r->uri.data, r->uri.len + 1);
- }
- name.len = last - name.data;
- location.len = last - location.data + 1;
+ name.len = last - name.data;
+ location.len = last - location.data + 1;
+ }
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, log, 0,
"http filename: \"%s\"", name.data);
diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c
index 066d08abc..dbc91bcd3 100644
--- a/src/http/ngx_http_core_module.c
+++ b/src/http/ngx_http_core_module.c
@@ -589,19 +589,24 @@ static ngx_int_t ngx_http_find_location(ngx_http_request_t *r,
}
if (n == 0) {
+ if (clcfp[i]->exact_match && r->uri.len == clcfp[i]->name.len) {
+ r->loc_conf = clcfp[i]->loc_conf;
+ return NGX_HTTP_LOCATION_EXACT;
+ }
+
clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
- if (clcf->name.len >= clcfp[i]->name.len) {
+#if 0
+ ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
+ "p:%d c:%d", clcf->name.len, clcfp[i]->name.len);
+#endif
+
+ if (clcf->name.len > clcfp[i]->name.len) {
/* the previous match is longer */
break;
}
r->loc_conf = clcfp[i]->loc_conf;
-
- if (clcfp[i]->exact_match && r->uri.len == clcfp[i]->name.len) {
- return NGX_HTTP_LOCATION_EXACT;
- }
-
found = 1;
}
}
@@ -1110,9 +1115,14 @@ static char *ngx_location_block(ngx_conf_t *cf, ngx_command_t *cmd, void *dummy)
return NGX_CONF_ERROR;
}
+#if (HAVE_PCRE)
if (clcf->regex == NULL
&& ngx_strncmp(clcf->name.data, pclcf->name.data, pclcf->name.len)
!= 0)
+#else
+ if (ngx_strncmp(clcf->name.data, pclcf->name.data, pclcf->name.len)
+ != 0)
+#endif
{
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
"location \"%s\" is outside location \"%s\"",