[4.0] b7b4cf0 Do not recognize a 304 as a valid revalidation response for an ims_oc without OF_IMSCAND

Lasse Karstensen lkarsten at varnish-software.com
Wed Feb 11 13:59:14 CET 2015


commit b7b4cf08134ea6cdb06214caac6fb56f94cc5cec
Author: Martin Blix Grydeland <martin at varnish-software.com>
Date:   Wed Feb 4 16:51:31 2015 +0100

    Do not recognize a 304 as a valid revalidation response for an ims_oc without OF_IMSCAND
    
    Fixes: #1672
    
    Conflicts:
    	bin/varnishd/cache/cache_fetch.c

diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index 0370bab..3308ae6 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -379,7 +379,10 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo)
 
 	AZ(bo->do_esi);
 
-	if (bo->ims_obj != NULL && bo->beresp->status == 304) {
+	if (bo->ims_obj != NULL && bo->ims_obj->http->status == 200 &&
+	    (http_GetHdr(bo->ims_obj->http, H_Last_Modified, NULL) ||
+	     http_GetHdr(bo->ims_obj->http, H_ETag, NULL)) &&
+	    bo->beresp->status == 304) {
 		http_Unset(bo->beresp, H_Content_Length);
 		http_Merge(bo->ims_obj->http, bo->beresp,
 		    bo->ims_obj->changed_gzip);
diff --git a/bin/varnishtest/tests/r01672.vtc b/bin/varnishtest/tests/r01672.vtc
new file mode 100644
index 0000000..ae99a2f
--- /dev/null
+++ b/bin/varnishtest/tests/r01672.vtc
@@ -0,0 +1,33 @@
+varnishtest "#1672: Bogus 304 backend reply"
+
+# First serve a non-200 status object to the cache,
+# then revalidate it unconditionally
+server s1 {
+	rxreq
+	txresp -status 404
+
+	rxreq
+	txresp -status 304
+} -start
+
+varnish v1 -vcl+backend {
+	sub vcl_backend_response {
+		set beresp.ttl = 0.1s;
+		set beresp.grace = 0s;
+		set beresp.keep = 10s;
+	}
+} -start
+
+client c1 {
+	txreq
+	rxresp
+	expect resp.status == 404
+} -run
+
+delay 0.2
+
+client c1 {
+	txreq
+	rxresp
+	expect resp.status == 304
+} -run



More information about the varnish-commit mailing list