]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
tests: add delay command to the HTTP server
authorDan Fandrich <dan@coneharvesters.com>
Mon, 21 Aug 2023 21:10:25 +0000 (14:10 -0700)
committerDan Fandrich <dan@coneharvesters.com>
Tue, 22 Aug 2023 22:32:16 +0000 (15:32 -0700)
This adds a delay after client connect.

tests/FILEFORMAT.md
tests/server/sws.c

index 82e5f6c27c45b27a1791d919f0b1c267b4fb8fac..e7245c2b75111fe85384ef3b06818cebd4f3cef9 100644 (file)
@@ -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
index bf2c6f94ecd71ec0d7a8f3dfafcd1d86a0d8acc7..c23534210aa95d35a895666e2d4efa1cd093ff3b 100644 (file)
@@ -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--;
     }