r4001 - in trunk/varnish-cache/bin/varnishtest: . tests

sky at projects.linpro.no sky at projects.linpro.no
Tue Mar 24 09:30:08 CET 2009


Author: sky
Date: 2009-03-24 09:30:08 +0100 (Tue, 24 Mar 2009)
New Revision: 4001

Added:
   trunk/varnish-cache/bin/varnishtest/tests/a00010.vtc
Modified:
   trunk/varnish-cache/bin/varnishtest/vtc_http.c
Log:
initial support for interpolating \0 and supporting it in the test framework

Added: trunk/varnish-cache/bin/varnishtest/tests/a00010.vtc
===================================================================
--- trunk/varnish-cache/bin/varnishtest/tests/a00010.vtc	                        (rev 0)
+++ trunk/varnish-cache/bin/varnishtest/tests/a00010.vtc	2009-03-24 08:30:08 UTC (rev 4001)
@@ -0,0 +1,23 @@
+# $Id$
+
+test "simply test that the framework support \0"
+
+server s1 -listen 127.0.0.1:9080 {
+        rxreq
+	expect req.url == "/"
+	txresp -body {a\0bc}
+} 
+
+server s1 -start 
+
+client c1 -connect 127.0.0.1:9080 {
+
+	txreq
+	rxresp
+	expect resp.bodylen == 4
+} 
+
+client c1 -run
+
+server s1 -wait
+


Property changes on: trunk/varnish-cache/bin/varnishtest/tests/a00010.vtc
___________________________________________________________________
Name: svn:keywords
   + Id

Modified: trunk/varnish-cache/bin/varnishtest/vtc_http.c
===================================================================
--- trunk/varnish-cache/bin/varnishtest/vtc_http.c	2009-03-23 15:02:33 UTC (rev 4000)
+++ trunk/varnish-cache/bin/varnishtest/vtc_http.c	2009-03-24 08:30:08 UTC (rev 4001)
@@ -477,6 +477,8 @@
 	const char *proto = "HTTP/1.1";
 	const char *status = "200";
 	const char *msg = "Ok";
+	int bodylen;
+	char *b, *c;
 	char *body = NULL;
 
 	(void)cmd;
@@ -517,9 +519,21 @@
 			AZ(body);
 			REPLACE(body, av[1]);
 			av++;
+			bodylen = strlen(body);
+			for (b = body; *b != '\0'; b++) {
+				if(*b == '\\' && b[1] == '0') {
+					*b = '\0';
+					for(c = b+1; *c != '\0'; c++) {
+						*c = c[1];
+					}
+					b++;
+					bodylen--;
+				}
+			}
 		} else if (!strcmp(*av, "-bodylen")) {
 			AZ(body);
 			body = synth_body(av[1]);
+			bodylen = strlen(body);
 			av++;
 		} else
 			break;
@@ -527,10 +541,10 @@
 	if (*av != NULL)
 		vtc_log(hp->vl, 0, "Unknown http txresp spec: %s\n", *av);
 	if (body != NULL)
-		vsb_printf(hp->vsb, "Content-Length: %d%s", strlen(body), nl);
+		vsb_printf(hp->vsb, "Content-Length: %d%s", bodylen, nl);
 	vsb_cat(hp->vsb, nl);
 	if (body != NULL)
-		vsb_cat(hp->vsb, body);
+		vsb_bcat(hp->vsb, body, bodylen);
 	http_write(hp, 4, "txresp");
 }
 



More information about the varnish-commit mailing list