comparison src/http/modules/ngx_http_dav_module.c @ 1819:0f907513dd3c

change status code, add log message, and test collection URI
author Igor Sysoev <igor@sysoev.ru>
date Thu, 03 Jan 2008 19:13:04 +0000
parents ae7affa52ec0
children 559fedc0c78a
comparison
equal deleted inserted replaced
1818:ae7affa52ec0 1819:0f907513dd3c
487 487
488 488
489 static ngx_int_t 489 static ngx_int_t
490 ngx_http_dav_mkcol_handler(ngx_http_request_t *r, ngx_http_dav_loc_conf_t *dlcf) 490 ngx_http_dav_mkcol_handler(ngx_http_request_t *r, ngx_http_dav_loc_conf_t *dlcf)
491 { 491 {
492 u_char *p;
492 size_t root; 493 size_t root;
493 ngx_int_t rc;
494 ngx_str_t path; 494 ngx_str_t path;
495 495
496 if (r->headers_in.content_length_n > 0) { 496 if (r->headers_in.content_length_n > 0) {
497 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
498 "MKCOL with body is unsupported");
497 return NGX_HTTP_UNSUPPORTED_MEDIA_TYPE; 499 return NGX_HTTP_UNSUPPORTED_MEDIA_TYPE;
498 } 500 }
499 501
500 rc = ngx_http_discard_request_body(r); 502 if (r->uri.data[r->uri.len - 1] != '/') {
501 503 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
502 if (rc != NGX_OK) { 504 "MKCOL can create a collection only");
503 return rc; 505 return NGX_HTTP_CONFLICT;
504 } 506 }
505 507
506 ngx_http_map_uri_to_path(r, &path, &root, 0); 508 p = ngx_http_map_uri_to_path(r, &path, &root, 0);
509
510 *(p - 1) = '\0';
507 511
508 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, 512 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
509 "http mkcol path: \"%s\"", path.data); 513 "http mkcol path: \"%s\"", path.data);
510 514
511 if (ngx_create_dir(path.data, ngx_dir_access(dlcf->access)) 515 if (ngx_create_dir(path.data, ngx_dir_access(dlcf->access))
517 521
518 return NGX_HTTP_CREATED; 522 return NGX_HTTP_CREATED;
519 } 523 }
520 524
521 return ngx_http_dav_error(r->connection->log, ngx_errno, 525 return ngx_http_dav_error(r->connection->log, ngx_errno,
522 NGX_HTTP_BAD_REQUEST, ngx_create_dir_n, 526 NGX_HTTP_CONFLICT, ngx_create_dir_n, path.data);
523 path.data);
524 } 527 }
525 528
526 529
527 static ngx_int_t 530 static ngx_int_t
528 ngx_http_dav_copy_move_handler(ngx_http_request_t *r) 531 ngx_http_dav_copy_move_handler(ngx_http_request_t *r)