upstream nginx-0.7.35
[nginx.git] / nginx / src / http / ngx_http_core_module.c
index d44933c..3f5cb29 100644 (file)
@@ -112,8 +112,9 @@ static ngx_conf_enum_t  ngx_http_core_satisfy[] = {
 
 
 static ngx_conf_enum_t  ngx_http_core_if_modified_since[] = {
-    { ngx_string("exact"), 0 },
-    { ngx_string("before"), 1 },
+    { ngx_string("off"), NGX_HTTP_IMS_OFF },
+    { ngx_string("exact"), NGX_HTTP_IMS_EXACT },
+    { ngx_string("before"), NGX_HTTP_IMS_BEFORE },
     { ngx_null_string, 0 }
 };
 
@@ -1034,10 +1035,10 @@ ngx_int_t
 ngx_http_core_try_files_phase(ngx_http_request_t *r,
     ngx_http_phase_handler_t *ph)
 {
-    size_t                        len, root, alias;
-    ssize_t                       reserve, allocated;
+    size_t                        len, root, alias, reserve, allocated;
     u_char                       *p, *name;
     ngx_str_t                     path;
+    ngx_uint_t                    test_dir;
     ngx_http_try_file_t          *tf;
     ngx_open_file_info_t          of;
     ngx_http_script_code_pt       code;
@@ -1058,7 +1059,7 @@ ngx_http_core_try_files_phase(ngx_http_request_t *r,
     allocated = 0;
     root = 0;
     name = NULL;
-    path.len = 0;
+    /* suppress MSVC warning */
     path.data = NULL;
 
     tf = clcf->try_files;
@@ -1133,6 +1134,8 @@ ngx_http_core_try_files_phase(ngx_http_request_t *r,
             }
         }
 
+        test_dir = tf->test_dir;
+
         tf++;
 
         ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
@@ -1172,7 +1175,7 @@ ngx_http_core_try_files_phase(ngx_http_request_t *r,
             continue;
         }
 
-        if (!of.is_file) {
+        if (of.is_dir && !test_dir) {
             continue;
         }
 
@@ -1194,6 +1197,11 @@ ngx_http_core_try_files_phase(ngx_http_request_t *r,
             ngx_memcpy(p, name, path.len);
         }
 
+        if (ngx_http_set_exten(r) != NGX_OK) {
+            ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
+            return NGX_OK;
+        }
+
         ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
                        "try file uri: \"%V\"", &r->uri);
 
@@ -3050,7 +3058,7 @@ ngx_http_core_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
     ngx_conf_merge_uint_value(conf->satisfy, prev->satisfy,
                               NGX_HTTP_SATISFY_ALL);
     ngx_conf_merge_uint_value(conf->if_modified_since, prev->if_modified_since,
-                              0);
+                              NGX_HTTP_IMS_EXACT);
     ngx_conf_merge_value(conf->internal, prev->internal, 0);
     ngx_conf_merge_value(conf->client_body_in_file_only,
                               prev->client_body_in_file_only, 0);
@@ -3853,6 +3861,11 @@ ngx_http_core_try_files(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
 
         tf[i].name = value[i + 1];
 
+        if (tf[i].name.data[tf[i].name.len - 1] == '/') {
+            tf[i].test_dir = 1;
+            tf[i].name.len--;
+        }
+
         n = ngx_http_script_variables_count(&tf[i].name);
 
         if (n) {