Ticket #242: nginx_dav_if-unmodified-since.patch
| File nginx_dav_if-unmodified-since.patch, 2.1 KB (added by , 14 years ago) |
|---|
-
src/http/modules/ngx_http_dav_module.c
55 55 static ngx_int_t ngx_http_dav_copy_tree_file(ngx_tree_ctx_t *ctx, 56 56 ngx_str_t *path); 57 57 58 static ngx_int_t ngx_http_dav_check_unmodified(ngx_http_request_t *r, 59 ngx_file_info_t *fi); 60 58 61 static ngx_int_t ngx_http_dav_depth(ngx_http_request_t *r, ngx_int_t dflt); 59 62 static ngx_int_t ngx_http_dav_error(ngx_log_t *log, ngx_err_t err, 60 63 ngx_int_t not_found, char *failed, u_char *path); … … 237 240 ngx_http_finalize_request(r, NGX_HTTP_CONFLICT); 238 241 return; 239 242 } 243 if (ngx_http_dav_check_unmodified(r, &fi)) return; 240 244 } 241 245 242 246 dlcf = ngx_http_get_module_loc_conf(r, ngx_http_dav_module); … … 353 357 354 358 } else { 355 359 360 if (ngx_http_dav_check_unmodified(r, &fi)) return NGX_DONE; 361 356 362 /* 357 363 * we do not need to test (r->uri.data[r->uri.len - 1] == '/') 358 364 * because ngx_link_info("/file/") returned NGX_ENOTDIR above … … 707 713 708 714 /* destination exists */ 709 715 716 if (ngx_http_dav_check_unmodified(r, &fi)) return NGX_DONE; 717 710 718 if (ngx_is_dir(&fi) && !slash) { 711 719 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, 712 720 "\"%V\" could not be %Ved to collection \"%V\"", … … 967 975 return NGX_OK; 968 976 } 969 977 978 static ngx_int_t 979 ngx_http_dav_check_unmodified(ngx_http_request_t *r, ngx_file_info_t *fi) 980 { 981 time_t date; 982 if (r->headers_in.if_unmodified_since) { 983 date = 984 ngx_http_parse_time(r->headers_in.if_unmodified_since->value.data, 985 r->headers_in.if_unmodified_since->value.len); 986 if (date < ngx_file_mtime(fi)) { 987 ngx_http_filter_finalize_request(r, NULL, 988 NGX_HTTP_PRECONDITION_FAILED); 989 return 1; 990 } 991 } 992 return 0; 993 } 970 994 971 995 static ngx_int_t 972 996 ngx_http_dav_depth(ngx_http_request_t *r, ngx_int_t dflt)
