MINOR: cache: Improve accept_encoding_normalizer
Turn the "Accept-Encoding" value to lower case before processing it.
Calculate the CRC on every token instead of a sorted concatenation of
them all (in order to avoir copying them) then XOR all the CRCs into a
single hash (while ignoring duplicates).
diff --git a/reg-tests/cache/vary.vtc b/reg-tests/cache/vary.vtc
index 9690490..001018f 100644
--- a/reg-tests/cache/vary.vtc
+++ b/reg-tests/cache/vary.vtc
@@ -187,8 +187,9 @@
expect resp.http.content-type == "text/plain"
expect resp.http.X-Cache-Hit == 1
- # The accept-encoding normalizer function sorts alphabeticaly the values
- # before calculating the secondary key
+ # The accept-encoding normalizer function converts the header values
+ # to lower case then calculates the hash of every sub part before
+ # sorting the hashes and xor'ing them (while removing duplicates).
txreq -url "/accept-encoding-multiple" -hdr "Accept-Encoding: first,second"
rxresp
expect resp.status == 200
@@ -207,6 +208,12 @@
expect resp.bodylen == 51
expect resp.http.X-Cache-Hit == 1
+ txreq -url "/accept-encoding-multiple" -hdr "Accept-Encoding: FirsT,SECOND,first"
+ rxresp
+ expect resp.status == 200
+ expect resp.bodylen == 51
+ expect resp.http.X-Cache-Hit == 1
+
# Unmanaged vary
txreq -url "/unmanaged" -hdr "Accept-Encoding: first_value"
rxresp
@@ -270,7 +277,7 @@
expect resp.bodylen == 57
expect resp.http.X-Cache-Hit == 1
- # The following requests are trated by a backend that does not cache
+ # The following requests are treated by a backend that does not cache
# responses containing a Vary header
txreq -url "/no_vary_support"
rxresp