Our interpretation of http://tools.ietf.org/html/rfc7234#section-4.1 is that removing all whitespace from a header field only containing whitespace equals to removing the header.
>From 76eccf170a73fe22ea1990566f8f387921aef18e Mon Sep 17 00:00:00 2001 From: Nils Goroll <[email protected]> Date: Sat, 27 Dec 2014 14:24:46 +0100 Subject: [PATCH] For Vary processing, treat an empty header (only whitespace) like a non-existent header
Our interpretation of http://tools.ietf.org/html/rfc7234#section-4.1 is that removing all whitespace from a header field only containing whitespace equals to removing the header. --- bin/varnishd/cache/cache_vary.c | 8 ++++++-- bin/varnishtest/tests/c00004.vtc | 11 +++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/bin/varnishd/cache/cache_vary.c b/bin/varnishd/cache/cache_vary.c index 492af99..1cfb047 100644 --- a/bin/varnishd/cache/cache_vary.c +++ b/bin/varnishd/cache/cache_vary.c @@ -129,7 +129,10 @@ VRY_Create(struct busyobj *bo, struct vsb **psb) e--; /* Encode two byte length and contents */ l = e - h; - if (l > 0xffff - 1) { + /* empty header == no header */ + if (l == 0) + l = 0xffff; + else if (l > 0xffff - 1) { VSLb(bo->vsl, SLT_Error, "Vary header maximum length exceeded"); error = 1; @@ -316,7 +319,8 @@ VRY_Match(struct req *req, const uint8_t *vary) lh = e - h; assert(lh < 0xffff); ln += lh; - } else { + } + if (!i || lh == 0) { e = h = NULL; lh = 0xffff; } diff --git a/bin/varnishtest/tests/c00004.vtc b/bin/varnishtest/tests/c00004.vtc index 56af641..afc29a9 100644 --- a/bin/varnishtest/tests/c00004.vtc +++ b/bin/varnishtest/tests/c00004.vtc @@ -4,12 +4,15 @@ server s1 { rxreq expect req.http.foobar == "1" txresp -hdr "Vary: Foobar" -hdr "Snafu: 1" -body "1111\n" + rxreq expect req.http.foobar == "2" txresp -hdr "Vary: Foobar" -hdr "Snafu: 2" -body "2222\n" + rxreq expect req.http.foobar == "3" txresp -hdr "Vary: Foobar" -hdr "Snafu: 3" -body "3333\n" + rxreq txresp -hdr "Vary: Foobar" -hdr "Snafu: 4" -body "4444\n" } -start @@ -47,4 +50,12 @@ client c1 { expect resp.http.X-Varnish == "1009 1002" expect resp.http.snafu == "1" + # only whitespace == no header + # http://tools.ietf.org/html/rfc7234#section-4.1 + txreq -hdr "Foobar: " + rxresp + expect resp.status == 200 + expect resp.http.X-Varnish == "1010 1008" + expect resp.http.snafu == "4" + } -run -- 2.1.3
_______________________________________________ varnish-dev mailing list [email protected] https://www.varnish-cache.org/lists/mailman/listinfo/varnish-dev
