* 20200702.2 (2.5.1-dev) Add dav_get_resource().
* 20200703.0 (2.5.1-dev) Remove ap_md5digest(), ap_md5contextTo64(),
* ContentDigest directive.
+ * 20200705.0 (2.5.1-dev) Update method_precondition hook.
*/
#define MODULE_MAGIC_COOKIE 0x41503235UL /* "AP25" */
#ifndef MODULE_MAGIC_NUMBER_MAJOR
-#define MODULE_MAGIC_NUMBER_MAJOR 20200703
+#define MODULE_MAGIC_NUMBER_MAJOR 20200705
#endif
#define MODULE_MAGIC_NUMBER_MINOR 0 /* 0...n */
}
#endif
+ /* check for any method preconditions */
+ if (dav_run_method_precondition(ctx->r, NULL, wres->resource, ctx->doc, &err) != DECLINED
+ && err) {
+ apr_pool_clear(ctx->scratchpool);
+ return NULL;
+ }
+
/*
** Note: ctx->doc can only be NULL for DAV_PROPFIND_IS_ALLPROP. Since
** dav_get_allprops() does not need to do namespace translation,
/* input: */
dav_walk_params w;
+ /* original request */
+ request_rec *r;
+
/* label being manipulated */
const char *label;
dav_label_walker_ctx *ctx = wres->walk_ctx;
dav_error *err = NULL;
+ /* check for any method preconditions */
+ if (dav_run_method_precondition(ctx->r, NULL, wres->resource, NULL, &err) != DECLINED
+ && err) {
+ /* precondition failed, dropping through */
+ }
+
/* Check the state of the resource: must be a version or
* non-checkedout version selector
*/
/* ### need a general mechanism for reporting precondition violations
* ### (should be returning XML document for 403/409 responses)
*/
- if (wres->resource->type != DAV_RESOURCE_TYPE_VERSION &&
+ else if (wres->resource->type != DAV_RESOURCE_TYPE_VERSION &&
(wres->resource->type != DAV_RESOURCE_TYPE_REGULAR
|| !wres->resource->versioned)) {
err = dav_new_error(ctx->w.pool, HTTP_CONFLICT, 0, 0,
ctx.w.walk_ctx = &ctx;
ctx.w.pool = r->pool;
ctx.w.root = resource;
+ ctx.r = r;
ctx.vsn_hooks = vsn_hooks;
err = (*resource->hooks->walk)(&ctx.w, depth, &multi_status);
APR_IMPLEMENT_EXTERNAL_HOOK_RUN_FIRST(dav, DAV, int, method_precondition,
(request_rec *r,
- dav_resource *src, dav_resource *dest,
+ dav_resource *src, const dav_resource *dest,
const apr_xml_doc *doc,
dav_error **err),
(r, src, dest, doc, err), DECLINED)
** the non-XML body of a request should register an input filter to do so
** within this hook.
**
- ** Methods like PUT will supply a single src resource, and the dest will
+ ** Methods like PUT will supply a single src resource, and the dst will
** be NULL.
**
** Methods like COPY or MOVE will trigger this hook twice. The first
** will supply a source and destination. This allows preconditions on the
** source resource to be verified before making an attempt to get the
** destination resource.
+ **
+ ** Methods like PROPFIND and LABEL will trigger this hook initially for
+ ** the src resource, and then subsequently for each resource that has
+ ** been walked during processing, with the walked resource passed in dst,
+ ** and NULL passed in src.
+ **
+ ** As a rule, the src resource originates from a request that has passed
+ ** through httpd's authn/authz hooks, while the dst resource has not.
*/
APR_DECLARE_EXTERNAL_HOOK(dav, DAV, int, method_precondition,
(request_rec *r,
- dav_resource *src, dav_resource *dst,
+ dav_resource *src, const dav_resource *dst,
const apr_xml_doc *doc, dav_error **err))