[svn] New option --no-http-keep-alive.

Published in <sxsd7fr1pdf.fsf@florida.arsdigita.de>.
This commit is contained in:
hniksic 2000-11-19 16:04:06 -08:00
parent b27144fcce
commit f2f77d87fd
5 changed files with 25 additions and 13 deletions

View 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"

View File

@ -444,9 +444,8 @@ gethttp (struct urlinfo *u, struct http_stat *hs, int *dt)
char *authenticate_h;
char *proxyauth;
char *all_headers;
char *host_port;
char *port_maybe;
char *request_keep_alive;
int host_port_len;
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;
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
@ -623,15 +622,12 @@ gethttp (struct urlinfo *u, struct http_stat *hs, int *dt)
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)
@ -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)
+ strlen (remhost) + host_port_len
+ strlen (remhost)
+ (port_maybe ? strlen (port_maybe) : 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,
host_port ? host_port : "",
port_maybe ? port_maybe : "",
HTTP_ACCEPT,
request_keep_alive ? request_keep_alive : "",
referer ? referer : "",

View File

@ -122,6 +122,7 @@ static struct {
{ "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 },
@ -214,6 +215,7 @@ defaults (void)
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)

View 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-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 },
@ -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 28:
setval ("httpkeepalive", "off");
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 'k':
setval ("httpkeepalive", "off");
break;
default:
printf (_("%s: illegal option -- `-n%c'\n"), exec_name, *p);
print_usage ();

View File

@ -86,6 +86,7 @@ struct options
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? */