r5211 - in trunk/varnish-cache/bin: varnishd varnishtest/tests
martin at varnish-cache.org
martin at varnish-cache.org
Wed Sep 15 09:54:51 CEST 2010
Author: martin
Date: 2010-09-15 09:54:50 +0200 (Wed, 15 Sep 2010)
New Revision: 5211
Added:
trunk/varnish-cache/bin/varnishtest/tests/r00769.vtc
Modified:
trunk/varnish-cache/bin/varnishd/cache_vrt.c
Log:
Set the int status when setting the txt header status in VRT_l_[obj|resp|beresp]_status.
Fixes: #769
Modified: trunk/varnish-cache/bin/varnishd/cache_vrt.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_vrt.c 2010-09-15 07:22:14 UTC (rev 5210)
+++ trunk/varnish-cache/bin/varnishd/cache_vrt.c 2010-09-15 07:54:50 UTC (rev 5211)
@@ -308,6 +308,7 @@
else
sprintf(p, "%d", num);
http_SetH(sp->obj->http, HTTP_HDR_STATUS, p);
+ sp->obj->http->status = num;
}
/* Add an objecthead to the saintmode list for the (hopefully) relevant
@@ -388,6 +389,7 @@
else
sprintf(p, "%d", num);
http_SetH(sp->wrk->resp, HTTP_HDR_STATUS, p);
+ sp->wrk->resp->status = num;
}
int
@@ -395,6 +397,8 @@
{
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
CHECK_OBJ_NOTNULL(sp->wrk->resp, HTTP_MAGIC);
+ if (sp->wrk->resp->status)
+ return (sp->wrk->resp->status);
return (atoi(sp->wrk->resp->hd[HTTP_HDR_STATUS].b));
}
@@ -490,6 +494,7 @@
else
sprintf(p, "%d", num);
http_SetH(sp->wrk->beresp, HTTP_HDR_STATUS, p);
+ sp->wrk->beresp->status = num;
}
int
Added: trunk/varnish-cache/bin/varnishtest/tests/r00769.vtc
===================================================================
--- trunk/varnish-cache/bin/varnishtest/tests/r00769.vtc (rev 0)
+++ trunk/varnish-cache/bin/varnishtest/tests/r00769.vtc 2010-09-15 07:54:50 UTC (rev 5211)
@@ -0,0 +1,45 @@
+# $Id$
+
+test "Test that set status code is readable again for obj.status and beresp.status"
+
+server s1 {
+ rxreq
+ txresp
+} -start
+
+varnish v1 -vcl+backend {
+ sub vcl_recv {
+ if (req.url ~ "^/test1") {
+ error 700;
+ }
+ }
+ sub vcl_fetch {
+ set beresp.status = 404;
+ set beresp.http.X-status = beresp.status;
+ return (deliver);
+ }
+ sub vcl_error {
+ if (obj.status == 700) {
+ set obj.status=404;
+ set obj.http.X-status = obj.status;
+ return (deliver);
+ }
+ }
+} -start
+
+client c1 {
+ txreq -url "/test1"
+ rxresp
+ expect resp.status == 404
+ expect resp.http.X-status == 404
+}
+
+client c2 {
+ txreq -url "/test2"
+ rxresp
+ expect resp.status == 404
+ expect resp.http.X-status == 404
+}
+
+client c1 -run
+client c2 -run
More information about the varnish-commit
mailing list