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

phk at varnish-cache.org phk at varnish-cache.org
Mon Aug 9 10:14:16 CEST 2010


Author: phk
Date: 2010-08-09 10:14:15 +0200 (Mon, 09 Aug 2010)
New Revision: 5075

Added:
   trunk/varnish-cache/bin/varnishtest/tests/r00733.vtc
Modified:
   trunk/varnish-cache/bin/varnishd/cache_fetch.c
   trunk/varnish-cache/bin/varnishtest/tests/b00011.vtc
   trunk/varnish-cache/bin/varnishtest/tests/b00027.vtc
   trunk/varnish-cache/bin/varnishtest/tests/e00007.vtc
   trunk/varnish-cache/bin/varnishtest/tests/e00014.vtc
   trunk/varnish-cache/bin/varnishtest/vtc_http.c
Log:
If we get a HTTP/1.1 response with no indicatation of length, assume EOF
encoding, rather than zero length.

This has implications for a number of testcases which were written
using the previous assumption.

Fixes: #733



Modified: trunk/varnish-cache/bin/varnishd/cache_fetch.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_fetch.c	2010-08-09 06:55:52 UTC (rev 5074)
+++ trunk/varnish-cache/bin/varnishd/cache_fetch.c	2010-08-09 08:14:15 UTC (rev 5075)
@@ -446,7 +446,10 @@
 
 	is_head = (strcasecmp(http_GetReq(sp->wrk->bereq), "head") == 0);
 
-	/* Determine if we have a body or not */
+	/*
+	 * Determine if we have a body or not
+	 * XXX: Missing:  RFC2616 sec. 4.4 in re 1xx, 204 & 304 responses
+	 */
 	cls = 0;
 	mklen = 0;
 	if (is_head) {
@@ -493,6 +496,7 @@
 		 * Assume zero length
 		 * XXX:  ???
 		 */
+		cls = fetch_eof(sp, sp->wrk->htc);
 		mklen = 1;
 	}
 

Modified: trunk/varnish-cache/bin/varnishtest/tests/b00011.vtc
===================================================================
--- trunk/varnish-cache/bin/varnishtest/tests/b00011.vtc	2010-08-09 06:55:52 UTC (rev 5074)
+++ trunk/varnish-cache/bin/varnishtest/tests/b00011.vtc	2010-08-09 08:14:15 UTC (rev 5075)
@@ -4,7 +4,9 @@
 
 server s1 {
 	rxreq 
-	txresp -hdr "Connection: close" 
+	send "HTTP/1.1 200 Ok\n"
+	send "Connection: close\n" 
+	send "\n"
 	send "Body line 1\n"
 	send "Body line 2\n"
 	send "Body line 3\n"

Modified: trunk/varnish-cache/bin/varnishtest/tests/b00027.vtc
===================================================================
--- trunk/varnish-cache/bin/varnishtest/tests/b00027.vtc	2010-08-09 06:55:52 UTC (rev 5074)
+++ trunk/varnish-cache/bin/varnishtest/tests/b00027.vtc	2010-08-09 08:14:15 UTC (rev 5075)
@@ -8,7 +8,9 @@
 	rxreq
 	txresp -proto HTTP/1.0 -hdr "Connection: keep-alive"
 	rxreq
-	txresp -hdr "Transfer-encoding: foobar"
+	send "HTTP/1.1 200 Ok\n"
+	send "Transfer-encoding: foobar\n"
+	send "\n"
 } -start
 
 varnish v1 -vcl+backend {} -start

Modified: trunk/varnish-cache/bin/varnishtest/tests/e00007.vtc
===================================================================
--- trunk/varnish-cache/bin/varnishtest/tests/e00007.vtc	2010-08-09 06:55:52 UTC (rev 5074)
+++ trunk/varnish-cache/bin/varnishtest/tests/e00007.vtc	2010-08-09 08:14:15 UTC (rev 5075)
@@ -18,7 +18,9 @@
 server s1 {
 	rxreq 
 	expect req.url == "/foo/bar"
-	txresp -hdr "Connection: close"
+	send "HTTP/1.1 200 Ok\n"
+	send "Connection: close\n"
+	send "\n"
 	send {
 		<html>filler
 		This is before the test

Modified: trunk/varnish-cache/bin/varnishtest/tests/e00014.vtc
===================================================================
--- trunk/varnish-cache/bin/varnishtest/tests/e00014.vtc	2010-08-09 06:55:52 UTC (rev 5074)
+++ trunk/varnish-cache/bin/varnishtest/tests/e00014.vtc	2010-08-09 08:14:15 UTC (rev 5075)
@@ -5,7 +5,9 @@
 server s1 {
         rxreq
         expect req.url == "/foo"
-        txresp -hdr "Connection: close"
+	send "HTTP/1.1 200 Ok\n"
+        send "Connection: close\n"
+	send "\n"
         send {           <a>   <esi/>                          }
 } -start
 

Added: trunk/varnish-cache/bin/varnishtest/tests/r00733.vtc
===================================================================
--- trunk/varnish-cache/bin/varnishtest/tests/r00733.vtc	                        (rev 0)
+++ trunk/varnish-cache/bin/varnishtest/tests/r00733.vtc	2010-08-09 08:14:15 UTC (rev 5075)
@@ -0,0 +1,18 @@
+# $Id$
+
+test "HTTP/1.1 Backend sends no length hint"
+
+server s1 {
+	rxreq
+	send "HTTP/1.1 200 Ok\n"
+	send "\n"
+	send "12345"
+} -start
+
+varnish v1 -vcl+backend {} -start
+
+client c1 {
+	txreq
+	rxresp
+	expect resp.bodylen == 5
+} -run

Modified: trunk/varnish-cache/bin/varnishtest/vtc_http.c
===================================================================
--- trunk/varnish-cache/bin/varnishtest/vtc_http.c	2010-08-09 06:55:52 UTC (rev 5074)
+++ trunk/varnish-cache/bin/varnishtest/vtc_http.c	2010-08-09 08:14:15 UTC (rev 5075)
@@ -507,7 +507,8 @@
 	const char *msg = "Ok";
 	int bodylen = 0;
 	char *b, *c;
-	char *body = NULL;
+	char *body = NULL, *nullbody;
+	
 
 	(void)cmd;
 	(void)vl;
@@ -518,6 +519,10 @@
 
 	vsb_clear(hp->vsb);
 
+	/* send a "Content-Length: 0" header unless something else happens */
+	REPLACE(body, "");
+	nullbody = body;
+
 	for(; *av != NULL; av++) {
 		if (!strcmp(*av, "-proto")) {
 			proto = av[1];
@@ -544,8 +549,9 @@
 	}
 	for(; *av != NULL; av++) {
 		if (!strcmp(*av, "-body")) {
-			AZ(body);
+			assert(body == nullbody);
 			REPLACE(body, av[1]);
+
 			AN(body);
 			av++;
 			bodylen = strlen(body);
@@ -560,7 +566,7 @@
 				}
 			}
 		} else if (!strcmp(*av, "-bodylen")) {
-			AZ(body);
+			assert(body == nullbody);
 			body = synth_body(av[1]);
 			bodylen = strlen(body);
 			av++;




More information about the varnish-commit mailing list