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

phk at varnish-cache.org phk at varnish-cache.org
Thu Apr 15 09:33:45 CEST 2010


Author: phk
Date: 2010-04-15 09:33:44 +0200 (Thu, 15 Apr 2010)
New Revision: 4662

Added:
   trunk/varnish-cache/bin/varnishtest/tests/r00679.vtc
Modified:
   trunk/varnish-cache/bin/varnishd/cache_center.c
   trunk/varnish-cache/bin/varnishtest/tests/b00000.vtc
   trunk/varnish-cache/bin/varnishtest/vtc_http.c
Log:
We converted HEAD to GET in vcl_recv{}, that is far too early, since it
also affects pipe and pass processing.

Move the HEAD->GET override to vcl_miss{} and do it on the bereq.* so
we do not tamper with the original request.

Fixes:	#679



Modified: trunk/varnish-cache/bin/varnishd/cache_center.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_center.c	2010-04-15 07:13:51 UTC (rev 4661)
+++ trunk/varnish-cache/bin/varnishd/cache_center.c	2010-04-15 07:33:44 UTC (rev 4662)
@@ -866,6 +866,7 @@
 	sp->wrk->bereq = sp->wrk->http[0];
 	http_Setup(sp->wrk->bereq, sp->wrk->ws);
 	http_FilterHeader(sp, HTTPH_R_FETCH);
+	http_ForceGet(sp->wrk->bereq);
 	sp->wrk->connect_timeout = 0;
 	sp->wrk->first_byte_timeout = 0;
 	sp->wrk->between_bytes_timeout = 0;
@@ -1050,10 +1051,9 @@
 	assert(sp->handling == VCL_RET_HASH);
 	SHA256_Final(sp->digest, sp->wrk->sha256ctx);
 
-	if (!strcmp(sp->http->hd[HTTP_HDR_REQ].b, "HEAD")) {
+	if (!strcmp(sp->http->hd[HTTP_HDR_REQ].b, "HEAD")) 
 		sp->wantbody = 0;
-		http_ForceGet(sp->http);
-	} else
+	else
 		sp->wantbody = 1;
 
 	sp->sendbody = 0;

Modified: trunk/varnish-cache/bin/varnishtest/tests/b00000.vtc
===================================================================
--- trunk/varnish-cache/bin/varnishtest/tests/b00000.vtc	2010-04-15 07:13:51 UTC (rev 4661)
+++ trunk/varnish-cache/bin/varnishtest/tests/b00000.vtc	2010-04-15 07:33:44 UTC (rev 4662)
@@ -11,6 +11,8 @@
 
 varnish v1 -arg "-smalloc,1m" -vcl+backend {} -start
 
+varnish v1 -cliok "param.set diag_bitmap 0x2"
+
 varnish v1 -expect n_object == 0
 varnish v1 -expect client_conn == 0
 varnish v1 -expect client_req == 0

Added: trunk/varnish-cache/bin/varnishtest/tests/r00679.vtc
===================================================================
--- trunk/varnish-cache/bin/varnishtest/tests/r00679.vtc	                        (rev 0)
+++ trunk/varnish-cache/bin/varnishtest/tests/r00679.vtc	2010-04-15 07:33:44 UTC (rev 4662)
@@ -0,0 +1,16 @@
+# $Id$
+
+test "pass + HEAD"
+
+server s1 {
+	rxreq
+	expect req.request == "HEAD"
+	txresp 
+} -start
+
+varnish v1 -vcl+backend {} -start
+
+client c1 {
+	txreq -req HEAD -hdr "Cookie: foo=bar"
+	rxresp -no_obj
+} -run

Modified: trunk/varnish-cache/bin/varnishtest/vtc_http.c
===================================================================
--- trunk/varnish-cache/bin/varnishtest/vtc_http.c	2010-04-15 07:13:51 UTC (rev 4661)
+++ trunk/varnish-cache/bin/varnishtest/vtc_http.c	2010-04-15 07:33:44 UTC (rev 4662)
@@ -467,6 +467,7 @@
 cmd_http_rxresp(CMD_ARGS)
 {
 	struct http *hp;
+	int has_obj = 1;
 
 	(void)cmd;
 	(void)vl;
@@ -476,11 +477,17 @@
 	av++;
 
 	for(; *av != NULL; av++)
-		vtc_log(hp->vl, 0, "Unknown http rxresp spec: %s\n", *av);
+		if (!strcmp(*av, "-no_obj"))
+			has_obj = 0;
+		else
+			vtc_log(hp->vl, 0,
+			    "Unknown http rxresp spec: %s\n", *av);
 	vtc_log(hp->vl, 3, "rxresp");
 	http_rxhdr(hp);
 	http_splitheader(hp, 0);
-	if (!strcmp(hp->resp[1], "200"))
+	if (!has_obj)
+		;
+	else if (!strcmp(hp->resp[1], "200"))
 		http_swallow_body(hp, hp->resp, 1);
 	else
 		http_swallow_body(hp, hp->resp, 0);




More information about the varnish-commit mailing list