On 12/09/2006 06:52 AM, Roy T. Fielding wrote:

> 
> The best solution is to not mess with content-encoding at all, which
> gets us out of both this consistency problem and related problems
> with the entity-header fields (content-md5, signatures, etc.).
> That is why transfer encoding was invented in the first place.
> 
> We should have an implementation of deflate as a transfer encoding,
> but it should be configurable independent of the existing filter.
> Some people will want TE specifically to avoid the addition of Vary
> and all the other problems that content-changing filters cause.
> For example, an additional directive option for CE, TE, or "either".

I think fixing the current CE filter is easier right now then to
add the option above. I think this can be done in a second step
and sounds like a good idea to me.

> 
> The existing filter needs to modify the ETag field value (and
> any other entity-dependent values that we can think of) or be
> removed as a feature.  Weak etags are not a solution -- being able
> to make range requests of large cached representations requires a
> strong etag, and it really isn't hard to provide one.  It is better
> to not deflate the response at all than to interfere with caching.

Would the following patch address all your points for a CE mod_deflate filter?

Index: modules/filters/mod_deflate.c
===================================================================
--- modules/filters/mod_deflate.c       (Revision 484803)
+++ modules/filters/mod_deflate.c       (Arbeitskopie)
@@ -320,6 +320,7 @@
     if (!ctx) {
         char *token;
         const char *encoding;
+        const char *etag;

         /* only work on main request/no subrequests */
         if (r->main != NULL) {
@@ -483,7 +484,26 @@
         else {
             apr_table_mergen(r->headers_out, "Content-Encoding", "gzip");
         }
+        /*
+         * Unset headers which are no longer valid after we have compressed
+         * the content.
+         */
         apr_table_unset(r->headers_out, "Content-Length");
+        apr_table_unset(r->headers_out, "Content-MD5");
+        /* Adjust ETag if present */
+        etag = apr_table_get(r->headers_out, "ETag");
+        if (etag) {
+            if (*etag) {
+                /* Remove the '"' at the end of the ETag */
+                etag[strlen(etag) - 1] = '\0';
+                apr_table_set(r->headers_out, "ETag",
+                              apr_pstrcat(r->pool, etag, "-gzip\"", NULL));
+            }
+            else {
+                /* Does not seem to be a valid ETag. So remove it. */
+                apr_table_unset(r->headers_out, "ETag");
+            }
+        }

         /* initialize deflate output buffer */
         ctx->stream.next_out = ctx->buffer;

Regards

RĂ¼diger

Reply via email to