Mercurial > hg > nginx
comparison src/http/modules/ngx_http_dav_module.c @ 1816:20a2512aacc4
min_delete_depth
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Sun, 30 Dec 2007 11:46:03 +0000 |
parents | 1e2fb527f9c0 |
children | ae7affa52ec0 |
comparison
equal
deleted
inserted
replaced
1815:1e2fb527f9c0 | 1816:20a2512aacc4 |
---|---|
19 #define NGX_HTTP_DAV_INFINITY_DEPTH -1 | 19 #define NGX_HTTP_DAV_INFINITY_DEPTH -1 |
20 | 20 |
21 | 21 |
22 typedef struct { | 22 typedef struct { |
23 ngx_uint_t methods; | 23 ngx_uint_t methods; |
24 ngx_uint_t access; | |
25 ngx_uint_t min_delete_depth; | |
24 ngx_flag_t create_full_put_path; | 26 ngx_flag_t create_full_put_path; |
25 ngx_uint_t access; | |
26 } ngx_http_dav_loc_conf_t; | 27 } ngx_http_dav_loc_conf_t; |
27 | 28 |
28 | 29 |
29 typedef struct { | 30 typedef struct { |
30 ngx_str_t path; | 31 ngx_str_t path; |
85 { ngx_string("create_full_put_path"), | 86 { ngx_string("create_full_put_path"), |
86 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, | 87 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, |
87 ngx_conf_set_flag_slot, | 88 ngx_conf_set_flag_slot, |
88 NGX_HTTP_LOC_CONF_OFFSET, | 89 NGX_HTTP_LOC_CONF_OFFSET, |
89 offsetof(ngx_http_dav_loc_conf_t, create_full_put_path), | 90 offsetof(ngx_http_dav_loc_conf_t, create_full_put_path), |
91 NULL }, | |
92 | |
93 { ngx_string("min_delete_depth"), | |
94 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | |
95 ngx_conf_set_num_slot, | |
96 NGX_HTTP_LOC_CONF_OFFSET, | |
97 offsetof(ngx_http_dav_loc_conf_t, min_delete_depth), | |
90 NULL }, | 98 NULL }, |
91 | 99 |
92 { ngx_string("dav_access"), | 100 { ngx_string("dav_access"), |
93 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE123, | 101 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE123, |
94 ngx_conf_set_access_slot, | 102 ngx_conf_set_access_slot, |
342 | 350 |
343 | 351 |
344 static ngx_int_t | 352 static ngx_int_t |
345 ngx_http_dav_delete_handler(ngx_http_request_t *r) | 353 ngx_http_dav_delete_handler(ngx_http_request_t *r) |
346 { | 354 { |
347 size_t root; | 355 size_t root; |
348 ngx_err_t err; | 356 ngx_err_t err; |
349 ngx_int_t rc, depth; | 357 ngx_int_t rc, depth; |
350 ngx_uint_t dir; | 358 ngx_uint_t i, d, dir; |
351 ngx_str_t path; | 359 ngx_str_t path; |
352 ngx_file_info_t fi; | 360 ngx_file_info_t fi; |
361 ngx_http_dav_loc_conf_t *dlcf; | |
353 | 362 |
354 if (r->headers_in.content_length_n > 0) { | 363 if (r->headers_in.content_length_n > 0) { |
355 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | 364 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, |
356 "DELETE with body is unsupported"); | 365 "DELETE with body is unsupported"); |
357 return NGX_HTTP_UNSUPPORTED_MEDIA_TYPE; | 366 return NGX_HTTP_UNSUPPORTED_MEDIA_TYPE; |
358 } | 367 } |
368 | |
369 dlcf = ngx_http_get_module_loc_conf(r, ngx_http_dav_module); | |
370 | |
371 if (dlcf->min_delete_depth) { | |
372 d = 0; | |
373 | |
374 for (i = 0; i < r->uri.len; /* void */) { | |
375 if (r->uri.data[i++] == '/') { | |
376 if (++d >= dlcf->min_delete_depth && i < r->uri.len) { | |
377 goto ok; | |
378 } | |
379 } | |
380 } | |
381 | |
382 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
383 "insufficient URI depth:%i to DELETE", d); | |
384 return NGX_HTTP_CONFLICT; | |
385 } | |
386 | |
387 ok: | |
359 | 388 |
360 ngx_http_map_uri_to_path(r, &path, &root, 0); | 389 ngx_http_map_uri_to_path(r, &path, &root, 0); |
361 | 390 |
362 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | 391 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
363 "http delete filename: \"%s\"", path.data); | 392 "http delete filename: \"%s\"", path.data); |
1123 * set by ngx_pcalloc(): | 1152 * set by ngx_pcalloc(): |
1124 * | 1153 * |
1125 * conf->methods = 0; | 1154 * conf->methods = 0; |
1126 */ | 1155 */ |
1127 | 1156 |
1157 conf->min_delete_depth = NGX_CONF_UNSET; | |
1158 conf->access = NGX_CONF_UNSET_UINT; | |
1128 conf->create_full_put_path = NGX_CONF_UNSET; | 1159 conf->create_full_put_path = NGX_CONF_UNSET; |
1129 conf->access = NGX_CONF_UNSET_UINT; | |
1130 | 1160 |
1131 return conf; | 1161 return conf; |
1132 } | 1162 } |
1133 | 1163 |
1134 | 1164 |
1139 ngx_http_dav_loc_conf_t *conf = child; | 1169 ngx_http_dav_loc_conf_t *conf = child; |
1140 | 1170 |
1141 ngx_conf_merge_bitmask_value(conf->methods, prev->methods, | 1171 ngx_conf_merge_bitmask_value(conf->methods, prev->methods, |
1142 (NGX_CONF_BITMASK_SET|NGX_HTTP_DAV_OFF)); | 1172 (NGX_CONF_BITMASK_SET|NGX_HTTP_DAV_OFF)); |
1143 | 1173 |
1144 ngx_conf_merge_value(conf->create_full_put_path, prev->create_full_put_path, | 1174 ngx_conf_merge_uint_value(conf->min_delete_depth, |
1145 0); | 1175 prev->min_delete_depth, 0); |
1146 | 1176 |
1147 ngx_conf_merge_uint_value(conf->access, prev->access, 0600); | 1177 ngx_conf_merge_uint_value(conf->access, prev->access, 0600); |
1178 | |
1179 ngx_conf_merge_value(conf->create_full_put_path, | |
1180 prev->create_full_put_path, 0); | |
1148 | 1181 |
1149 return NGX_CONF_OK; | 1182 return NGX_CONF_OK; |
1150 } | 1183 } |
1151 | 1184 |
1152 | 1185 |