diff options
-rw-r--r-- | auto/modules | 6 | ||||
-rw-r--r-- | src/core/nginx.h | 2 | ||||
-rw-r--r-- | src/core/ngx_config.h | 2 | ||||
-rw-r--r-- | src/http/modules/ngx_http_index_handler.c | 49 | ||||
-rw-r--r-- | src/http/modules/ngx_http_static_handler.c | 42 | ||||
-rw-r--r-- | src/http/ngx_http_core_module.c | 22 |
6 files changed, 71 insertions, 52 deletions
diff --git a/auto/modules b/auto/modules index 4dc9e1e66..ce6096791 100644 --- a/auto/modules +++ b/auto/modules @@ -106,12 +106,6 @@ if [ $HTTP_SSL = YES ]; then HTTP_MODULES="$HTTP_MODULES $HTTP_SSL_MODULE" HTTP_DEPS="$HTTP_DEPS $HTTP_SSL_DEPS" HTTP_SRCS="$HTTP_SRCS $HTTP_SSL_SRCS" - - # STUB: move to auto/libs/ssl after md5 - #have=NGX_OPENSSL . auto/have - #CORE_DEPS="$CORE_DEPS $OPENSSL_DEPS" - #CORE_SRCS="$CORE_SRCS $OPENSSL_SRCS" - #CORE_LIBS="$CORE_LIBS -lssl -lcrypto" fi if [ $HTTP_PROXY = YES ]; then diff --git a/src/core/nginx.h b/src/core/nginx.h index c824cdd24..d8c82b273 100644 --- a/src/core/nginx.h +++ b/src/core/nginx.h @@ -2,7 +2,7 @@ #define _NGINX_H_INCLUDED_ -#define NGINX_VER "nginx/0.0.7" +#define NGINX_VER "nginx/0.0.8" #define NGINX_VAR "NGINX" #define NGX_NEWPID_EXT ".newbin" diff --git a/src/core/ngx_config.h b/src/core/ngx_config.h index 6e381f50d..09fd70eb2 100644 --- a/src/core/ngx_config.h +++ b/src/core/ngx_config.h @@ -97,7 +97,7 @@ typedef long ngx_flag_t; #define ngx_inline inline #endif -#define NGX_ACCEPT_THRESHOLD 50 +#define NGX_ACCEPT_THRESHOLD 100 #ifndef INADDR_NONE /* Solaris */ #define INADDR_NONE ((unsigned int) -1) 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\"", |