Published in <sxsd7fr1pdf.fsf@florida.arsdigita.de>.
+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"
char *authenticate_h;
char *proxyauth;
char *all_headers;
char *authenticate_h;
char *proxyauth;
char *all_headers;
char *request_keep_alive;
char *request_keep_alive;
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;
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
remhost = ou->host;
remport = ou->port;
remhost = ou->host;
remport = ou->port;
+ /* 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)
/* 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)
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 : "",
{ "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 },
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)
{ "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 },
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;
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 ();
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? */