r5074 - in trunk/varnish-cache/bin: varnishd varnishtest varnishtest/tests

phk at varnish-cache.org phk at varnish-cache.org
Mon Aug 9 08:55:53 CEST 2010


Author: phk
Date: 2010-08-09 08:55:52 +0200 (Mon, 09 Aug 2010)
New Revision: 5074

Added:
   trunk/varnish-cache/bin/varnishtest/tests/r00730.vtc
Modified:
   trunk/varnish-cache/bin/varnishd/cache.h
   trunk/varnish-cache/bin/varnishd/cache_center.c
   trunk/varnish-cache/bin/varnishtest/vtc_varnish.c
Log:
Do not suppress the Content-Length:, Age:, Range: and Proxy-Auth headers
from the backend on a pass operation.

Fixes: #730



Modified: trunk/varnish-cache/bin/varnishd/cache.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache.h	2010-08-09 06:22:27 UTC (rev 5073)
+++ trunk/varnish-cache/bin/varnishd/cache.h	2010-08-09 06:55:52 UTC (rev 5074)
@@ -416,6 +416,7 @@
 	enum step		step;
 	unsigned		cur_method;
 	unsigned		handling;
+	unsigned char		pass;
 	unsigned char		sendbody;
 	unsigned char		wantbody;
 	int			err_code;

Modified: trunk/varnish-cache/bin/varnishd/cache_center.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_center.c	2010-08-09 06:22:27 UTC (rev 5073)
+++ trunk/varnish-cache/bin/varnishd/cache_center.c	2010-08-09 06:55:52 UTC (rev 5074)
@@ -532,7 +532,7 @@
 		AZ(sp->objcore);
 	}
 
-	l = http_EstimateWS(sp->wrk->beresp, HTTPH_A_INS, &nhttp);
+	l = http_EstimateWS(sp->wrk->beresp, sp->pass ? HTTPH_R_PASS : HTTPH_A_INS, &nhttp);
 
 	if (vary != NULL)
 		l += varyl;
@@ -584,7 +584,7 @@
 
 	hp2->logtag = HTTP_Obj;
 	http_CopyResp(hp2, hp);
-	http_FilterFields(sp->wrk, sp->fd, hp2, hp, HTTPH_A_INS);
+	http_FilterFields(sp->wrk, sp->fd, hp2, hp, sp->pass ? HTTPH_R_PASS : HTTPH_A_INS);
 	http_CopyHome(sp->wrk, sp->fd, hp2);
 
 	if (http_GetHdr(hp, H_Last_Modified, &b))
@@ -954,6 +954,7 @@
 	sp->acct_tmp.pass++;
 	sp->sendbody = 1;
 	sp->step = STP_FETCH;
+	sp->pass = 1;
 	return (0);
 }
 
@@ -1041,6 +1042,7 @@
 	AN(sp->director);
 
 	sp->disable_esi = 0;
+	sp->pass = 0;
 
 	VCL_recv_method(sp);
 	recv_handling = sp->handling;

Added: trunk/varnish-cache/bin/varnishtest/tests/r00730.vtc
===================================================================
--- trunk/varnish-cache/bin/varnishtest/tests/r00730.vtc	                        (rev 0)
+++ trunk/varnish-cache/bin/varnishtest/tests/r00730.vtc	2010-08-09 06:55:52 UTC (rev 5074)
@@ -0,0 +1,33 @@
+# $Id$
+
+test "Check that HEAD returns Content-Length: if backend provides"
+
+server s1 {
+	rxreq
+	txresp -bodylen 5
+	rxreq
+	txresp -bodylen 6
+} -start
+
+varnish v1 -vcl+backend {
+} -start
+
+client c1 {
+	txreq -req HEAD
+	rxresp -no_obj
+	expect resp.http.content-length == 5
+} -run
+
+
+varnish v1 -vcl+backend {
+	sub vcl_recv {
+		return (pass);
+	}
+} 
+
+client c1 {
+	txreq -req HEAD
+	rxresp -no_obj
+	expect resp.http.content-length == 6
+} -run
+

Modified: trunk/varnish-cache/bin/varnishtest/vtc_varnish.c
===================================================================
--- trunk/varnish-cache/bin/varnishtest/vtc_varnish.c	2010-08-09 06:22:27 UTC (rev 5073)
+++ trunk/varnish-cache/bin/varnishtest/vtc_varnish.c	2010-08-09 06:55:52 UTC (rev 5074)
@@ -198,7 +198,8 @@
 	vtc_logclose(v->vl);
 	free(v->name);
 	free(v->workdir);
-	VSM_Delete(v->vd);
+	if (v->vd != NULL)
+		VSM_Delete(v->vd);
 
 	/*
 	 * We do not delete the workdir, it may contain stuff people




More information about the varnish-commit mailing list