]> git.kaiwu.me - nginx.git/commitdiff
try_files status code
authorIgor Sysoev <igor@sysoev.ru>
Sat, 11 Apr 2009 11:02:36 +0000 (11:02 +0000)
committerIgor Sysoev <igor@sysoev.ru>
Sat, 11 Apr 2009 11:02:36 +0000 (11:02 +0000)
src/http/ngx_http_core_module.c
src/http/ngx_http_core_module.h

index b6f4b11e1bbbf606ed6d3a56ea226305e6d38284..ca1fbead0ff0afbed3c4737a935df656b41166ef 100644 (file)
@@ -1144,6 +1144,11 @@ ngx_http_core_try_files_phase(ngx_http_request_t *r,
 
         if (tf->lengths == NULL && tf->name.len == 0) {
 
+            if (tf->code) {
+                ngx_http_finalize_request(r, tf->code);
+                return NGX_OK;
+            }
+
             path.len -= root;
             path.data += root;
 
@@ -3939,6 +3944,7 @@ ngx_http_core_try_files(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
     ngx_http_core_loc_conf_t *clcf = conf;
 
     ngx_str_t                  *value;
+    ngx_int_t                   code;
     ngx_uint_t                  i, n;
     ngx_http_try_file_t        *tf;
     ngx_http_script_compile_t   sc;
@@ -3994,6 +4000,20 @@ ngx_http_core_try_files(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
         }
     }
 
+    if (tf[i - 1].name.data[0] == '=') {
+
+        code = ngx_atoi(tf[i - 1].name.data + 1, tf[i - 1].name.len - 2);
+
+        if (code == NGX_ERROR) {
+            ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
+                               "invalid code \"%*s\"",
+                               tf[i - 1].name.len - 1, tf[i - 1].name.data);
+            return NGX_CONF_ERROR;
+        }
+
+        tf[i].code = code;
+    }
+
     return NGX_CONF_OK;
 }
 
index e1692fd03ea6155eb38c92df7975ff18ad2d43b9..8b1db54a25ee820db089c0d9a553cddfc8e15c79 100644 (file)
@@ -267,7 +267,9 @@ typedef struct {
     ngx_array_t               *lengths;
     ngx_array_t               *values;
     ngx_str_t                  name;
-    ngx_uint_t                 test_dir;   /* unsigned  test_dir:1; */
+
+    unsigned                   code:10;
+    unsigned                   test_dir:1;
 } ngx_http_try_file_t;