You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by ni...@apache.org on 2007/12/29 20:38:52 UTC
svn commit: r607466 - in /httpd/httpd/trunk: CHANGES modules/dav/main/util.c
Author: niq
Date: Sat Dec 29 11:38:51 2007
New Revision: 607466
URL: http://svn.apache.org/viewvc?rev=607466&view=rev
Log:
mod_dav: Fix evaluation of If-Match * and If-None-Match * conditionals.
PR 38034
Patch by Paritosh Shah
Explanation by Werner Baumann
Modified:
httpd/httpd/trunk/CHANGES
httpd/httpd/trunk/modules/dav/main/util.c
Modified: httpd/httpd/trunk/CHANGES
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/CHANGES?rev=607466&r1=607465&r2=607466&view=diff
==============================================================================
--- httpd/httpd/trunk/CHANGES [utf-8] (original)
+++ httpd/httpd/trunk/CHANGES [utf-8] Sat Dec 29 11:38:51 2007
@@ -16,6 +16,9 @@
Prevent crash in balancer manager if invalid balancer name is passed
as parameter. Reported by SecurityReason. [Ruediger Pluem]
+ *) mod_dav: Fix evaluation of If-Match * and If-None-Match * conditionals.
+ PR 38034 [Paritosh Shah <shah.paritosh gmail.com>]
+
*) mod_dav: Adjust etag generation to produce identical results on 32-bit
and 64-bit platforms and avoid a regression with conditional PUT's on lock
and etag. PR 44152.
Modified: httpd/httpd/trunk/modules/dav/main/util.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/dav/main/util.c?rev=607466&r1=607465&r2=607466&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/dav/main/util.c (original)
+++ httpd/httpd/trunk/modules/dav/main/util.c Sat Dec 29 11:38:51 2007
@@ -1404,6 +1404,37 @@
return NULL;
}
+/* If-* header checking */
+static int dav_meets_conditions(request_rec *r, int resource_state)
+{
+ const char *if_match, *if_none_match;
+ int retVal;
+
+ /* If-Match '*' fix. Resource existence not checked by ap_meets_conditions.
+ * If-Match '*' request should succeed only if the resource exists. */
+ if ((if_match = apr_table_get(r->headers_in, "If-Match")) != NULL) {
+ if(if_match[0] == '*' && resource_state != DAV_RESOURCE_EXISTS)
+ return HTTP_PRECONDITION_FAILED;
+ }
+
+ retVal = ap_meets_conditions(r);
+
+ /* If-None-Match '*' fix. If-None-Match '*' request should succeed
+ * if the resource does not exist. */
+ if(retVal == HTTP_PRECONDITION_FAILED) {
+ /* Note. If if_none_match != NULL, if_none_match is the culprit.
+ * Since, in presence of If-None-Match,
+ * other If-* headers are undefined. */
+ if((if_none_match =
+ apr_table_get(r->headers_in, "If-None-Match")) != NULL) {
+ if(if_none_match[0] == '*' && resource_state != DAV_RESOURCE_EXISTS)
+ return OK;
+ }
+ }
+
+ return retVal;
+}
+
/*
** dav_validate_request: Validate if-headers (and check for locks) on:
** (1) r->filename @ depth;
@@ -1433,6 +1464,7 @@
const dav_hooks_repository *repos_hooks = resource->hooks;
dav_buffer work_buf = { 0 };
dav_response *new_response;
+ int resource_state;
#if DAV_DEBUG
if (depth && response == NULL) {
@@ -1449,9 +1481,17 @@
if (response != NULL)
*response = NULL;
+ /* Set the ETag header required by dav_meets_conditions() */
+ if ((err = (*resource->hooks->set_headers)(r, resource)) != NULL) {
+ return dav_push_error(r->pool, err->status, 0,
+ "Unable to set up HTTP headers.",
+ err);
+ }
+
+ resource_state = dav_get_resource_state(r, resource);
/* Do the standard checks for conditional requests using
* If-..-Since, If-Match etc */
- if ((result = ap_meets_conditions(r)) != OK) {
+ if ((result = dav_meets_conditions(r, resource_state)) != OK) {
/* ### fix this up... how? */
return dav_new_error(r->pool, result, 0, NULL);
}
Re: svn commit: r607466 - in /httpd/httpd/trunk: CHANGES modules/dav/main/util.c
Posted by Ruediger Pluem <rp...@apache.org>.
On 12/29/2007 08:38 PM, niq@apache.org wrote:
> Author: niq
> Date: Sat Dec 29 11:38:51 2007
> New Revision: 607466
>
> URL: http://svn.apache.org/viewvc?rev=607466&view=rev
> Log:
> mod_dav: Fix evaluation of If-Match * and If-None-Match * conditionals.
> PR 38034
> Patch by Paritosh Shah
> Explanation by Werner Baumann
>
> Modified:
> httpd/httpd/trunk/CHANGES
> httpd/httpd/trunk/modules/dav/main/util.c
>
> Modified: httpd/httpd/trunk/modules/dav/main/util.c
> URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/dav/main/util.c?rev=607466&r1=607465&r2=607466&view=diff
> ==============================================================================
> --- httpd/httpd/trunk/modules/dav/main/util.c (original)
> +++ httpd/httpd/trunk/modules/dav/main/util.c Sat Dec 29 11:38:51 2007
> @@ -1404,6 +1404,37 @@
> @@ -1449,9 +1481,17 @@
> if (response != NULL)
> *response = NULL;
>
> + /* Set the ETag header required by dav_meets_conditions() */
> + if ((err = (*resource->hooks->set_headers)(r, resource)) != NULL) {
I agree that setting the ETag header is needed in order to have dav_meets_conditions
/ ap_meets_conditions working, but this means we now set several headers in cases where
we did not set them before (e.g. DELETE method). Is this correct?
Regards
RĂ¼diger