comparison src/http/modules/ngx_http_dav_module.c @ 272:29a6403156b0 NGINX_0_5_6

nginx 0.5.6 *) Change: now the ngx_http_index_module ignores all methods except the GET, HEAD, and POST methods. *) Feature: the ngx_http_limit_zone_module. *) Feature: the $binary_remote_addr variable. *) Feature: the "ssl_session_cache" directives of the ngx_http_ssl_module and ngx_imap_ssl_module. *) Feature: the DELETE method supports recursive removal. *) Bugfix: the byte-ranges were transferred incorrectly if the $r->sendfile() was used.
author Igor Sysoev <http://sysoev.ru>
date Tue, 09 Jan 2007 00:00:00 +0300
parents a0c9f21ee120
children c5c2b2883984
comparison
equal deleted inserted replaced
271:fcbee7dacf2b 272:29a6403156b0
17 ngx_uint_t access; 17 ngx_uint_t access;
18 } ngx_http_dav_loc_conf_t; 18 } ngx_http_dav_loc_conf_t;
19 19
20 20
21 static ngx_int_t ngx_http_dav_handler(ngx_http_request_t *r); 21 static ngx_int_t ngx_http_dav_handler(ngx_http_request_t *r);
22 static ngx_int_t ngx_http_dav_no_init(ngx_tree_ctx_t *ctx,
23 ngx_tree_ctx_t *prev);
24 static ngx_int_t ngx_http_dav_noop(ngx_tree_ctx_t *ctx, ngx_str_t *path);
25 static ngx_int_t ngx_http_dav_delete_dir(ngx_tree_ctx_t *ctx, ngx_str_t *path);
26 static ngx_int_t ngx_http_dav_delete_file(ngx_tree_ctx_t *ctx, ngx_str_t *path);
22 static void ngx_http_dav_put_handler(ngx_http_request_t *r); 27 static void ngx_http_dav_put_handler(ngx_http_request_t *r);
23 static ngx_int_t ngx_http_dav_error(ngx_http_request_t *, ngx_err_t err, 28 static ngx_int_t ngx_http_dav_error(ngx_http_request_t *, ngx_err_t err,
24 ngx_int_t not_found, char *failed, u_char *path); 29 ngx_int_t not_found, char *failed, u_char *path);
25 static ngx_int_t ngx_http_dav_location(ngx_http_request_t *r, u_char *path); 30 static ngx_int_t ngx_http_dav_location(ngx_http_request_t *r, u_char *path);
26 static char *ngx_http_dav_access(ngx_conf_t *cf, ngx_command_t *cmd, 31 static char *ngx_http_dav_access(ngx_conf_t *cf, ngx_command_t *cmd,
103 { 108 {
104 char *failed; 109 char *failed;
105 size_t root; 110 size_t root;
106 ngx_int_t rc; 111 ngx_int_t rc;
107 ngx_str_t path; 112 ngx_str_t path;
113 ngx_tree_ctx_t tree;
108 ngx_file_info_t fi; 114 ngx_file_info_t fi;
109 ngx_table_elt_t *depth; 115 ngx_table_elt_t *depth;
110 ngx_http_dav_loc_conf_t *dlcf; 116 ngx_http_dav_loc_conf_t *dlcf;
111 117
112 /* TODO: Win32 */ 118 /* TODO: Win32 */
174 || ngx_strcmp(depth->value.data, "infinity") != 0)) 180 || ngx_strcmp(depth->value.data, "infinity") != 0))
175 { 181 {
176 return NGX_HTTP_BAD_REQUEST; 182 return NGX_HTTP_BAD_REQUEST;
177 } 183 }
178 184
179 if (ngx_delete_dir(path.data) != NGX_FILE_ERROR) { 185 path.len -= 2;
180 return NGX_HTTP_NO_CONTENT; 186
187 tree.init_handler = ngx_http_dav_no_init;
188 tree.file_handler = ngx_http_dav_delete_file;
189 tree.pre_tree_handler = ngx_http_dav_noop;
190 tree.post_tree_handler = ngx_http_dav_delete_dir;
191 tree.spec_handler = ngx_http_dav_delete_file;
192 tree.data = NULL;
193 tree.size = 0;
194 tree.log = r->connection->log;
195
196 if (ngx_walk_tree(&tree, &path) == NGX_OK) {
197
198 if (ngx_delete_dir(path.data) != NGX_FILE_ERROR) {
199 return NGX_HTTP_NO_CONTENT;
200 }
201
181 } 202 }
182 203
183 failed = ngx_delete_dir_n; 204 failed = ngx_delete_dir_n;
184 205
185 } else { 206 } else {
243 return ngx_http_dav_error(r, ngx_errno, NGX_HTTP_CONFLICT, 264 return ngx_http_dav_error(r, ngx_errno, NGX_HTTP_CONFLICT,
244 ngx_create_dir_n, path.data); 265 ngx_create_dir_n, path.data);
245 } 266 }
246 267
247 return NGX_DECLINED; 268 return NGX_DECLINED;
269 }
270
271
272 static ngx_int_t
273 ngx_http_dav_no_init(ngx_tree_ctx_t *ctx, ngx_tree_ctx_t *prev)
274 {
275 return NGX_OK;
276 }
277
278
279 static ngx_int_t
280 ngx_http_dav_noop(ngx_tree_ctx_t *ctx, ngx_str_t *path)
281 {
282 return NGX_OK;
283 }
284
285
286 static ngx_int_t
287 ngx_http_dav_delete_dir(ngx_tree_ctx_t *ctx, ngx_str_t *path)
288 {
289 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, ctx->log, 0,
290 "http delete dir: \"%s\"", path->data);
291
292 ngx_delete_dir(path->data);
293
294 return NGX_OK;
295 }
296
297
298 static ngx_int_t
299 ngx_http_dav_delete_file(ngx_tree_ctx_t *ctx, ngx_str_t *path)
300 {
301 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, ctx->log, 0,
302 "http delete file: \"%s\"", path->data);
303
304 ngx_delete_file(path->data);
305
306 return NGX_OK;
248 } 307 }
249 308
250 309
251 static void 310 static void
252 ngx_http_dav_put_handler(ngx_http_request_t *r) 311 ngx_http_dav_put_handler(ngx_http_request_t *r)