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

Function dav_method_merge

modules/dav/main/mod_dav.c:4584–4729  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4582}
4583
4584static int dav_method_merge(request_rec *r)
4585{
4586 dav_resource *resource;
4587 dav_resource *source_resource;
4588 const dav_hooks_vsn *vsn_hooks = DAV_GET_HOOKS_VSN(r);
4589 dav_error *err;
4590 int result;
4591 apr_xml_doc *doc;
4592 apr_xml_elem *source_elem;
4593 apr_xml_elem *href_elem;
4594 apr_xml_elem *prop_elem;
4595 const char *source;
4596 int no_auto_merge;
4597 int no_checkout;
4598 dav_lookup_result lookup;
4599
4600 /* If no versioning provider, decline the request */
4601 if (vsn_hooks == NULL)
4602 return DECLINED;
4603
4604 if ((result = ap_xml_parse_input(r, &doc)) != OK)
4605 return result;
4606
4607 if (doc == NULL || !dav_validate_root(doc, "merge")) {
4608 /* This supplies additional information for the default msg. */
4609 ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00616)
4610 "The request body must be present and must be a "
4611 "DAV:merge element.");
4612 return HTTP_BAD_REQUEST;
4613 }
4614
4615 if ((source_elem = dav_find_child(doc->root, "source")) == NULL) {
4616 /* This supplies additional information for the default msg. */
4617 ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00617)
4618 "The DAV:merge element must contain a DAV:source "
4619 "element.");
4620 return HTTP_BAD_REQUEST;
4621 }
4622 if ((href_elem = dav_find_child(source_elem, "href")) == NULL) {
4623 /* This supplies additional information for the default msg. */
4624 ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00618)
4625 "The DAV:source element must contain a DAV:href "
4626 "element.");
4627 return HTTP_BAD_REQUEST;
4628 }
4629 source = dav_xml_get_cdata(href_elem, r->pool, 1 /* strip_white */);
4630
4631 /* get a subrequest for the source, so that we can get a dav_resource
4632 for that source. */
4633 lookup = dav_lookup_uri(source, r, 0 /* must_be_absolute */);
4634 if (lookup.rnew == NULL) {
4635 if (lookup.err.status == HTTP_BAD_REQUEST) {
4636 /* This supplies additional information for the default message. */
4637 ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00619)
4638 "%s", lookup.err.desc);
4639 return HTTP_BAD_REQUEST;
4640 }
4641

Callers 1

dav_handlerFunction · 0.85

Calls 10

ap_xml_parse_inputFunction · 0.85
dav_validate_rootFunction · 0.85
dav_find_childFunction · 0.85
dav_xml_get_cdataFunction · 0.85
dav_lookup_uriFunction · 0.85
dav_error_responseFunction · 0.85
dav_get_resourceFunction · 0.85
dav_handle_errFunction · 0.85
ap_set_content_typeFunction · 0.85
dav_push_errorFunction · 0.85

Tested by

no test coverage detected