]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
squidclient: Use -k option to control connection keep-alive or close
authorAmos Jeffries <squid3@treenet.co.nz>
Wed, 7 Apr 2010 13:15:09 +0000 (01:15 +1200)
committerAmos Jeffries <squid3@treenet.co.nz>
Wed, 7 Apr 2010 13:15:09 +0000 (01:15 +1200)
This is needed to prevent HTTP 1.1 servers (or Squid) holding the
connection open after squidclient has finished.

Retain the old behavior for HTTP/1.0 requests.

tools/squidclient.cc

index e2a82ca33068d78bd3d4b8d49014711922a57475..9a9cb9d513f2194e78feef4b3e77fff25449252b 100644 (file)
@@ -126,7 +126,7 @@ usage(const char *progname)
     fprintf(stderr,
             "Version: %s\n"
             "Usage: %s [-arsv] [-g count] [-h remote host] [-H 'string'] [-i IMS] [-I ping-interval] [-j 'Host-header']"
-            "[-l local-host] [-m method] [-p port] [-P file] [-t count] [-T timeout] [-u proxy-user] [-U www-user] "
+            "[-k] [-l local-host] [-m method] [-p port] [-P file] [-t count] [-T timeout] [-u proxy-user] [-U www-user] "
             "[-V version] [-w proxy-password] [-W www-password] url\n"
             "\n"
             "Options:\n"
@@ -137,6 +137,7 @@ usage(const char *progname)
             "    -i IMS       If-Modified-Since time (in Epoch seconds).\n"
             "    -I interval  Ping interval in seconds (default 1 second).\n"
             "    -j hosthdr   Host header content\n"
+            "    -k           Keep the connection active. Default is to do only one request then close.\n"
             "    -l host      Specify a local IP address to bind to.  Default is none.\n"
             "    -m method    Request method, default is GET.\n"
             "    -p port      Port number of cache.  Default is %d.\n"
@@ -435,10 +436,10 @@ main(int argc, char *argv[])
                 } else
                     strcat(msg, "Connection: keep-alive\r\n");
             }
-        } else {
-            if (!keep_alive)
-                strcat(msg, "Connection: close\r\n");
         }
+        /* HTTP/1.1 may need close */
+        if (!keep_alive)
+            strcat(msg, "Connection: close\r\n");
 
         strcat(msg, extra_hdrs);
         strcat(msg, "\r\n");