]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
CLEANUP: compression: Make use of http_get_etag_type()
authorTim Duesterhus <tim@bastelstu.be>
Tue, 1 Sep 2020 16:32:35 +0000 (18:32 +0200)
committerWilliam Lallemand <wlallemand@haproxy.org>
Thu, 22 Oct 2020 14:59:36 +0000 (16:59 +0200)
This commit makes the compressor use http_get_etag_type to validate the
ETag instead of using an ad-hoc condition.

src/flt_http_comp.c

index 87f359d03af6af55e0172f233dbbe7afdce32aeb..0360d94be2049cbe3bc1dc1da00cf1f84f405b55 100644 (file)
@@ -508,11 +508,8 @@ select_compression_response_header(struct comp_state *st, struct stream *s, stru
        /* no compression when ETag is malformed */
        ctx.blk = NULL;
        if (http_find_header(htx, ist("ETag"), &ctx, 1)) {
-               if (!(((ctx.value.len >= 4 && memcmp(ctx.value.ptr, "W/\"", 3) == 0) || /* Either a weak ETag */
-                      (ctx.value.len >= 2 && ctx.value.ptr[0] == '"')) &&              /* or strong ETag */
-                     ctx.value.ptr[ctx.value.len - 1] == '"')) {
+               if (http_get_etag_type(ctx.value) == ETAG_INVALID)
                        goto fail;
-               }
        }
        /* no compression when multiple ETags are present
         * Note: Do not reset ctx.blk!