Index: modules/filters/mod_deflate.c =================================================================== --- modules/filters/mod_deflate.c (revision 687729) +++ modules/filters/mod_deflate.c (working copy) @@ -43,6 +43,7 @@ #include "util_filter.h" #include "apr_buckets.h" #include "http_request.h" +#include "http_protocol.h" #define APR_WANT_STRFUNC #include "apr_want.h" @@ -537,6 +538,10 @@ /* For a 304 or 204 response there is no entity included in * the response and hence nothing to deflate. */ if (r->status == HTTP_NOT_MODIFIED || r->status == HTTP_NO_CONTENT) { + /* munge the etag only if we had done that when we came in.*/ + if(apr_table_get(r->notes, "If-None-Match") != NULL) + deflate_check_etag(r, "gzip"); + ap_remove_output_filter(f); return ap_pass_brigade(f->next, bb); } @@ -1329,6 +1334,31 @@ return APR_SUCCESS; } +static int etag_post_read_request(request_rec *r) +{ + /* Do not disturb clients who aren't interested in gzip + */ + char* inm; + char* gz; + const char* accept = apr_table_get(r->headers_in, "Accept-Encoding"); + if ((accept == NULL) || (ap_strstr_c(accept, "gzip") == NULL)) { + return DECLINED; + } + + /* Do they have a gzip version? + */ + inm = apr_table_get(r->headers_in, "If-None-Match"); + if ((inm == NULL) || ( (gz = ap_strstr(inm, "-gzip")) == NULL )) { + return DECLINED; + } + + *gz = '\0'; + apr_table_set(r->headers_in, "If-None-Match", apr_pstrdup(r->pool, inm)); + apr_table_setn(r->notes, "If-None-Match", "1"); + + return DECLINED; +} + #define PROTO_FLAGS AP_FILTER_PROTO_CHANGE|AP_FILTER_PROTO_CHANGE_LENGTH static void register_hooks(apr_pool_t *p) { @@ -1338,6 +1368,9 @@ AP_FTYPE_RESOURCE-1); ap_register_input_filter(deflateFilterName, deflate_in_filter, NULL, AP_FTYPE_CONTENT_SET); + ap_hook_post_read_request(etag_post_read_request, NULL, NULL, + APR_HOOK_MIDDLE); + } static const command_rec deflate_filter_cmds[] = {