From: Amos Jeffries Date: Wed, 7 Apr 2010 13:15:09 +0000 (+1200) Subject: squidclient: Use -k option to control connection keep-alive or close X-Git-Tag: SQUID_3_2_0_1~312 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=51d94d10005fd2cfb8caa189c304aceece31ed03;p=thirdparty%2Fsquid.git squidclient: Use -k option to control connection keep-alive or close 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. --- diff --git a/tools/squidclient.cc b/tools/squidclient.cc index e2a82ca330..9a9cb9d513 100644 --- a/tools/squidclient.cc +++ b/tools/squidclient.cc @@ -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");