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

Function dav_method_copymove

modules/dav/main/mod_dav.c:2758–3173  ·  view source on GitHub ↗

handle the COPY and MOVE methods */

Source from the content-addressed store, hash-verified

2756
2757/* handle the COPY and MOVE methods */
2758static int dav_method_copymove(request_rec *r, int is_move)
2759{
2760 dav_resource *resource;
2761 dav_resource *resnew;
2762 dav_auto_version_info src_av_info = { 0 };
2763 dav_auto_version_info dst_av_info = { 0 };
2764 const char *body;
2765 const char *dest;
2766 dav_error *err;
2767 dav_error *err2;
2768 dav_error *err3;
2769 dav_response *multi_response;
2770 dav_lookup_result lookup;
2771 int is_dir;
2772 int overwrite;
2773 int depth;
2774 int result;
2775 dav_lockdb *lockdb;
2776 int replace_dest;
2777 int resnew_state;
2778
2779 /* Ask repository module to resolve the resource */
2780 err = dav_get_resource(r, !is_move /* label_allowed */,
2781 0 /* use_checked_in */, &resource);
2782 if (err != NULL)
2783 return dav_handle_err(r, err, NULL);
2784
2785 /* check for any method preconditions */
2786 if (dav_run_method_precondition(r, resource, NULL, NULL, &err) != DECLINED
2787 && err) {
2788 return dav_handle_err(r, err, NULL);
2789 }
2790
2791 if (!resource->exists) {
2792 /* Apache will supply a default error for this. */
2793 return HTTP_NOT_FOUND;
2794 }
2795
2796 /* If not a file or collection resource, COPY/MOVE not allowed */
2797 /* ### allow COPY/MOVE of DeltaV resource types */
2798 if (resource->type != DAV_RESOURCE_TYPE_REGULAR) {
2799 body = apr_psprintf(r->pool,
2800 "Cannot COPY/MOVE resource %s.",
2801 ap_escape_html(r->pool, r->uri));
2802 return dav_error_response(r, HTTP_METHOD_NOT_ALLOWED, body);
2803 }
2804
2805 /* get the destination URI */
2806 dest = apr_table_get(r->headers_in, "Destination");
2807 if (dest == NULL) {
2808 /* Look in headers provided by Netscape's Roaming Profiles */
2809 const char *nscp_host = apr_table_get(r->headers_in, "Host");
2810 const char *nscp_path = apr_table_get(r->headers_in, "New-uri");
2811
2812 if (nscp_host != NULL && nscp_path != NULL)
2813 dest = apr_pstrcat(r->pool, "http://", nscp_host, nscp_path, NULL);
2814 }
2815 if (dest == NULL) {

Callers 1

dav_handlerFunction · 0.85

Calls 15

dav_get_resourceFunction · 0.85
dav_handle_errFunction · 0.85
dav_error_responseFunction · 0.85
dav_lookup_uriFunction · 0.85
dav_get_overwriteFunction · 0.85
dav_get_depthFunction · 0.85
dav_validate_requestFunction · 0.85
dav_push_errorFunction · 0.85
ap_discard_request_bodyFunction · 0.85
dav_open_lockdbFunction · 0.85
dav_unlockFunction · 0.85
dav_auto_checkoutFunction · 0.85

Tested by

no test coverage detected