]> granicus.if.org Git - curl/commitdiff
sws: add 'connection-monitor' command support
authorDaniel Stenberg <daniel@haxx.se>
Thu, 5 Jul 2012 07:31:04 +0000 (09:31 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Thu, 5 Jul 2012 09:24:23 +0000 (11:24 +0200)
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.

tests/FILEFORMAT
tests/data/test503
tests/server/sws.c

index 66f0dfe5256028322a9a8c215361c762dc9381d4..040daf3d188309b72eb8c9f4011d8ed650dc617c 100644 (file)
@@ -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>
 
index e7543593fb239641dd3fdac95ec72591706e2e35..4b0ab8a437e12c2934bd5d6ed33bf1cb9b88e328 100644 (file)
@@ -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
index 14369e1d51140d786f930d104abc35e39954c069..21e3bf57adeb13e8030bdd45451f8c1ea825a9d9 100644 (file)
@@ -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