MCPcopy Create free account
hub / github.com/apache/httpd / dav_method_mkcol

Function dav_method_mkcol

modules/dav/main/mod_dav.c:2636–2755  ·  view source on GitHub ↗

handle the MKCOL method */

Source from the content-addressed store, hash-verified

2634
2635/* handle the MKCOL method */
2636static int dav_method_mkcol(request_rec *r)
2637{
2638 dav_resource *resource;
2639 int resource_state;
2640 dav_auto_version_info av_info;
2641 const dav_hooks_locks *locks_hooks = DAV_GET_HOOKS_LOCKS(r);
2642 dav_error *err;
2643 dav_error *err2;
2644 int result;
2645 dav_response *multi_status;
2646
2647 /* handle the request body */
2648 /* ### this may move lower once we start processing bodies */
2649 if ((result = process_mkcol_body(r)) != OK) {
2650 return result;
2651 }
2652
2653 /* Ask repository module to resolve the resource */
2654 err = dav_get_resource(r, 0 /* label_allowed */, 0 /* use_checked_in */,
2655 &resource);
2656 if (err != NULL)
2657 return dav_handle_err(r, err, NULL);
2658
2659 /* check for any method preconditions */
2660 if (dav_run_method_precondition(r, resource, NULL, NULL, &err) != DECLINED
2661 && err) {
2662 return dav_handle_err(r, err, NULL);
2663 }
2664
2665 if (resource->exists) {
2666 /* oops. something was already there! */
2667
2668 /* Apache will supply a default error for this. */
2669 /* ### we should provide a specific error message! */
2670 return HTTP_METHOD_NOT_ALLOWED;
2671 }
2672
2673 resource_state = dav_get_resource_state(r, resource);
2674
2675 /*
2676 * Check If-Headers and existing locks.
2677 *
2678 * Note: depth == 0 normally requires no multistatus response. However,
2679 * if we pass DAV_VALIDATE_PARENT, then we could get an error on a URI
2680 * other than the Request-URI, thereby requiring a multistatus.
2681 *
2682 * If the resource does not exist (DAV_RESOURCE_NULL), then we must
2683 * check the resource *and* its parent. If the resource exists or is
2684 * a locknull resource, then we check only the resource.
2685 */
2686 if ((err = dav_validate_request(r, resource, 0, NULL, &multi_status,
2687 resource_state == DAV_RESOURCE_NULL ?
2688 DAV_VALIDATE_PARENT :
2689 DAV_VALIDATE_RESOURCE, NULL)) != NULL) {
2690 /* ### add a higher-level description? */
2691 return dav_handle_err(r, err, multi_status);
2692 }
2693

Callers 1

dav_handlerFunction · 0.85

Calls 11

process_mkcol_bodyFunction · 0.85
dav_get_resourceFunction · 0.85
dav_handle_errFunction · 0.85
dav_get_resource_stateFunction · 0.85
dav_validate_requestFunction · 0.85
dav_auto_checkoutFunction · 0.85
dav_auto_checkinFunction · 0.85
dav_push_errorFunction · 0.85
dav_log_errFunction · 0.85
dav_notify_createdFunction · 0.85
dav_createdFunction · 0.85

Tested by

no test coverage detected