httpd-bugs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject [Bug 39727] Incorrect ETag on gzip:ed content
Date Sun, 09 Feb 2020 21:06:55 GMT
https://bz.apache.org/bugzilla/show_bug.cgi?id=39727

--- Comment #44 from Ebarg <e.barg0089@icloud.com> ---
Comment on attachment 23051
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=23051
fix etag checking in content handlers by stripping "-gzip" from etags in if
headers

>Index: mod_deflate.c
>===================================================================
>--- mod_deflate.c	(revision 729534)
>+++ mod_deflate.c	(working copy)
>@@ -749,6 +760,45 @@
>     return APR_SUCCESS;
> }
> 
>+static const char *find_replace(apr_pool_t *pool, const char *s, 
>+                                const char *pattern, const char *replacement)
>+{
>+    const char *result = "", *buffer;
>+    const char *pos = s, *match;
>+    int offset = strlen(pattern);
>+
>+    while((match = strstr(pos, pattern))) {
>+        buffer = apr_pstrndup(pool, pos, match - pos);
>+        result = apr_pstrcat(pool, result, buffer, replacement, NULL);
>+        pos = match + offset;
>+    }
>+
>+    return apr_pstrcat(pool, result, pos, NULL);
>+}
>+
>+static void fix_header(request_rec *r, const char *header)
>+{
>+    const char *value = apr_table_get(r->headers_in, header);
>+    const char *new_value;
>+
>+    if (value) {
>+        new_value = find_replace(r->pool, value, "-gzip\"", "\"");
>+        new_value = find_replace(r->pool, new_value, "-gunzip\"", "\"");
>+        apr_table_set(r->headers_in, header, new_value);
>+    }
>+
>+    return;
>+}
>+
>+static int deflate_fixups(request_rec *r)
>+{
>+    /* Fix the etags in If-* headers that we transformed */
>+    fix_header(r, "If-None-Match");
>+    fix_header(r, "If-Match");
>+
>+    return OK;
>+}
>+
> /* This is the deflate input filter (inflates).  */
> static apr_status_t deflate_in_filter(ap_filter_t *f,
>                                       apr_bucket_brigade *bb,
>@@ -1352,6 +1402,7 @@
>                               AP_FTYPE_RESOURCE-1);
>     ap_register_input_filter(deflateFilterName, deflate_in_filter, NULL,
>                               AP_FTYPE_CONTENT_SET);
>+    ap_hook_fixups(deflate_fixups, NULL, NULL, APR_HOOK_MIDDLE);
> }
> 
> static const command_rec deflate_filter_cmds[] = {

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


Mime
View raw message