Commit f8046046 authored by Artur Bergman's avatar Artur Bergman

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

git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@4001 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 231cb9c1
# $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
......@@ -477,6 +477,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;
......@@ -517,9 +519,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;
......@@ -527,10 +541,10 @@ cmd_http_txresp(CMD_ARGS)
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");
}
......
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