[4.1] 4f2af50 Hit-for-pass objects are not IMS candidates
Martin Blix Grydeland
martin at varnish-software.com
Wed Feb 24 13:36:24 CET 2016
commit 4f2af500ee64091e8a7c17a2a68026ae8920804c
Author: Martin Blix Grydeland <martin at varnish-software.com>
Date: Wed Feb 24 13:26:05 2016 +0100
Hit-for-pass objects are not IMS candidates
Original test case by fgsch
Fixes: #1858
diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index c41fce3..e03d5c2 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -644,9 +644,10 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo)
if (bo->do_gzip || bo->do_gunzip)
ObjSetFlag(bo->wrk, bo->fetch_objcore, OF_CHGGZIP, 1);
- if (http_IsStatus(bo->beresp, 200) && (
- http_GetHdr(bo->beresp, H_Last_Modified, &p) ||
- http_GetHdr(bo->beresp, H_ETag, &p)))
+ if (!(bo->fetch_objcore->flags & OC_F_PASS) &&
+ http_IsStatus(bo->beresp, 200) && (
+ http_GetHdr(bo->beresp, H_Last_Modified, &p) ||
+ http_GetHdr(bo->beresp, H_ETag, &p)))
ObjSetFlag(bo->wrk, bo->fetch_objcore, OF_IMSCAND, 1);
if (bo->htc->body_status != BS_NONE)
diff --git a/bin/varnishtest/tests/r01858.vtc b/bin/varnishtest/tests/r01858.vtc
new file mode 100644
index 0000000..7335b6d
--- /dev/null
+++ b/bin/varnishtest/tests/r01858.vtc
@@ -0,0 +1,38 @@
+varnishtest "Test a hit-for-pass does not issue an IMS request"
+
+server s1 {
+ rxreq
+ txresp \
+ -hdr {Etag: "foo"} \
+ -body "foo"
+ rxreq
+ expect req.http.if-none-match == <undef>
+ txresp \
+ -hdr {Etag: "bar"} \
+ -body "bar"
+} -start
+
+varnish v1 -vcl+backend {
+ sub vcl_backend_response {
+ if (beresp.status == 200) {
+ set beresp.ttl = 1s;
+ set beresp.uncacheable = true;
+ return (deliver);
+ }
+ }
+} -start
+
+client c1 {
+ txreq
+ rxresp
+ expect resp.status == 200
+ expect resp.body == "foo"
+
+ delay 1.5
+
+ txreq
+ rxresp
+ expect resp.status == 200
+ expect resp.body == "bar"
+} -run
+
More information about the varnish-commit
mailing list