Commit 646f3c4e authored by Tollef Fog Heen's avatar Tollef Fog Heen

Merge r4001: initial support for interpolating \0 and supporting it in the test framework



git-svn-id: http://www.varnish-cache.org/svn/branches/2.0@4004 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 5defcad3
# $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
......@@ -479,6 +479,8 @@ cmd_http_txresp(CMD_ARGS)
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 @@ cmd_http_txresp(CMD_ARGS)
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 @@ cmd_http_txresp(CMD_ARGS)
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");
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment