comparison src/http/modules/ngx_http_dav_module.c @ 1820:559fedc0c78a

change order
author Igor Sysoev <igor@sysoev.ru>
date Thu, 03 Jan 2008 19:18:25 +0000
parents 0f907513dd3c
children 252110065e0a
comparison
equal deleted inserted replaced
1819:0f907513dd3c 1820:559fedc0c78a
36 static ngx_int_t ngx_http_dav_handler(ngx_http_request_t *r); 36 static ngx_int_t ngx_http_dav_handler(ngx_http_request_t *r);
37 37
38 static void ngx_http_dav_put_handler(ngx_http_request_t *r); 38 static void ngx_http_dav_put_handler(ngx_http_request_t *r);
39 39
40 static ngx_int_t ngx_http_dav_delete_handler(ngx_http_request_t *r); 40 static ngx_int_t ngx_http_dav_delete_handler(ngx_http_request_t *r);
41 static ngx_int_t ngx_http_dav_noop(ngx_tree_ctx_t *ctx, ngx_str_t *path); 41 static ngx_int_t ngx_http_dav_delete_path(ngx_http_request_t *r,
42 ngx_str_t *path, ngx_uint_t dir);
42 static ngx_int_t ngx_http_dav_delete_dir(ngx_tree_ctx_t *ctx, ngx_str_t *path); 43 static ngx_int_t ngx_http_dav_delete_dir(ngx_tree_ctx_t *ctx, ngx_str_t *path);
43 static ngx_int_t ngx_http_dav_delete_file(ngx_tree_ctx_t *ctx, ngx_str_t *path); 44 static ngx_int_t ngx_http_dav_delete_file(ngx_tree_ctx_t *ctx, ngx_str_t *path);
45 static ngx_int_t ngx_http_dav_noop(ngx_tree_ctx_t *ctx, ngx_str_t *path);
44 46
45 static ngx_int_t ngx_http_dav_mkcol_handler(ngx_http_request_t *r, 47 static ngx_int_t ngx_http_dav_mkcol_handler(ngx_http_request_t *r,
46 ngx_http_dav_loc_conf_t *dlcf); 48 ngx_http_dav_loc_conf_t *dlcf);
47 49
48 static ngx_int_t ngx_http_dav_copy_move_handler(ngx_http_request_t *r); 50 static ngx_int_t ngx_http_dav_copy_move_handler(ngx_http_request_t *r);
49 static ngx_int_t ngx_http_dav_copy_dir(ngx_tree_ctx_t *ctx, ngx_str_t *path); 51 static ngx_int_t ngx_http_dav_copy_dir(ngx_tree_ctx_t *ctx, ngx_str_t *path);
50 static ngx_int_t ngx_http_dav_copy_dir_time(ngx_tree_ctx_t *ctx, 52 static ngx_int_t ngx_http_dav_copy_dir_time(ngx_tree_ctx_t *ctx,
51 ngx_str_t *path); 53 ngx_str_t *path);
52 static ngx_int_t ngx_http_dav_copy_file(ngx_tree_ctx_t *ctx, ngx_str_t *path); 54 static ngx_int_t ngx_http_dav_copy_file(ngx_tree_ctx_t *ctx, ngx_str_t *path);
53 55
54 static ngx_int_t ngx_http_dav_delete_path(ngx_http_request_t *r,
55 ngx_str_t *path, ngx_uint_t dir);
56 static ngx_int_t ngx_http_dav_depth(ngx_http_request_t *r, ngx_int_t dflt); 56 static ngx_int_t ngx_http_dav_depth(ngx_http_request_t *r, ngx_int_t dflt);
57 static ngx_int_t ngx_http_dav_error(ngx_log_t *log, ngx_err_t err, 57 static ngx_int_t ngx_http_dav_error(ngx_log_t *log, ngx_err_t err,
58 ngx_int_t not_found, char *failed, u_char *path); 58 ngx_int_t not_found, char *failed, u_char *path);
59 static ngx_int_t ngx_http_dav_location(ngx_http_request_t *r, u_char *path); 59 static ngx_int_t ngx_http_dav_location(ngx_http_request_t *r, u_char *path);
60 static void *ngx_http_dav_create_loc_conf(ngx_conf_t *cf); 60 static void *ngx_http_dav_create_loc_conf(ngx_conf_t *cf);
442 return rc; 442 return rc;
443 } 443 }
444 444
445 445
446 static ngx_int_t 446 static ngx_int_t
447 ngx_http_dav_noop(ngx_tree_ctx_t *ctx, ngx_str_t *path) 447 ngx_http_dav_delete_path(ngx_http_request_t *r, ngx_str_t *path, ngx_uint_t dir)
448 { 448 {
449 return NGX_OK; 449 char *failed;
450 ngx_tree_ctx_t tree;
451
452 if (dir) {
453
454 tree.init_handler = NULL;
455 tree.file_handler = ngx_http_dav_delete_file;
456 tree.pre_tree_handler = ngx_http_dav_noop;
457 tree.post_tree_handler = ngx_http_dav_delete_dir;
458 tree.spec_handler = ngx_http_dav_delete_file;
459 tree.data = NULL;
460 tree.alloc = 0;
461 tree.log = r->connection->log;
462
463 /* TODO: 207 */
464
465 if (ngx_walk_tree(&tree, path) != NGX_OK) {
466 return NGX_HTTP_INTERNAL_SERVER_ERROR;
467 }
468
469 if (ngx_delete_dir(path->data) != NGX_FILE_ERROR) {
470 return NGX_OK;
471 }
472
473 failed = ngx_delete_dir_n;
474
475 } else {
476
477 if (ngx_delete_file(path->data) != NGX_FILE_ERROR) {
478 return NGX_OK;
479 }
480
481 failed = ngx_delete_file_n;
482 }
483
484 return ngx_http_dav_error(r->connection->log, ngx_errno,
485 NGX_HTTP_NOT_FOUND, failed, path->data);
450 } 486 }
451 487
452 488
453 static ngx_int_t 489 static ngx_int_t
454 ngx_http_dav_delete_dir(ngx_tree_ctx_t *ctx, ngx_str_t *path) 490 ngx_http_dav_delete_dir(ngx_tree_ctx_t *ctx, ngx_str_t *path)
480 516
481 (void) ngx_http_dav_error(ctx->log, ngx_errno, 0, ngx_delete_file_n, 517 (void) ngx_http_dav_error(ctx->log, ngx_errno, 0, ngx_delete_file_n,
482 path->data); 518 path->data);
483 } 519 }
484 520
521 return NGX_OK;
522 }
523
524
525 static ngx_int_t
526 ngx_http_dav_noop(ngx_tree_ctx_t *ctx, ngx_str_t *path)
527 {
485 return NGX_OK; 528 return NGX_OK;
486 } 529 }
487 530
488 531
489 static ngx_int_t 532 static ngx_int_t
985 return NGX_OK; 1028 return NGX_OK;
986 } 1029 }
987 1030
988 1031
989 static ngx_int_t 1032 static ngx_int_t
990 ngx_http_dav_delete_path(ngx_http_request_t *r, ngx_str_t *path, ngx_uint_t dir)
991 {
992 char *failed;
993 ngx_tree_ctx_t tree;
994
995 if (dir) {
996
997 tree.init_handler = NULL;
998 tree.file_handler = ngx_http_dav_delete_file;
999 tree.pre_tree_handler = ngx_http_dav_noop;
1000 tree.post_tree_handler = ngx_http_dav_delete_dir;
1001 tree.spec_handler = ngx_http_dav_delete_file;
1002 tree.data = NULL;
1003 tree.alloc = 0;
1004 tree.log = r->connection->log;
1005
1006 /* TODO: 207 */
1007
1008 if (ngx_walk_tree(&tree, path) != NGX_OK) {
1009 return NGX_HTTP_INTERNAL_SERVER_ERROR;
1010 }
1011
1012 if (ngx_delete_dir(path->data) != NGX_FILE_ERROR) {
1013 return NGX_OK;
1014 }
1015
1016 failed = ngx_delete_dir_n;
1017
1018 } else {
1019
1020 if (ngx_delete_file(path->data) != NGX_FILE_ERROR) {
1021 return NGX_OK;
1022 }
1023
1024 failed = ngx_delete_file_n;
1025 }
1026
1027 return ngx_http_dav_error(r->connection->log, ngx_errno,
1028 NGX_HTTP_NOT_FOUND, failed, path->data);
1029 }
1030
1031
1032 static ngx_int_t
1033 ngx_http_dav_depth(ngx_http_request_t *r, ngx_int_t dflt) 1033 ngx_http_dav_depth(ngx_http_request_t *r, ngx_int_t dflt)
1034 { 1034 {
1035 ngx_table_elt_t *depth; 1035 ngx_table_elt_t *depth;
1036 1036
1037 depth = r->headers_in.depth; 1037 depth = r->headers_in.depth;