]> sjero.net Git - wget/commitdiff
[svn] New option --no-http-keep-alive.
authorhniksic <devnull@localhost>
Mon, 20 Nov 2000 00:04:06 +0000 (16:04 -0800)
committerhniksic <devnull@localhost>
Mon, 20 Nov 2000 00:04:06 +0000 (16:04 -0800)
Published in <sxsd7fr1pdf.fsf@florida.arsdigita.de>.

src/ChangeLog
src/http.c
src/init.c
src/main.c
src/options.h

index 93af875d25030c6ed38c380c7c53b76e22e01417..71401675a3fc499ee8f69b00daacba7d115078d2 100644 (file)
@@ -1,3 +1,8 @@
+2000-11-20  Hrvoje Niksic  <hniksic@arsdigita.com>
+
+       * http.c (gethttp): Don't use the return value of sprintf().
+       (gethttp): Inhibit keep-alive if opt.http_keep_alive is 0.
+
 2000-11-20  Hrvoje Niksic  <hniksic@arsdigita.com>
 
        * recur.c (recursive_retrieve): Print the "so we don't load"
 2000-11-20  Hrvoje Niksic  <hniksic@arsdigita.com>
 
        * recur.c (recursive_retrieve): Print the "so we don't load"
index 07621acc5971e6a1e5f4b6238b98a38016cff19c..f75980317a8ac001d48f9710a19ce4f86101540f 100644 (file)
@@ -444,9 +444,8 @@ gethttp (struct urlinfo *u, struct http_stat *hs, int *dt)
   char *authenticate_h;
   char *proxyauth;
   char *all_headers;
   char *authenticate_h;
   char *proxyauth;
   char *all_headers;
-  char *host_port;
+  char *port_maybe;
   char *request_keep_alive;
   char *request_keep_alive;
-  int host_port_len;
   int sock, hcount, num_written, all_length, remport, statcode;
   long contlen, contrange;
   struct urlinfo *ou;
   int sock, hcount, num_written, all_length, remport, statcode;
   long contlen, contrange;
   struct urlinfo *ou;
@@ -474,7 +473,7 @@ gethttp (struct urlinfo *u, struct http_stat *hs, int *dt)
   authenticate_h = 0;
   auth_tried_already = 0;
 
   authenticate_h = 0;
   auth_tried_already = 0;
 
-  inhibit_keep_alive = (u->proxy != NULL);
+  inhibit_keep_alive = (!opt.http_keep_alive || u->proxy != NULL);
 
  again:
   /* We need to come back here when the initial attempt to retrieve
 
  again:
   /* We need to come back here when the initial attempt to retrieve
@@ -623,15 +622,12 @@ gethttp (struct urlinfo *u, struct http_stat *hs, int *dt)
   remhost = ou->host;
   remport = ou->port;
 
   remhost = ou->host;
   remport = ou->port;
 
-  if (remport == 80)
+  /* String of the form :PORT.  Used only for non-standard ports. */
+  port_maybe = NULL;
+  if (remport != 80)
     {
     {
-      host_port = NULL;
-      host_port_len = 0;
-    }
-  else
-    {
-      host_port = (char *)alloca (numdigit (remport) + 2);
-      host_port_len = sprintf (host_port, ":%d", remport);
+      port_maybe = (char *)alloca (numdigit (remport) + 2);
+      sprintf (port_maybe, ":%d", remport);
     }
 
   if (!inhibit_keep_alive)
     }
 
   if (!inhibit_keep_alive)
@@ -642,7 +638,8 @@ gethttp (struct urlinfo *u, struct http_stat *hs, int *dt)
   /* Allocate the memory for the request.  */
   request = (char *)alloca (strlen (command) + strlen (path)
                            + strlen (useragent)
   /* Allocate the memory for the request.  */
   request = (char *)alloca (strlen (command) + strlen (path)
                            + strlen (useragent)
-                           + strlen (remhost) + host_port_len
+                           + strlen (remhost)
+                           + (port_maybe ? strlen (port_maybe) : 0)
                            + strlen (HTTP_ACCEPT)
                            + (request_keep_alive
                               ? strlen (request_keep_alive) : 0)
                            + strlen (HTTP_ACCEPT)
                            + (request_keep_alive
                               ? strlen (request_keep_alive) : 0)
@@ -661,7 +658,7 @@ Host: %s%s\r\n\
 Accept: %s\r\n\
 %s%s%s%s%s%s%s\r\n",
           command, path, useragent, remhost,
 Accept: %s\r\n\
 %s%s%s%s%s%s%s\r\n",
           command, path, useragent, remhost,
-          host_port ? host_port : "",
+          port_maybe ? port_maybe : "",
           HTTP_ACCEPT,
           request_keep_alive ? request_keep_alive : "",
           referer ? referer : "",
           HTTP_ACCEPT,
           request_keep_alive ? request_keep_alive : "",
           referer ? referer : "",
index b511c724859ddf3260482eb26deaaf5b45bc7c09..e7b974f4d4353b539c4b347b75d9cabb814bf4f9 100644 (file)
@@ -122,6 +122,7 @@ static struct {
   { "header",          NULL,                   cmd_spec_header },
   { "htmlextension",   &opt.html_extension,    cmd_boolean },
   { "htmlify",         NULL,                   cmd_spec_htmlify },
   { "header",          NULL,                   cmd_spec_header },
   { "htmlextension",   &opt.html_extension,    cmd_boolean },
   { "htmlify",         NULL,                   cmd_spec_htmlify },
+  { "httpkeepalive",   &opt.http_keep_alive,   cmd_boolean },
   { "httppasswd",      &opt.http_passwd,       cmd_string },
   { "httpproxy",       &opt.http_proxy,        cmd_string },
   { "httpuser",                &opt.http_user,         cmd_string },
   { "httppasswd",      &opt.http_passwd,       cmd_string },
   { "httpproxy",       &opt.http_proxy,        cmd_string },
   { "httpuser",                &opt.http_user,         cmd_string },
@@ -214,6 +215,7 @@ defaults (void)
   opt.netrc = 1;
   opt.ftp_glob = 1;
   opt.htmlify = 1;
   opt.netrc = 1;
   opt.ftp_glob = 1;
   opt.htmlify = 1;
+  opt.http_keep_alive = 1;
   opt.use_proxy = 1;
   tmp = getenv ("no_proxy");
   if (tmp)
   opt.use_proxy = 1;
   tmp = getenv ("no_proxy");
   if (tmp)
index ca4f7f233fc40eff7d6088fcb92a80cd5200db01..5cbd692b485123bc35dd06cf35b09849184cefbb 100644 (file)
@@ -247,6 +247,7 @@ main (int argc, char *const *argv)
     { "no-directories", no_argument, NULL, 19 },
     { "no-host-directories", no_argument, NULL, 20 },
     { "no-host-lookup", no_argument, NULL, 22 },
     { "no-directories", no_argument, NULL, 19 },
     { "no-host-directories", no_argument, NULL, 20 },
     { "no-host-lookup", no_argument, NULL, 22 },
+    { "no-http-keep-alive", no_argument, NULL, 28 },
     { "no-parent", no_argument, NULL, 5 },
     { "non-verbose", no_argument, NULL, 18 },
     { "passive-ftp", no_argument, NULL, 11 },
     { "no-parent", no_argument, NULL, 5 },
     { "non-verbose", no_argument, NULL, 18 },
     { "passive-ftp", no_argument, NULL, 11 },
@@ -385,6 +386,9 @@ hpVqvdkKsxmNWrHSLcFbEY:G:g:T:U:O:l:n:i:o:a:t:D:A:R:P:B:e:Q:X:I:w:",
        case 27:
          setval ("bindaddress", optarg);
          break;
        case 27:
          setval ("bindaddress", optarg);
          break;
+       case 28:
+         setval ("httpkeepalive", "off");
+         break;
        case 'b':
          setval ("background", "on");
          break;
        case 'b':
          setval ("background", "on");
          break;
@@ -579,6 +583,9 @@ GNU General Public License for more details.\n"));
                case 'p':
                  setval ("noparent", "on");
                  break;
                case 'p':
                  setval ("noparent", "on");
                  break;
+               case 'k':
+                 setval ("httpkeepalive", "off");
+                 break;
                default:
                  printf (_("%s: illegal option -- `-n%c'\n"), exec_name, *p);
                  print_usage ();
                default:
                  printf (_("%s: illegal option -- `-n%c'\n"), exec_name, *p);
                  print_usage ();
index 742c75470e453e633f7b960517ab85e79739b360..db849579626706fb544409f85a77b48e49e439ce 100644 (file)
@@ -86,6 +86,7 @@ struct options
   char *http_user;             /* HTTP user. */
   char *http_passwd;           /* HTTP password. */
   char *user_header;           /* User-defined header(s). */
   char *http_user;             /* HTTP user. */
   char *http_passwd;           /* HTTP password. */
   char *user_header;           /* User-defined header(s). */
+  int http_keep_alive;         /* whether we use keep-alive */
 
   int use_proxy;               /* Do we use proxy? */
   int proxy_cache;             /* Do we load from proxy cache? */
 
   int use_proxy;               /* Do we use proxy? */
   int proxy_cache;             /* Do we load from proxy cache? */