diff --git a/tests/FILEFORMAT.md b/tests/FILEFORMAT.md index 82e5f6c27c..e7245c2b75 100644 --- a/tests/FILEFORMAT.md +++ b/tests/FILEFORMAT.md @@ -332,6 +332,7 @@ about to issue. - `auth_required` if this is set and a POST/PUT is made without auth, the server will NOT wait for the full request body to get sent +- `delay: [msecs]` - delay this amount after connection - `idle` - do nothing after receiving the request, just "sit idle" - `stream` - continuously send data to the client, never-ending - `writedelay: [msecs]` delay this amount between reply packets diff --git a/tests/server/sws.c b/tests/server/sws.c index bf2c6f94ec..c23534210a 100644 --- a/tests/server/sws.c +++ b/tests/server/sws.c @@ -112,6 +112,7 @@ struct httprequest { size_t cl; /* Content-Length of the incoming request */ bool digest; /* Authorization digest header found */ bool ntlm; /* Authorization ntlm header found */ + int delay; /* if non-zero, delay this number of msec after connect */ int writedelay; /* if non-zero, delay this number of milliseconds between writes in the response */ int skip; /* if non-zero, the server is instructed to not read this @@ -328,6 +329,10 @@ static int parse_servercmd(struct httprequest *req) logmsg("instructed to reject Expect: 100-continue"); req->noexpect = TRUE; } + else if(1 == sscanf(cmd, "delay: %d", &num)) { + logmsg("instructed to delay %d msecs after connect", num); + req->delay = num; + } else if(1 == sscanf(cmd, "writedelay: %d", &num)) { logmsg("instructed to delay %d msecs between packets", num); req->writedelay = num; @@ -854,6 +859,7 @@ static void init_httprequest(struct httprequest *req) req->skip = 0; req->skipall = FALSE; req->noexpect = FALSE; + req->delay = 0; req->writedelay = 0; req->rcmd = RCMD_NORMALREQ; req->prot_version = 0; @@ -2333,6 +2339,8 @@ int main(int argc, char *argv[]) logmsg("accept_connection %d returned %d", sock, msgsock); if(CURL_SOCKET_BAD == msgsock) goto sws_cleanup; + if(req->delay) + wait_ms(req->delay); } while(msgsock > 0); active--; }