changeset 400:69e851f83522

nginx-0.0.8-2004-07-26-20:21:18 import
author Igor Sysoev <igor@sysoev.ru>
date Mon, 26 Jul 2004 16:21:18 +0000
parents 4e21d1291a14
children b32ca005e025
files auto/modules src/core/nginx.h src/core/ngx_config.h src/http/modules/ngx_http_index_handler.c src/http/modules/ngx_http_static_handler.c src/http/ngx_http_core_module.c
diffstat 6 files changed, 72 insertions(+), 53 deletions(-) [+]
line wrap: on
line diff
--- 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
--- 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"
--- 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)
--- 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_htt
     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_htt
 #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->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->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 = 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_htt
                                     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_htt
             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_htt
             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_htt
         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_htt
 
         } 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;
--- 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
      * 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;
-    }
+    if (clcf->alias) {
+        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;
+        }
 
-    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,
+        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
         if (*location.data != '/') {
             location.data--;
         }
+#endif
+
+        location.len = last - location.data + 1;
 
     } else {
-        last = ngx_cpystrn(location.data, r->uri.data, r->uri.len + 1);
-    }
+        name.data = ngx_palloc(r->pool, clcf->root.len + r->uri.len + 2);
+        if (name.data == NULL) {
+            return NGX_HTTP_INTERNAL_SERVER_ERROR;
+        }
 
-    name.len = last - name.data;
-    location.len = last - location.data + 1;
+        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;
+    }
 
     ngx_log_debug1(NGX_LOG_DEBUG_HTTP, log, 0,
                    "http filename: \"%s\"", name.data);
--- 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(
         }
 
         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
             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\"",