[master] ff2647b Don't do conditional processing for hit-for-pass objects.
Poul-Henning Kamp
phk at varnish-cache.org
Wed Oct 17 12:25:01 CEST 2012
commit ff2647b2828888f3e39637f3688dad6a05354500
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Wed Oct 17 10:23:37 2012 +0000
Don't do conditional processing for hit-for-pass objects.
Fixes #1206
Found & Fixed by: DocWilco
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..dc403ed
--- /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 7
+
+ rxreq
+ txresp -hdr "Last-Modified: Thu, 26 Jun 2008 12:00:01 GMT" \
+ -bodylen 8
+} -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 == 7
+
+ txreq -hdr "If-Modified-Since: Thu, 26 Jun 2008 12:00:01 GMT"
+ rxresp
+ expect resp.status == 200
+ expect resp.bodylen == 8
+} -run
+
+server s1 -start
+
+varnish v1 -vcl+backend {
+ sub vcl_fetch {
+ set beresp.do_pass = true;
+ }
+}
+
+client c1 -run
+
More information about the varnish-commit
mailing list