You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Timothy Wood <tj...@omnigroup.com> on 2013/02/25 22:47:32 UTC

If/If-Match don't work for COPY

Sending a If or If-Match header with an invalid ETag doesn't result in a 412 Precondition Failed.

<http://www.webdav.org/specs/rfc4918.html#METHOD_COPY> has an example specifically calling out preconditions on COPY (10.4.9), for example, but I'm just doing a simple If-Match.

This patch (vs our local clone of 2.4.3) resolves the issue for me, but I'm wondering if there is some case this would break.

Thanks!

-tim
 
Index: modules/dav/main/mod_dav.c
===================================================================
--- modules/dav/main/mod_dav.c	(revision 180376)
+++ modules/dav/main/mod_dav.c	(revision 180377)
@@ -2761,10 +2761,10 @@
     }
 
     /*
-     * Check If-Headers and existing locks for each resource in the source
-     * if we are performing a MOVE. We will return a 424 response with a
-     * DAV:multistatus body. The multistatus responses will contain the
-     * information about any resource that fails the validation.
+     * Check If-Headers and existing locks for each resource in the source.
+     * We will return a 424 response with a DAV:multistatus body.
+     * The multistatus responses will contain the information about any
+     * resource that fails the validation.
      *
      * We check the parent resource, too, since this is a MOVE. Moving the
      * resource effectively removes it from the parent collection, so we
@@ -2773,17 +2773,17 @@
      * If a problem occurs with the Request-URI itself, then a plain error
      * (rather than a multistatus) will be returned.
      */
-    if (is_move
-        && (err = dav_validate_request(r, resource, depth, NULL,
+    if ((err = dav_validate_request(r, resource, depth, NULL,
                                        &multi_response,
                                        DAV_VALIDATE_PARENT
                                        | DAV_VALIDATE_USE_424,
                                        NULL)) != NULL) {
         err = dav_push_error(r->pool, err->status, 0,
                              apr_psprintf(r->pool,
-                                          "Could not MOVE %s due to a failed "
+                                          "Could not %s %s due to a failed "
                                           "precondition on the source "
                                           "(e.g. locks).",
+                                          is_move ? "MOVE" : "COPY",
                                           ap_escape_html(r->pool, r->uri)),
                              err);
         return dav_handle_err(r, err, multi_response);



Re: If/If-Match don't work for COPY

Posted by Tim Bannister <is...@jellybaby.net>.
On 25 Feb 2013, at 21:56, Reindl Harald wrote:
Am 25.02.2013 22:47, schrieb Timothy Wood:
>> Sending a If or If-Match header with an invalid ETag doesn't result in a 412 Precondition Failed
> 
> why in the world should it?
…
> why would you response with a 412?

Maybe if you want to create a copy but only if you haven't lost an update? ETags are used to avoid lost updates; checking that cached data are fresh is just a common special case.

-- 
Tim Bannister – isoma@jellybaby.net


Re: If/If-Match don't work for COPY

Posted by Reindl Harald <h....@thelounge.net>.

Am 25.02.2013 22:47, schrieb Timothy Wood:
> Sending a If or If-Match header with an invalid ETag doesn't result in a 412 Precondition Failed

why in the world should it?

you get back a 200 status code and content
or a "305 Not Modified"  which you can EASY
implement in any PHP-application too as i do
it for years

why would you response with a 412?