Commit c001cb9f authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Add -bodylen which creates a synthetic body of the specified length.

The generated body is the classic drum-printer test pattern:

	!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_\n
	"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`\n
	#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`a\n
	$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`ab\n

The last char is always a \n




git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@3173 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 1c0aed69
......@@ -65,6 +65,41 @@ struct http {
/* XXX: we may want to vary this */
static const char *nl = "\r\n";
/**********************************************************************
* Generate a synthetic body
*/
static const char *
synth_body(const char *len)
{
int i, j, k, l;
char *b;
AN(len);
i = strtoul(len, NULL, 0);
assert(i > 0);
b = malloc(i + 1);
AN(b);
l = k = '!';
for (j = 0; j < i; j++) {
if ((j % 64) == 63) {
b[j] = '\n';
k++;
if (k == '~')
k = '!';
l = k;
} else {
b[j] = l++;
if (l == '~')
l = '!';
}
}
b[i - 1] = '\n';
b[i] = '\0';
return (b);
}
/**********************************************************************
* Finish and write the vsb to the fd
*/
......@@ -441,6 +476,10 @@ cmd_http_txresp(CMD_ARGS)
AZ(body);
body = av[1];
av++;
} else if (!strcmp(*av, "-bodylen")) {
AZ(body);
body = synth_body(av[1]);
av++;
} else
break;
}
......@@ -530,6 +569,10 @@ cmd_http_txreq(CMD_ARGS)
AZ(body);
body = av[1];
av++;
} else if (!strcmp(*av, "-bodylen")) {
AZ(body);
body = synth_body(av[1]);
av++;
} else
break;
}
......
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