mirror of
https://github.com/curl/curl.git
synced 2025-02-17 14:59:45 +08:00
tests: add delay command to the HTTP server
This adds a delay after client connect.
This commit is contained in:
parent
a2caea87bc
commit
66883a89d6
@ -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
|
||||
|
@ -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--;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user