mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-01-06 12:20:07 +00:00
b229f018ee
RFC 7232 section 2.3.3 states: > Note: Content codings are a property of the representation data, > so a strong entity-tag for a content-encoded representation has to > be distinct from the entity tag of an unencoded representation to > prevent potential conflicts during cache updates and range > requests. In contrast, transfer codings (Section 4 of [RFC7230]) > apply only during message transfer and do not result in distinct > entity-tags. Thus a strong ETag must be changed when compressing. Usually this is done by converting it into a weak ETag, which represents a semantically, but not byte-by-byte identical response. A conversion to a weak ETag still allows If-None-Match to work. This should be backported to 1.9 and might be backported to every supported branch with compression.
227 lines
6.3 KiB
Plaintext
227 lines
6.3 KiB
Plaintext
varnishtest "Compression converts strong ETags to weak ETags"
|
|
|
|
#REQUIRE_VERSION=1.9
|
|
#REQUIRE_OPTION=ZLIB|SLZ
|
|
|
|
feature ignore_unknown_macro
|
|
|
|
server s1 {
|
|
rxreq
|
|
expect req.url == "/strong"
|
|
expect req.http.accept-encoding == "gzip"
|
|
txresp \
|
|
-hdr "Content-Type: text/plain" \
|
|
-hdr "ETag: \"123\"" \
|
|
-bodylen 100
|
|
|
|
rxreq
|
|
expect req.url == "/weak"
|
|
expect req.http.accept-encoding == "gzip"
|
|
txresp \
|
|
-hdr "Content-Type: text/plain" \
|
|
-hdr "ETag: W/\"456\"" \
|
|
-bodylen 100
|
|
|
|
rxreq
|
|
expect req.url == "/weak-incorrect-quoting"
|
|
expect req.http.accept-encoding == "gzip"
|
|
txresp \
|
|
-hdr "Content-Type: text/plain" \
|
|
-hdr "ETag: \"W/789\"" \
|
|
-bodylen 100
|
|
|
|
rxreq
|
|
expect req.url == "/empty-strong"
|
|
expect req.http.accept-encoding == "gzip"
|
|
txresp \
|
|
-hdr "Content-Type: text/plain" \
|
|
-hdr "ETag: \"\"" \
|
|
-bodylen 100
|
|
|
|
rxreq
|
|
expect req.url == "/empty-weak"
|
|
expect req.http.accept-encoding == "gzip"
|
|
txresp \
|
|
-hdr "Content-Type: text/plain" \
|
|
-hdr "ETag: W/\"\"" \
|
|
-bodylen 100
|
|
|
|
rxreq
|
|
expect req.url == "/invalid1"
|
|
expect req.http.accept-encoding == "gzip"
|
|
txresp \
|
|
-hdr "Content-Type: text/plain" \
|
|
-hdr "ETag: \"invalid" \
|
|
-bodylen 100
|
|
|
|
rxreq
|
|
expect req.url == "/invalid2"
|
|
expect req.http.accept-encoding == "gzip"
|
|
txresp \
|
|
-hdr "Content-Type: text/plain" \
|
|
-hdr "ETag: invalid\"" \
|
|
-bodylen 100
|
|
|
|
rxreq
|
|
expect req.url == "/invalid3"
|
|
expect req.http.accept-encoding == "gzip"
|
|
txresp \
|
|
-hdr "Content-Type: text/plain" \
|
|
-hdr "ETag: invalid" \
|
|
-bodylen 100
|
|
|
|
rxreq
|
|
expect req.url == "/invalid4"
|
|
expect req.http.accept-encoding == "gzip"
|
|
txresp \
|
|
-hdr "Content-Type: text/plain" \
|
|
-hdr "ETag: W/\"invalid" \
|
|
-bodylen 100
|
|
|
|
rxreq
|
|
expect req.url == "/invalid5"
|
|
expect req.http.accept-encoding == "gzip"
|
|
txresp \
|
|
-hdr "Content-Type: text/plain" \
|
|
-hdr "ETag: W/invalid\"" \
|
|
-bodylen 100
|
|
|
|
rxreq
|
|
expect req.url == "/invalid6"
|
|
expect req.http.accept-encoding == "gzip"
|
|
txresp \
|
|
-hdr "Content-Type: text/plain" \
|
|
-hdr "ETag: W/invalid" \
|
|
-bodylen 100
|
|
|
|
rxreq
|
|
expect req.url == "/multiple"
|
|
expect req.http.accept-encoding == "gzip"
|
|
txresp \
|
|
-hdr "Content-Type: text/plain" \
|
|
-hdr "ETag: \"one\"" \
|
|
-hdr "ETag: \"two\"" \
|
|
-bodylen 100
|
|
} -start
|
|
|
|
|
|
haproxy h1 -conf {
|
|
defaults
|
|
mode http
|
|
${no-htx} option http-use-htx
|
|
timeout connect 1s
|
|
timeout client 1s
|
|
timeout server 1s
|
|
|
|
frontend fe-gzip
|
|
bind "fd@${fe_gzip}"
|
|
default_backend be-gzip
|
|
|
|
backend be-gzip
|
|
compression algo gzip
|
|
compression type text/html text/plain
|
|
server www ${s1_addr}:${s1_port}
|
|
} -start
|
|
|
|
client c1 -connect ${h1_fe_gzip_sock} {
|
|
txreq -url "/strong" \
|
|
-hdr "Accept-Encoding: gzip"
|
|
rxresp
|
|
expect resp.status == 200
|
|
expect resp.http.content-encoding == "gzip"
|
|
expect resp.http.etag == "W/\"123\""
|
|
gunzip
|
|
expect resp.bodylen == 100
|
|
|
|
txreq -url "/weak" \
|
|
-hdr "Accept-Encoding: gzip"
|
|
rxresp
|
|
expect resp.status == 200
|
|
expect resp.http.content-encoding == "gzip"
|
|
expect resp.http.etag == "W/\"456\""
|
|
gunzip
|
|
expect resp.bodylen == 100
|
|
|
|
txreq -url "/weak-incorrect-quoting" \
|
|
-hdr "Accept-Encoding: gzip"
|
|
rxresp
|
|
expect resp.status == 200
|
|
expect resp.http.content-encoding == "gzip"
|
|
expect resp.http.etag == "W/\"W/789\""
|
|
gunzip
|
|
expect resp.bodylen == 100
|
|
|
|
txreq -url "/empty-strong" \
|
|
-hdr "Accept-Encoding: gzip"
|
|
rxresp
|
|
expect resp.status == 200
|
|
expect resp.http.content-encoding == "gzip"
|
|
expect resp.http.etag == "W/\"\""
|
|
gunzip
|
|
expect resp.bodylen == 100
|
|
|
|
txreq -url "/empty-weak" \
|
|
-hdr "Accept-Encoding: gzip"
|
|
rxresp
|
|
expect resp.status == 200
|
|
expect resp.http.content-encoding == "gzip"
|
|
expect resp.http.etag == "W/\"\""
|
|
gunzip
|
|
expect resp.bodylen == 100
|
|
|
|
txreq -url "/invalid1" \
|
|
-hdr "Accept-Encoding: gzip"
|
|
rxresp
|
|
expect resp.status == 200
|
|
expect resp.http.content-encoding == "<undef>"
|
|
expect resp.http.etag == "\"invalid"
|
|
expect resp.bodylen == 100
|
|
|
|
txreq -url "/invalid2" \
|
|
-hdr "Accept-Encoding: gzip"
|
|
rxresp
|
|
expect resp.status == 200
|
|
expect resp.http.content-encoding == "<undef>"
|
|
expect resp.http.etag == "invalid\""
|
|
expect resp.bodylen == 100
|
|
|
|
txreq -url "/invalid3" \
|
|
-hdr "Accept-Encoding: gzip"
|
|
rxresp
|
|
expect resp.status == 200
|
|
expect resp.http.content-encoding == "<undef>"
|
|
expect resp.http.etag == "invalid"
|
|
expect resp.bodylen == 100
|
|
|
|
txreq -url "/invalid4" \
|
|
-hdr "Accept-Encoding: gzip"
|
|
rxresp
|
|
expect resp.status == 200
|
|
expect resp.http.content-encoding == "<undef>"
|
|
expect resp.http.etag == "W/\"invalid"
|
|
expect resp.bodylen == 100
|
|
|
|
txreq -url "/invalid5" \
|
|
-hdr "Accept-Encoding: gzip"
|
|
rxresp
|
|
expect resp.status == 200
|
|
expect resp.http.content-encoding == "<undef>"
|
|
expect resp.http.etag == "W/invalid\""
|
|
expect resp.bodylen == 100
|
|
|
|
txreq -url "/invalid6" \
|
|
-hdr "Accept-Encoding: gzip"
|
|
rxresp
|
|
expect resp.status == 200
|
|
expect resp.http.content-encoding == "<undef>"
|
|
expect resp.http.etag == "W/invalid"
|
|
expect resp.bodylen == 100
|
|
|
|
txreq -url "/multiple" \
|
|
-hdr "Accept-Encoding: gzip"
|
|
rxresp
|
|
expect resp.status == 200
|
|
expect resp.http.content-encoding == "<undef>"
|
|
expect resp.bodylen == 100
|
|
} -run
|