MCPcopy Index your code
hub / github.com/apache/httpd / dav_method_lock

Function dav_method_lock

modules/dav/main/mod_dav.c:3178–3358  ·  view source on GitHub ↗

dav_method_lock: Handler to implement the DAV LOCK method * Returns appropriate HTTP_* response. */

Source from the content-addressed store, hash-verified

3176 * Returns appropriate HTTP_* response.
3177 */
3178static int dav_method_lock(request_rec *r)
3179{
3180 dav_error *err;
3181 dav_resource *resource;
3182 dav_resource *parent;
3183 const dav_hooks_locks *locks_hooks;
3184 int result;
3185 int depth;
3186 int new_lock_request = 0;
3187 apr_xml_doc *doc;
3188 dav_lock *lock;
3189 dav_response *multi_response = NULL;
3190 dav_lockdb *lockdb;
3191 int resource_state;
3192
3193 /* If no locks provider, decline the request */
3194 locks_hooks = DAV_GET_HOOKS_LOCKS(r);
3195 if (locks_hooks == NULL)
3196 return DECLINED;
3197
3198 if ((result = ap_xml_parse_input(r, &doc)) != OK)
3199 return result;
3200
3201 depth = dav_get_depth(r, DAV_INFINITY);
3202 if (depth != 0 && depth != DAV_INFINITY) {
3203 ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00595)
3204 "Depth must be 0 or \"infinity\" for LOCK.");
3205 return HTTP_BAD_REQUEST;
3206 }
3207
3208 /* Ask repository module to resolve the resource */
3209 err = dav_get_resource(r, 0 /* label_allowed */, 0 /* use_checked_in */,
3210 &resource);
3211 if (err != NULL)
3212 return dav_handle_err(r, err, NULL);
3213
3214 /* check for any method preconditions */
3215 if (dav_run_method_precondition(r, resource, NULL, doc, &err) != DECLINED
3216 && err) {
3217 return dav_handle_err(r, err, NULL);
3218 }
3219
3220 /* Check if parent collection exists */
3221 if ((err = resource->hooks->get_parent_resource(resource, &parent)) != NULL) {
3222 /* ### add a higher-level description? */
3223 return dav_handle_err(r, err, NULL);
3224 }
3225 if (parent && (!parent->exists || parent->collection != 1)) {
3226 err = dav_new_error(r->pool, HTTP_CONFLICT, 0, 0,
3227 apr_psprintf(r->pool,
3228 "The parent resource of %s does not "
3229 "exist or is not a collection.",
3230 ap_escape_html(r->pool, r->uri)));
3231 return dav_handle_err(r, err, NULL);
3232 }
3233
3234 /*
3235 * Open writable. Unless an error occurs, we'll be

Callers 1

dav_handlerFunction · 0.85

Calls 15

ap_xml_parse_inputFunction · 0.85
dav_get_depthFunction · 0.85
dav_get_resourceFunction · 0.85
dav_handle_errFunction · 0.85
dav_new_errorFunction · 0.85
dav_lock_parse_lockinfoFunction · 0.85
dav_get_resource_stateFunction · 0.85
dav_validate_requestFunction · 0.85
dav_push_errorFunction · 0.85
dav_get_locktoken_listFunction · 0.85
dav_get_timeoutFunction · 0.85
ap_get_module_configFunction · 0.85

Tested by

no test coverage detected