hi all...

well, I haven't quite figured out all the weak etag issues yet, but just the
other day someone asked how to remove ETag headers from a default-handler
response.

so, I thought I'd re-submit the ap_suppress_etag() part as a formal API
wrapper around

  apr_table_setn(r->notes, "no-etag", "omit");

if only to make the feature a bit more self-documenting.

--Geoff

Index: include/http_protocol.h
===================================================================
RCS file: /home/cvspublic/httpd-2.0/include/http_protocol.h,v
retrieving revision 1.86
diff -u -r1.86 http_protocol.h
--- include/http_protocol.h     1 Jan 2004 13:26:16 -0000       1.86
+++ include/http_protocol.h     23 Jan 2004 15:56:34 -0000
@@ -203,11 +203,18 @@
 AP_DECLARE(char *) ap_make_etag(request_rec *r, int force_weak);
 
 /**
- * Set the E-tag outgoing header
+ * Set the ETag outgoing header
  * @param The current request
  * @deffunc void ap_set_etag(request_rec *r)
  */
 AP_DECLARE(void) ap_set_etag(request_rec *r);
+
+/**
+ * Suppress the ETag outgoing header
+ * @param The current request
+ * @deffunc void ap_suppress_etag(request_rec *r)
+ */
+AP_DECLARE(void) ap_suppress_etag(request_rec *r);
 
 /**
  * Set the last modified time for the file being sent
Index: modules/filters/mod_include.c
===================================================================
RCS file: /home/cvspublic/httpd-2.0/modules/filters/mod_include.c,v
retrieving revision 1.296
diff -u -r1.296 mod_include.c
--- modules/filters/mod_include.c       13 Jan 2004 22:12:02 -0000      1.296
+++ modules/filters/mod_include.c       23 Jan 2004 15:56:50 -0000
@@ -3539,7 +3539,7 @@
      * We don't know if we are going to be including a file or executing
      * a program - in either case a strong ETag header will likely be invalid.
      */
-    apr_table_setn(f->r->notes, "no-etag", "");
+    ap_suppress_etag(f->r);
 
     return OK;
 }
Index: modules/http/http_protocol.c
===================================================================
RCS file: /home/cvspublic/httpd-2.0/modules/http/http_protocol.c,v
retrieving revision 1.476
diff -u -r1.476 http_protocol.c
--- modules/http/http_protocol.c        16 Jan 2004 20:11:12 -0000      1.476
+++ modules/http/http_protocol.c        23 Jan 2004 15:56:53 -0000
@@ -1635,7 +1635,8 @@
 
     /*
      * Now remove any ETag response header field if earlier processing
-     * says so (such as a 'FileETag None' directive).
+     * says so.  this could have happened via a direct API call to
+     * ap_suppress_etag() or a directive like 'FileETag None'
      */
     if (apr_table_get(r->notes, "no-etag") != NULL) {
         apr_table_unset(r->headers_out, "ETag");
@@ -2700,7 +2701,7 @@
      * note it for the header-sender to ignore.
      */
     if (etag_bits & ETAG_NONE) {
-        apr_table_setn(r->notes, "no-etag", "omit");
+        ap_suppress_etag(r);
         return "";
     }
 
@@ -2838,6 +2839,14 @@
     }
 
     apr_table_setn(r->headers_out, "ETag", etag);
+}
+
+/*
+ * keep ETag headers from the response
+ */
+AP_DECLARE(void) ap_suppress_etag(request_rec *r)
+{
+    apr_table_setn(r->notes, "no-etag", "omit");
 }
 
 static int parse_byterange(char *range, apr_off_t clength,

Reply via email to