handle the DELETE method */
| 1269 | |
| 1270 | /* handle the DELETE method */ |
| 1271 | static int dav_method_delete(request_rec *r) |
| 1272 | { |
| 1273 | dav_resource *resource; |
| 1274 | dav_auto_version_info av_info; |
| 1275 | dav_error *err; |
| 1276 | dav_error *err2; |
| 1277 | dav_response *multi_response; |
| 1278 | int result; |
| 1279 | int depth; |
| 1280 | |
| 1281 | /* We don't use the request body right now, so torch it. */ |
| 1282 | if ((result = ap_discard_request_body(r)) != OK) { |
| 1283 | return result; |
| 1284 | } |
| 1285 | |
| 1286 | /* Ask repository module to resolve the resource */ |
| 1287 | err = dav_get_resource(r, 0 /* label_allowed */, 0 /* use_checked_in */, |
| 1288 | &resource); |
| 1289 | if (err != NULL) |
| 1290 | return dav_handle_err(r, err, NULL); |
| 1291 | |
| 1292 | /* check for any method preconditions */ |
| 1293 | if (dav_run_method_precondition(r, resource, NULL, NULL, &err) != DECLINED |
| 1294 | && err) { |
| 1295 | return dav_handle_err(r, err, NULL); |
| 1296 | } |
| 1297 | |
| 1298 | if (!resource->exists) { |
| 1299 | /* Apache will supply a default error for this. */ |
| 1300 | return HTTP_NOT_FOUND; |
| 1301 | } |
| 1302 | |
| 1303 | /* 2518 says that depth must be infinity only for collections. |
| 1304 | * For non-collections, depth is ignored, unless it is an illegal value (1). |
| 1305 | */ |
| 1306 | depth = dav_get_depth(r, DAV_INFINITY); |
| 1307 | |
| 1308 | if (resource->collection && depth != DAV_INFINITY) { |
| 1309 | /* This supplies additional information for the default message. */ |
| 1310 | ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00582) |
| 1311 | "Depth must be \"infinity\" for DELETE of a collection."); |
| 1312 | return HTTP_BAD_REQUEST; |
| 1313 | } |
| 1314 | |
| 1315 | if (!resource->collection && depth == 1) { |
| 1316 | /* This supplies additional information for the default message. */ |
| 1317 | ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00583) |
| 1318 | "Depth of \"1\" is not allowed for DELETE."); |
| 1319 | return HTTP_BAD_REQUEST; |
| 1320 | } |
| 1321 | |
| 1322 | /* |
| 1323 | ** If any resources fail the lock/If: conditions, then we must fail |
| 1324 | ** the delete. Each of the failing resources will be listed within |
| 1325 | ** a DAV:multistatus body, wrapped into a 424 response. |
| 1326 | ** |
| 1327 | ** Note that a failure on the resource itself does not generate a |
| 1328 | ** multistatus response -- only internal members/collections. |
no test coverage detected