[PATCH] Don't do conditionals for passes, leave that to the backend

Rogier 'DocWilco' Mulhuijzen github at bsdchicks.com
Mon Oct 15 16:14:03 CEST 2012


The last one had a whitespace booboo, fixed in this one.

---
 bin/varnishd/cache/cache_response.c |    5 +++-
 bin/varnishtest/tests/r01206.vtc    |   48 +++++++++++++++++++++++++++++++++++
 2 files changed, 52 insertions(+), 1 deletion(-)
 create mode 100644 bin/varnishtest/tests/r01206.vtc

diff --git a/bin/varnishd/cache/cache_response.c b/bin/varnishd/cache/cache_response.c
index cb152a5..3fecd27 100644
--- a/bin/varnishd/cache/cache_response.c
+++ b/bin/varnishd/cache/cache_response.c
@@ -108,6 +108,7 @@ RES_BuildHttp(struct req *req)
 	char time_str[30];
 
 	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
+	CHECK_OBJ_NOTNULL(req->obj, OBJECT_MAGIC);
 
 	http_ClrHeader(req->resp);
 	http_FilterResp(req->obj->http, req->resp, 0);
@@ -122,7 +123,9 @@ RES_BuildHttp(struct req *req)
 	if (req->res_mode & RES_GUNZIP)
 		http_Unset(req->resp, H_Content_Encoding);
 
-	if (req->obj->response == 200
+	if (req->obj->objcore != NULL
+	    && !(req->obj->objcore->flags & OC_F_PASS)
+	    && req->obj->response == 200
 	    && req->http->conds && RFC2616_Do_Cond(req)) {
 		req->wantbody = 0;
 		http_SetResp(req->resp, "HTTP/1.1", 304, "Not Modified");
diff --git a/bin/varnishtest/tests/r01206.vtc b/bin/varnishtest/tests/r01206.vtc
new file mode 100644
index 0000000..1f8444d
--- /dev/null
+++ b/bin/varnishtest/tests/r01206.vtc
@@ -0,0 +1,48 @@
+varnishtest "Pass shouldn't honor IMS/INM if the backend doesn't"
+
+server s1 {
+	rxreq
+	txresp -bodylen 6
+
+	rxreq
+	txresp -hdr "ETag: 123456789" \
+	    -bodylen 6
+
+	rxreq
+	txresp -hdr "Last-Modified: Thu, 26 Jun 2008 12:00:01 GMT" \
+	    -bodylen 6
+} -start
+
+varnish v1 -vcl+backend {
+	sub vcl_recv {
+		return(pass);
+	}
+} -start
+
+client c1 {
+	txreq
+	rxresp
+	expect resp.status == 200
+	expect resp.bodylen == 6
+
+	txreq -hdr "If-None-Match: 123456789"
+	rxresp
+	expect resp.status == 200
+	expect resp.bodylen == 6
+
+	txreq -hdr "If-Modified-Since: Thu, 26 Jun 2008 12:00:01 GMT"
+	rxresp
+	expect resp.status == 200
+	expect resp.bodylen == 6
+} -run
+
+server s1 -start
+
+varnish v1 -vcl+backend {
+	sub vcl_fetch {
+		set beresp.do_pass = true;
+	}
+}
+
+client c1 -run
+
-- 
1.7.9.5




More information about the varnish-dev mailing list