On Sun, 30 Dec 2007 09:22:28 +0800
Michael Clark <[EMAIL PROTECTED]> wrote:

> I'm getting a segfault here in mod_dav from trunk

Oops ... more haste less speed:-(

I attach a revised patch (against current trunk).
This is completely untested; just posting before going to bed,
in case anyone feels like picking it up.  If not, I'll try
and find time to revisit it tomorrow.

-- 
Nick Kew

Application Development with Apache - the Apache Modules Book
http://www.apachetutor.org/
Index: modules/dav/main/util.c
===================================================================
--- modules/dav/main/util.c	(revision 607466)
+++ modules/dav/main/util.c	(working copy)
@@ -1465,6 +1465,7 @@
     dav_buffer work_buf = { 0 };
     dav_response *new_response;
     int resource_state;
+    const char *etag;
 
 #if DAV_DEBUG
     if (depth && response == NULL) {
@@ -1482,17 +1483,23 @@
         *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);
+    etag = apr_table_get(r->headers_out, "ETag");
+    if (!etag) {
+        etag = (*resource->hooks->getetag)(resource);
+        if (etag) {
+            apr_table_set(r->headers_out, "ETag", etag);
+        }
     }
-
-    resource_state = dav_get_resource_state(r, resource);
     /* Do the standard checks for conditional requests using
      * If-..-Since, If-Match etc */
-    if ((result = dav_meets_conditions(r, resource_state)) != OK) {
-        /* ### fix this up... how? */
+    if (etag) {
+        resource_state = dav_get_resource_state(r, resource);
+        result = dav_meets_conditions(r, resource_state);
+    }
+    else {
+        result = ap_meets_conditions(r);
+    }
+    if (result != OK) {
         return dav_new_error(r->pool, result, 0, NULL);
     }
 

Reply via email to