aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2012-07-05 09:31:04 +0200
committerDaniel Stenberg <daniel@haxx.se>2012-07-05 11:24:23 +0200
commit28dc509dde13e0f8da1b5dca2979d936609a4698 (patch)
treec0d74e0ca51e81bac5bf15361764f771e3f2804e /tests
parent897cf5d1175fc4757cf71a7bd45d531c7f50dec3 (diff)
sws: add 'connection-monitor' command support
Using this, the server will output in the protocol log when the connection gets disconnected and thus we will verify correctly in the test cases that the connection doesn't get closed prematurely. This is important for example NTLM to work. Documentation added to FILEFORMAT, test 503 updated to use this.
Diffstat (limited to 'tests')
-rw-r--r--tests/FILEFORMAT1
-rw-r--r--tests/data/test5033
-rw-r--r--tests/server/sws.c21
3 files changed, 21 insertions, 4 deletions
diff --git a/tests/FILEFORMAT b/tests/FILEFORMAT
index 66f0dfe52..040daf3d1 100644
--- a/tests/FILEFORMAT
+++ b/tests/FILEFORMAT
@@ -133,6 +133,7 @@ skip: [num] instructs the server to ignore reading this many bytes from a PU
rtp: part [num] channel [num] size [num]
stream a fake RTP packet for the given part on a chosen channel
with the given payload size
+connection-monitor
</servercmd>
</reply>
diff --git a/tests/data/test503 b/tests/data/test503
index e7543593f..4b0ab8a43 100644
--- a/tests/data/test503
+++ b/tests/data/test503
@@ -13,6 +13,9 @@ multi
# Server-side
<reply>
+<servercmd>
+connection-monitor
+</servercmd>
<data>
HTTP/1.1 200 OK swsclose
Date: Thu, 09 Nov 2010 14:49:00 GMT
diff --git a/tests/server/sws.c b/tests/server/sws.c
index 14369e1d5..21e3bf57a 100644
--- a/tests/server/sws.c
+++ b/tests/server/sws.c
@@ -118,6 +118,7 @@ struct httprequest {
bool pipelining; /* true if request is pipelined */
int callcount; /* times ProcessRequest() gets called */
unsigned short connect_port; /* the port number CONNECT used */
+ bool connmon; /* monitor the state of the connection, log disconnects */
};
static int ProcessRequest(struct httprequest *req);
@@ -157,6 +158,11 @@ const char *serverlogfile = DEFAULT_LOGFILE;
/* 'stream' means to send a never-ending stream of data */
#define CMD_STREAM "stream"
+/* 'connection-monitor' will output when a server/proxy connection gets
+ disconnected as for some cases it is important that it gets done at the
+ proper point - like with NTLM */
+#define CMD_CONNECTIONMONITOR "connection-monitor"
+
#define END_OF_HEADERS "\r\n\r\n"
enum {
@@ -437,6 +443,11 @@ static int ProcessRequest(struct httprequest *req)
logmsg("instructed to stream");
req->rcmd = RCMD_STREAM;
}
+ else if(!strncmp(CMD_CONNECTIONMONITOR, cmd,
+ strlen(CMD_CONNECTIONMONITOR))) {
+ logmsg("enabled connection monitoring");
+ req->connmon = TRUE;
+ }
else if(1 == sscanf(cmd, "pipe: %d", &num)) {
logmsg("instructed to allow a pipe size of %d", num);
if(num < 0)
@@ -814,6 +825,7 @@ static int get_request(curl_socket_t sock, struct httprequest *req)
req->pipelining = FALSE;
req->callcount = 0;
req->connect_port = 0;
+ req->connmon = FALSE;
/*** end of httprequest init ***/
@@ -1960,10 +1972,6 @@ int main(int argc, char *argv[])
if(req.open) {
logmsg("=> persistant connection request ended, awaits new request\n");
- /*
- const char *keepopen="[KEEPING CONNECTION OPEN]";
- storerequest((char *)keepopen, strlen(keepopen));
- */
}
/* if we got a CONNECT, loop and get another request as well! */
} while(req.open || (req.testno == DOCNUMBER_CONNECT));
@@ -1973,6 +1981,11 @@ int main(int argc, char *argv[])
logmsg("====> Client disconnect");
+ if(req.connmon) {
+ const char *keepopen="[DISCONNECT]\n";
+ storerequest((char *)keepopen, strlen(keepopen));
+ }
+
if(!req.open)
/* When instructed to close connection after server-reply we
wait a very small amount of time before doing so. If this