[PATCH 2/2] Copy the status code, proto, status string and response message on backend IMS.
Martin Blix Grydeland
martin at varnish-software.com
Fri Apr 25 11:35:42 CEST 2014
When revalidating using backend IMS, copy the status code, status
code, status string and response message from the original object into
the new revalidated object. This makes sure that none of the 304
message fields gets applied to the new revalidated object.
This change also removes the forced 200 status of the revalidated
object, inheriting the status code of the original object instead.
Fixes: #1485
---
bin/varnishd/cache/cache_fetch.c | 8 +++++++-
bin/varnishtest/tests/r01485.vtc | 32 ++++++++++++++++++++++++++++++++
2 files changed, 39 insertions(+), 1 deletion(-)
create mode 100644 bin/varnishtest/tests/r01485.vtc
diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index 5a0a9ff..8603777 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -356,7 +356,13 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo)
AZ(bo->do_esi);
if (bo->ims_obj != NULL && bo->beresp->status == 304) {
- bo->beresp->status = 200;
+ http_SetH(bo->beresp, HTTP_HDR_PROTO,
+ bo->ims_obj->http->hd[HTTP_HDR_PROTO].b);
+ bo->beresp->status = bo->ims_obj->http->status;
+ http_SetH(bo->beresp, HTTP_HDR_STATUS,
+ bo->ims_obj->http->hd[HTTP_HDR_STATUS].b);
+ http_SetH(bo->beresp, HTTP_HDR_RESPONSE,
+ bo->ims_obj->http->hd[HTTP_HDR_RESPONSE].b);
http_Merge(bo->ims_obj->http, bo->beresp,
bo->ims_obj->changed_gzip);
do_ims = 1;
diff --git a/bin/varnishtest/tests/r01485.vtc b/bin/varnishtest/tests/r01485.vtc
new file mode 100644
index 0000000..caf267a
--- /dev/null
+++ b/bin/varnishtest/tests/r01485.vtc
@@ -0,0 +1,32 @@
+varnishtest "#1485: Wrong response reason phrase"
+
+server s1 {
+ rxreq
+ txresp -hdr "Etag: foo"
+
+ rxreq
+ expect req.http.If-None-Match == "foo"
+ txresp -status 304 -msg "Not Modified"
+} -start
+
+varnish v1 -vcl+backend {
+ sub vcl_backend_response {
+ set beresp.ttl = 1ms;
+ set beresp.grace = 0s;
+ set beresp.keep = 1h;
+ }
+} -start
+
+client c1 {
+ txreq
+ rxresp
+ expect resp.status == 200
+ expect resp.msg == "OK"
+
+ delay 0.1
+
+ txreq
+ rxresp
+ expect resp.status == 200
+ expect resp.msg == "OK"
+} -run
--
1.9.2
More information about the varnish-dev
mailing list