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

Add "recv N" action

parent dd54ea0e
......@@ -975,6 +975,34 @@ cmd_http_txreq(CMD_ARGS)
http_write(hp, 4, "txreq");
}
/**********************************************************************
* Receive N characters
*/
static void
cmd_http_recv(CMD_ARGS)
{
struct http *hp;
int i, n;
uint8_t u[32];
(void)cmd;
(void)vl;
CAST_OBJ_NOTNULL(hp, priv, HTTP_MAGIC);
AN(av[1]);
AZ(av[2]);
n = strtoul(av[1], NULL, 0);
while (n > 0) {
i = read(hp->fd, u, n > 32 ? 32 : n);
if (i > 0)
vtc_dump(hp->vl, 4, "recv", u, i);
else
vtc_log(hp->vl, hp->fatal, "recv() got %d (%s)", i,
strerror(errno));
n -= i;
}
}
/**********************************************************************
* Send a string
*/
......@@ -1307,6 +1335,7 @@ static const struct cmds http_cmds[] = {
{ "rxrespbody", cmd_http_rxrespbody },
{ "gunzip", cmd_http_gunzip_body },
{ "expect", cmd_http_expect },
{ "recv", cmd_http_recv },
{ "send", cmd_http_send },
{ "send_n", cmd_http_send_n },
{ "send_urgent", cmd_http_send_urgent },
......
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