summaryrefslogtreecommitdiff
path: root/test/src
diff options
context:
space:
mode:
authorHeiko Schlittermann (HS12-RIPE) <hs@schlittermann.de>2016-11-05 00:50:37 +0100
committerHeiko Schlittermann (HS12-RIPE) <hs@schlittermann.de>2016-11-05 00:50:37 +0100
commitf6f239461fd62b3a4f3142b6b2a85f8f65eee486 (patch)
treeed8e56cbd762d427a34095e6c2f732783db761bd /test/src
parent88d979eb5aee7d63c4c22aea940123a2e696526c (diff)
Testsuite: limited support for Content-length:
The simulation of the rspamd protocol needs this, as rspamd-client sends this Content-length header and newer rspamd-servers honour this header in favour of a half closed connection.
Diffstat (limited to 'test/src')
-rw-r--r--test/src/server.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/test/src/server.c b/test/src/server.c
index 1abd3f49a..4bdde65bf 100644
--- a/test/src/server.c
+++ b/test/src/server.c
@@ -496,6 +496,12 @@ s = script;
for (count = 0; count < connection_count; count++)
{
+
+ struct {
+ int left;
+ int in_use;
+ } content_length = { .left = 0, .in_use = 0 };
+
alarm(timeout);
if (port <= 0)
{
@@ -709,6 +715,7 @@ for (count = 0; count < connection_count; count++)
alarm(timeout);
n = read(dup_accept_socket, CS buffer+offset, s->len - offset);
+ if (content_length.in_use) content_length.left -= n;
if (n == 0)
{
printf("%sxpected EOF read from client\n",
@@ -726,8 +733,11 @@ for (count = 0; count < connection_count; count++)
if (data) do
{
n = (read(dup_accept_socket, &c, 1) == 1 && c == '.');
+ if (content_length.in_use) content_length.left--;
while (c != '\n' && read(dup_accept_socket, &c, 1) == 1)
- ;
+ {
+ if (content_length.in_use) content_length.left--;
+ }
} while (!n);
else if (memcmp(ss, buffer, n) != 0)
{
@@ -751,6 +761,7 @@ for (count = 0; count < connection_count; count++)
}
alarm(0);
n = (int)strlen(CS buffer);
+ if (content_length.in_use) content_length.left -= (n - offset);
while (n > 0 && isspace(buffer[n-1])) n--;
buffer[n] = 0;
printf("%s\n", buffer);
@@ -764,6 +775,9 @@ for (count = 0; count < connection_count; count++)
break;
}
}
+
+ if (sscanf(buffer, "<Content-length: %d", &content_length.left)) content_length.in_use = 1;
+ if (content_length.in_use && content_length.left <= 0) shutdown(dup_accept_socket, SHUT_RD);
}
}