comparison src/http/modules/ngx_http_dav_module.c @ 635:e67b227c8dbb default tip

Merge with current.
author Maxim Dounin <mdounin@mdounin.ru>
date Mon, 25 Apr 2011 04:07:55 +0400
parents bc110f60c0de
children
comparison
equal deleted inserted replaced
578:f3a9e57d2e17 635:e67b227c8dbb
144 ngx_http_dav_handler(ngx_http_request_t *r) 144 ngx_http_dav_handler(ngx_http_request_t *r)
145 { 145 {
146 ngx_int_t rc; 146 ngx_int_t rc;
147 ngx_http_dav_loc_conf_t *dlcf; 147 ngx_http_dav_loc_conf_t *dlcf;
148 148
149 if (r->zero_in_uri) {
150 return NGX_DECLINED;
151 }
152
153 dlcf = ngx_http_get_module_loc_conf(r, ngx_http_dav_module); 149 dlcf = ngx_http_get_module_loc_conf(r, ngx_http_dav_module);
154 150
155 if (!(r->method & dlcf->methods)) { 151 if (!(r->method & dlcf->methods)) {
156 return NGX_DECLINED; 152 return NGX_DECLINED;
157 } 153 }
323 ngx_http_map_uri_to_path(r, &path, &root, 0); 319 ngx_http_map_uri_to_path(r, &path, &root, 0);
324 320
325 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, 321 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
326 "http delete filename: \"%s\"", path.data); 322 "http delete filename: \"%s\"", path.data);
327 323
328 if (ngx_file_info(path.data, &fi) == NGX_FILE_ERROR) { 324 if (ngx_link_info(path.data, &fi) == NGX_FILE_ERROR) {
329 err = ngx_errno; 325 err = ngx_errno;
330 326
331 rc = (err == NGX_ENOTDIR) ? NGX_HTTP_CONFLICT : NGX_HTTP_NOT_FOUND; 327 rc = (err == NGX_ENOTDIR) ? NGX_HTTP_CONFLICT : NGX_HTTP_NOT_FOUND;
332 328
333 return ngx_http_dav_error(r->connection->log, err, 329 return ngx_http_dav_error(r->connection->log, err,
334 rc, ngx_file_info_n, path.data); 330 rc, ngx_link_info_n, path.data);
335 } 331 }
336 332
337 if (ngx_is_dir(&fi)) { 333 if (ngx_is_dir(&fi)) {
338 334
339 if (r->uri.data[r->uri.len - 1] != '/') { 335 if (r->uri.data[r->uri.len - 1] != '/') {
356 352
357 } else { 353 } else {
358 354
359 /* 355 /*
360 * we do not need to test (r->uri.data[r->uri.len - 1] == '/') 356 * we do not need to test (r->uri.data[r->uri.len - 1] == '/')
361 * because ngx_file_info("/file/") returned NGX_ENOTDIR above 357 * because ngx_link_info("/file/") returned NGX_ENOTDIR above
362 */ 358 */
363 359
364 depth = ngx_http_dav_depth(r, 0); 360 depth = ngx_http_dav_depth(r, 0);
365 361
366 if (depth != 0 && depth != NGX_HTTP_DAV_INFINITY_DEPTH) { 362 if (depth != 0 && depth != NGX_HTTP_DAV_INFINITY_DEPTH) {
537 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, 533 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
538 "client sent no \"Destination\" header"); 534 "client sent no \"Destination\" header");
539 return NGX_HTTP_BAD_REQUEST; 535 return NGX_HTTP_BAD_REQUEST;
540 } 536 }
541 537
538 p = dest->value.data;
539 /* there is always '\0' even after empty header value */
540 if (p[0] == '/') {
541 last = p + dest->value.len;
542 goto destination_done;
543 }
544
542 len = r->headers_in.server.len; 545 len = r->headers_in.server.len;
543 546
544 if (len == 0) { 547 if (len == 0) {
545 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, 548 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
546 "client sent no \"Host\" header"); 549 "client sent no \"Host\" header");
683 } 686 }
684 687
685 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, 688 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
686 "http copy to: \"%s\"", copy.path.data); 689 "http copy to: \"%s\"", copy.path.data);
687 690
688 if (ngx_file_info(copy.path.data, &fi) == NGX_FILE_ERROR) { 691 if (ngx_link_info(copy.path.data, &fi) == NGX_FILE_ERROR) {
689 err = ngx_errno; 692 err = ngx_errno;
690 693
691 if (err != NGX_ENOENT) { 694 if (err != NGX_ENOENT) {
692 return ngx_http_dav_error(r->connection->log, err, 695 return ngx_http_dav_error(r->connection->log, err,
693 NGX_HTTP_NOT_FOUND, ngx_file_info_n, 696 NGX_HTTP_NOT_FOUND, ngx_link_info_n,
694 copy.path.data); 697 copy.path.data);
695 } 698 }
696 699
697 /* destination does not exist */ 700 /* destination does not exist */
698 701
717 } 720 }
718 721
719 dir = ngx_is_dir(&fi); 722 dir = ngx_is_dir(&fi);
720 } 723 }
721 724
722 if (ngx_file_info(path.data, &fi) == NGX_FILE_ERROR) { 725 if (ngx_link_info(path.data, &fi) == NGX_FILE_ERROR) {
723 return ngx_http_dav_error(r->connection->log, ngx_errno, 726 return ngx_http_dav_error(r->connection->log, ngx_errno,
724 NGX_HTTP_NOT_FOUND, ngx_file_info_n, 727 NGX_HTTP_NOT_FOUND, ngx_link_info_n,
725 path.data); 728 path.data);
726 } 729 }
727 730
728 if (ngx_is_dir(&fi)) { 731 if (ngx_is_dir(&fi)) {
729 732