--- modules/filters/mod_deflate.c (revision 687021) +++ modules/filters/mod_deflate.c (working copy) @@ -49,6 +49,7 @@ #include "zlib.h" static const char deflateFilterName[] = "DEFLATE"; +static const char etagFilterName[] = "ETAG"; module AP_MODULE_DECLARE_DATA deflate_module; typedef struct deflate_filter_config_t @@ -537,6 +538,9 @@ /* 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); } @@ -735,6 +739,36 @@ return APR_SUCCESS; } +static apr_status_t etag_in_filter(ap_filter_t *f, + apr_bucket_brigade *bb, + ap_input_mode_t mode, + apr_read_type_e block, + apr_off_t readbytes) +{ + request_rec *r = f->r; + /* Do not disturb clients who aren't interested in gzip + */ + const char* inm; + char* gz; + const char* accept = apr_table_get(r->headers_in, "Accept-Encoding"); + ap_remove_input_filter(f); /* go thru only once */ + if ((accept == NULL) || (ap_strstr_c(accept, "gzip") == NULL)) { + return ap_get_brigade(f->next, bb, mode, block, readbytes); + } + + /* Do they have a gzip version? + */ + inm = apr_table_get(r->headers_in, "If-None-Match"); + if ((inm == NULL) || ( (gz = ap_strstr_c(inm, "-gzip")) == NULL )) { + return ap_get_brigade(f->next, bb, mode, block, readbytes); + } + + *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 ap_get_brigade(f->next, bb, mode, block, readbytes); +} + /* This is the deflate input filter (inflates). */ static apr_status_t deflate_in_filter(ap_filter_t *f, apr_bucket_brigade *bb, @@ -1338,6 +1372,8 @@ AP_FTYPE_RESOURCE-1); ap_register_input_filter(deflateFilterName, deflate_in_filter, NULL, AP_FTYPE_CONTENT_SET); + ap_register_input_filter(etagFilterName, etag_in_filter, NULL, + AP_FTYPE_CONTENT_SET); } static const command_rec deflate_filter_cmds[] = {