You are viewing a plain text version of this content. The canonical link for it is here.
Posted to bugs@httpd.apache.org by bu...@apache.org on 2020/02/09 21:06:55 UTC
[Bug 39727] Incorrect ETag on gzip:ed content
https://bz.apache.org/bugzilla/show_bug.cgi?id=39727
--- Comment #44 from Ebarg <e....@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