diff src/http/modules/ngx_http_static_handler.c @ 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 6f3b20c1ac50
children ea3113b181d1
line wrap: on
line diff
--- 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);