r4004 - in branches/2.0/varnish-cache/bin/varnishtest: . tests
tfheen at projects.linpro.no
tfheen at projects.linpro.no
Fri Mar 27 13:25:11 CET 2009
Author: tfheen
Date: 2009-03-27 13:25:11 +0100 (Fri, 27 Mar 2009)
New Revision: 4004
Added:
branches/2.0/varnish-cache/bin/varnishtest/tests/a00010.vtc
Modified:
branches/2.0/varnish-cache/bin/varnishtest/vtc_http.c
Log:
Merge r4001: initial support for interpolating \0 and supporting it in the test framework
Copied: branches/2.0/varnish-cache/bin/varnishtest/tests/a00010.vtc (from rev 4001, trunk/varnish-cache/bin/varnishtest/tests/a00010.vtc)
===================================================================
--- branches/2.0/varnish-cache/bin/varnishtest/tests/a00010.vtc (rev 0)
+++ branches/2.0/varnish-cache/bin/varnishtest/tests/a00010.vtc 2009-03-27 12:25:11 UTC (rev 4004)
@@ -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
+
Modified: branches/2.0/varnish-cache/bin/varnishtest/vtc_http.c
===================================================================
--- branches/2.0/varnish-cache/bin/varnishtest/vtc_http.c 2009-03-27 12:13:31 UTC (rev 4003)
+++ branches/2.0/varnish-cache/bin/varnishtest/vtc_http.c 2009-03-27 12:25:11 UTC (rev 4004)
@@ -479,6 +479,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;
@@ -519,9 +521,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;
@@ -531,10 +545,10 @@
exit (1);
}
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