aboutsummaryrefslogtreecommitdiff
path: root/tests/server
diff options
context:
space:
mode:
authorDan Fandrich <dan@coneharvesters.com>2010-10-02 00:21:59 +0200
committerDaniel Stenberg <daniel@haxx.se>2010-10-02 00:21:59 +0200
commit15622e69a995bb4bee04bc647d86d658860914be (patch)
treefbc632ba629436aa2b4bfb33030e4b4f823d3126 /tests/server
parent8500586251d9ef3310e09171a7514d9e1d054bf1 (diff)
sws: Added writedelay HTTP server command
This delays between write operations, hopefully making it easier to spot problems where libcurl doesn't flush the socket properly before waiting for the next response.
Diffstat (limited to 'tests/server')
-rw-r--r--tests/server/sws.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/server/sws.c b/tests/server/sws.c
index 8a93b3b8d..a4c040bd2 100644
--- a/tests/server/sws.c
+++ b/tests/server/sws.c
@@ -105,6 +105,8 @@ struct httprequest {
size_t cl; /* Content-Length of the incoming request */
bool digest; /* Authorization digest header found */
bool ntlm; /* Authorization ntlm header found */
+ int writedelay; /* if non-zero, delay this number of seconds between
+ writes in the response */
int pipe; /* if non-zero, expect this many requests to do a "piped"
request/response */
int skip; /* if non-zero, the server is instructed to not read this
@@ -435,6 +437,10 @@ static int ProcessRequest(struct httprequest *req)
logmsg("instructed to skip this number of bytes %d", num);
req->skip = num;
}
+ else if(1 == sscanf(cmd, "writedelay: %d", &num)) {
+ logmsg("instructed to delay %d secs between packets", num);
+ req->writedelay = num;
+ }
else {
logmsg("funny instruction found: %s", cmd);
}
@@ -745,6 +751,7 @@ static int get_request(curl_socket_t sock, struct httprequest *req)
req->ntlm = FALSE;
req->pipe = 0;
req->skip = 0;
+ req->writedelay = 0;
req->rcmd = RCMD_NORMALREQ;
req->prot_version = 0;
req->pipelining = FALSE;
@@ -1015,6 +1022,10 @@ static int send_doc(curl_socket_t sock, struct httprequest *req)
else {
logmsg("Sent off %zd bytes", written);
}
+ if (req->writedelay) {
+ logmsg("Pausing %d seconds", req->writedelay);
+ sleep(req->writedelay);
+ }
/* write to file as well */
fwrite(buffer, 1, (size_t)written, dump);
if(got_exit_signal)