dav_method_unlock: Handler to implement the DAV UNLOCK method * Returns appropriate HTTP_* response. */
| 3361 | * Returns appropriate HTTP_* response. |
| 3362 | */ |
| 3363 | static int dav_method_unlock(request_rec *r) |
| 3364 | { |
| 3365 | dav_error *err; |
| 3366 | dav_resource *resource; |
| 3367 | const dav_hooks_locks *locks_hooks; |
| 3368 | int result; |
| 3369 | const char *const_locktoken_txt; |
| 3370 | char *locktoken_txt; |
| 3371 | dav_locktoken *locktoken = NULL; |
| 3372 | int resource_state; |
| 3373 | dav_response *multi_response; |
| 3374 | |
| 3375 | /* If no locks provider, decline the request */ |
| 3376 | locks_hooks = DAV_GET_HOOKS_LOCKS(r); |
| 3377 | if (locks_hooks == NULL) |
| 3378 | return DECLINED; |
| 3379 | |
| 3380 | if ((const_locktoken_txt = apr_table_get(r->headers_in, |
| 3381 | "Lock-Token")) == NULL) { |
| 3382 | ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00596) |
| 3383 | "Unlock failed (%s): " |
| 3384 | "No Lock-Token specified in header", r->filename); |
| 3385 | return HTTP_BAD_REQUEST; |
| 3386 | } |
| 3387 | |
| 3388 | locktoken_txt = apr_pstrdup(r->pool, const_locktoken_txt); |
| 3389 | if (locktoken_txt[0] != '<') { |
| 3390 | /* ### should provide more specifics... */ |
| 3391 | return HTTP_BAD_REQUEST; |
| 3392 | } |
| 3393 | locktoken_txt++; |
| 3394 | |
| 3395 | if (locktoken_txt[strlen(locktoken_txt) - 1] != '>') { |
| 3396 | /* ### should provide more specifics... */ |
| 3397 | return HTTP_BAD_REQUEST; |
| 3398 | } |
| 3399 | locktoken_txt[strlen(locktoken_txt) - 1] = '\0'; |
| 3400 | |
| 3401 | if ((err = (*locks_hooks->parse_locktoken)(r->pool, locktoken_txt, |
| 3402 | &locktoken)) != NULL) { |
| 3403 | err = dav_push_error(r->pool, HTTP_BAD_REQUEST, 0, |
| 3404 | apr_psprintf(r->pool, |
| 3405 | "The UNLOCK on %s failed -- an " |
| 3406 | "invalid lock token was specified " |
| 3407 | "in the \"If:\" header.", |
| 3408 | ap_escape_html(r->pool, r->uri)), |
| 3409 | err); |
| 3410 | return dav_handle_err(r, err, NULL); |
| 3411 | } |
| 3412 | |
| 3413 | /* Ask repository module to resolve the resource */ |
| 3414 | err = dav_get_resource(r, 0 /* label_allowed */, 0 /* use_checked_in */, |
| 3415 | &resource); |
| 3416 | if (err != NULL) |
| 3417 | return dav_handle_err(r, err, NULL); |
| 3418 | |
| 3419 | /* check for any method preconditions */ |
| 3420 | if (dav_run_method_precondition(r, resource, NULL, NULL, &err) != DECLINED |
no test coverage detected