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 }
};
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;
allocated = 0;
root = 0;
name = NULL;
- path.len = 0;
+ /* suppress MSVC warning */
path.data = NULL;
tf = clcf->try_files;
}
}
+ test_dir = tf->test_dir;
+
tf++;
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
continue;
}
- if (!of.is_file) {
+ if (of.is_dir && !test_dir) {
continue;
}
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);
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);
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) {