diff options
Diffstat (limited to 'tests/server')
-rw-r--r-- | tests/server/sws.c | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/tests/server/sws.c b/tests/server/sws.c index 65f8aa619..eed2d5fd9 100644 --- a/tests/server/sws.c +++ b/tests/server/sws.c @@ -118,6 +118,8 @@ struct httprequest { int rcmd; /* doing a special command, see defines above */ int prot_version; /* HTTP version * 10 */ int callcount; /* times ProcessRequest() gets called */ + bool skipall; /* skip all incoming data */ + bool noexpect; /* refuse Expect: (don't read the body) */ bool connmon; /* monitor the state of the connection, log disconnects */ bool upgrade; /* test case allows upgrade to http2 */ bool upgrade_request; /* upgrade request found and allowed */ @@ -179,6 +181,9 @@ const char *serverlogfile = DEFAULT_LOGFILE; /* close connection */ #define CMD_SWSCLOSE "swsclose" +/* deny Expect: requests */ +#define CMD_NOEXPECT "no-expect" + #define END_OF_HEADERS "\r\n\r\n" enum { @@ -427,6 +432,10 @@ static int parse_servercmd(struct httprequest *req) logmsg("instructed to skip this number of bytes %d", num); req->skip = num; } + else if(!strncmp(CMD_NOEXPECT, cmd, strlen(CMD_NOEXPECT))) { + logmsg("instructed to reject Expect: 100-continue"); + req->noexpect = TRUE; + } else if(1 == sscanf(cmd, "writedelay: %d", &num)) { logmsg("instructed to delay %d secs between packets", num); req->writedelay = num; @@ -735,19 +744,28 @@ static int ProcessRequest(struct httprequest *req) req->open = FALSE; /* closes connection */ return 1; /* done */ } - req->cl = clen - req->skip; + if(req->skipall) + req->cl = 0; + else + req->cl = clen - req->skip; logmsg("Found Content-Length: %lu in the request", clen); if(req->skip) logmsg("... but will abort after %zu bytes", req->cl); - break; } else if(strncasecompare("Transfer-Encoding: chunked", line, strlen("Transfer-Encoding: chunked"))) { /* chunked data coming in */ chunked = TRUE; } - + else if(req->noexpect && + strncasecompare("Expect: 100-continue", line, + strlen("Expect: 100-continue"))) { + if(req->cl) + req->cl = 0; + req->skipall = TRUE; + logmsg("Found Expect: 100-continue, ignore body"); + } if(chunked) { if(strstr(req->reqbuf, "\r\n0\r\n\r\n")) { @@ -939,6 +957,8 @@ static void init_httprequest(struct httprequest *req) req->digest = FALSE; req->ntlm = FALSE; req->skip = 0; + req->skipall = FALSE; + req->noexpect = FALSE; req->writedelay = 0; req->rcmd = RCMD_NORMALREQ; req->prot_version = 0; |