diff src/http/ngx_http_variables.c @ 557:ecd9c160f25b release-0.3.0

nginx-0.3.0-RELEASE import *) Change: the 10-days live time limit of worker process was eliminated. The limit was introduced because of millisecond timers overflow.
author Igor Sysoev <igor@sysoev.ru>
date Fri, 07 Oct 2005 13:30:52 +0000
parents 45033d85b30e
children e48ebafc6939
line wrap: on
line diff
--- a/src/http/ngx_http_variables.c
+++ b/src/http/ngx_http_variables.c
@@ -619,8 +619,6 @@ ngx_http_variable_document_root(ngx_http
 static ngx_http_variable_value_t *
 ngx_http_variable_request_filename(ngx_http_request_t *r, uintptr_t data)
 {
-    u_char                     *p;
-    ngx_http_core_loc_conf_t   *clcf;
     ngx_http_variable_value_t  *vv;
 
     vv = ngx_palloc(r->pool, sizeof(ngx_http_variable_value_t));
@@ -630,29 +628,13 @@ ngx_http_variable_request_filename(ngx_h
 
     vv->value = 0;
 
-    clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
-
-    if (!clcf->alias) {
-        vv->text.len = clcf->root.len + r->uri.len;
-        vv->text.data = ngx_palloc(r->pool, vv->text.len);
-        if (vv->text.data == NULL) {
-            return NULL;
-        }
-
-        p = ngx_cpymem(vv->text.data, clcf->root.data, clcf->root.len);
-        ngx_memcpy(p, r->uri.data, r->uri.len + 1);
+    if (ngx_http_map_uri_to_path(r, &vv->text, 0) == NULL) {
+        return NULL;
+    }
 
-    } else {
-        vv->text.len = clcf->root.len + r->uri.len + 2 - clcf->name.len;
-        vv->text.data = ngx_palloc(r->pool, vv->text.len);
-        if (vv->text.data == NULL) {
-            return NULL;
-        }
+    /* ngx_http_map_uri_to_path() allocates memory for terminating '\0' */
 
-        p = ngx_cpymem(vv->text.data, clcf->root.data, clcf->root.len);
-        ngx_memcpy(p, r->uri.data + clcf->name.len,
-                   r->uri.len + 1 - clcf->name.len);
-    }
+    vv->text.len--;
 
     return vv;
 }