Pbublished in <sxslmbsxptu.fsf@florida.arsdigita.de>.
** Download speed shown by the progress bar is based on the data
recently read, rather than the average speed of the entire download.
The ETA is still based on the average speed, though.
+
+** It is now possible to connect to FTP servers through FWTK
+firewalls. Set ftp_proxy to an FTP URL, and Wget will automatically
+log on to the proxy as "username@host".
\f
* Wget 1.8.1 is a bugfix release with no user-visible changes.
\f
* Be careful not to lose username/password information given for the
URL on the command line.
-* Support FWTK firewalls. It should work like this: if ftp_proxy is
- set to an ftp URL, Wget should assume the use of an FWTK firewall.
- It should connect to the proxy URL, log in as username@target-site,
- and continue as usual.
-
* Add a --range parameter allowing you to explicitly specify a range of bytes to
get from a file over HTTP (FTP only supports ranges ending at the end of the
file, though forcibly disconnecting from the server at the desired endpoint
+2002-04-13 Hrvoje Niksic <hniksic@arsdigita.com>
+
+ * url.c (getproxy): Accept a struct url argument. This obviates
+ the need for USE_PROXY_P.
+
+ * retr.c (retrieve_url): Allow proxy to be a non-FTP URL.
+
+ * ftp.c (getftp): Recognize FWTK-style proxy.
+
2002-04-12 Hrvoje Niksic <hniksic@arsdigita.com>
* config.h.in: Only define _VA_LIST when compiled with gcc.
enum stype rs; /* remote system reported by ftp server */
char *id; /* initial directory */
char *target; /* target file name */
+ struct url *proxy; /* FTWK-style proxy */
} ccon;
char type_char;
struct address_list *al;
+ char *host = con->proxy ? con->proxy->host : u->host;
+ int port = con->proxy ? con->proxy->port : u->port;
+ char *logname = user;
+
+ if (con->proxy)
+ {
+ /* If proxy is in use, log in as username@target-site. */
+ logname = xmalloc (strlen (user) + 1 + strlen (u->host) + 1);
+ sprintf (logname, "%s@%s", user, u->host);
+ }
+
/* Login to the server: */
/* First: Establish the control connection. */
- al = lookup_host (u->host, 0);
+ al = lookup_host (host, 0);
if (!al)
return HOSTERR;
- set_connection_host_name (u->host);
- csock = connect_to_many (al, u->port, 0);
+ set_connection_host_name (host);
+ csock = connect_to_many (al, port, 0);
set_connection_host_name (NULL);
address_list_release (al);
logprintf (LOG_VERBOSE, _("Logging in as %s ... "), user);
if (opt.server_response)
logputs (LOG_ALWAYS, "\n");
- err = ftp_login (&con->rbuf, user, passwd);
+ err = ftp_login (&con->rbuf, logname, passwd);
+
+ if (con->proxy)
+ xfree (logname);
+
/* FTPRERR, FTPSRVERR, WRITEFAILED, FTPLOGREFUSED, FTPLOGINC */
switch (err)
{
of URL. Inherently, its capabilities are limited on what can be
encoded into a URL. */
uerr_t
-ftp_loop (struct url *u, int *dt)
+ftp_loop (struct url *u, int *dt, struct url *proxy)
{
ccon con; /* FTP connection */
uerr_t res;
con.st = ON_YOUR_OWN;
con.rs = ST_UNIX;
con.id = NULL;
+ con.proxy = proxy;
res = RETROK; /* in case it's not used */
/* If the file name is empty, the user probably wants a directory
};
struct fileinfo *ftp_parse_ls PARAMS ((const char *, const enum stype));
-uerr_t ftp_loop PARAMS ((struct url *, int *));
+uerr_t ftp_loop PARAMS ((struct url *, int *, struct url *));
uerr_t ftp_index PARAMS ((const char *, struct url *, struct fileinfo *));
return dlrate;
}
\f
-#define USE_PROXY_P(u) (opt.use_proxy && getproxy((u)->scheme) \
- && no_proxy_match((u)->host, \
- (const char **)opt.no_proxy))
-
/* Maximum number of allowed redirections. 20 was chosen as a
"reasonable" value, which is low enough to not cause havoc, yet
high enough to guarantee that normal retrievals will not be hurt by
uerr_t result;
char *url;
int location_changed, dummy;
- int use_proxy;
char *mynewloc, *proxy;
- struct url *u;
+ struct url *u, *proxy_url;
int up_error_code; /* url parse error code */
char *local_file;
int redirection_count = 0;
result = NOCONERROR;
mynewloc = NULL;
local_file = NULL;
+ proxy_url = NULL;
- use_proxy = USE_PROXY_P (u);
- if (use_proxy)
+ proxy = getproxy (u);
+ if (proxy)
{
- struct url *proxy_url;
-
- /* Get the proxy server for the current scheme. */
- proxy = getproxy (u->scheme);
- if (!proxy)
- {
- logputs (LOG_NOTQUIET, _("Could not find proxy host.\n"));
- url_free (u);
- xfree (url);
- return PROXERR;
- }
-
/* Parse the proxy URL. */
proxy_url = url_parse (proxy, &up_error_code);
if (!proxy_url)
xfree (url);
return PROXERR;
}
- if (proxy_url->scheme != SCHEME_HTTP)
+ if (proxy_url->scheme != SCHEME_HTTP && proxy_url->scheme != u->scheme)
{
logprintf (LOG_NOTQUIET, _("Error in proxy URL %s: Must be HTTP.\n"), proxy);
url_free (proxy_url);
xfree (url);
return PROXERR;
}
-
- result = http_loop (u, &mynewloc, &local_file, refurl, dt, proxy_url);
- url_free (proxy_url);
}
- else if (u->scheme == SCHEME_HTTP
+
+ if (u->scheme == SCHEME_HTTP
#ifdef HAVE_SSL
|| u->scheme == SCHEME_HTTPS
#endif
- )
+ || (proxy_url && proxy_url->scheme == SCHEME_HTTP))
{
- result = http_loop (u, &mynewloc, &local_file, refurl, dt, NULL);
+ result = http_loop (u, &mynewloc, &local_file, refurl, dt, proxy_url);
}
else if (u->scheme == SCHEME_FTP)
{
int oldrec = opt.recursive;
if (redirection_count)
opt.recursive = 0;
- result = ftp_loop (u, dt);
+ result = ftp_loop (u, dt, proxy_url);
opt.recursive = oldrec;
/* There is a possibility of having HTTP being redirected to
*dt |= TEXTHTML;
}
}
+
+ if (proxy_url)
+ {
+ url_free (proxy_url);
+ proxy_url = NULL;
+ }
+
location_changed = (result == NEWLOCATION);
if (location_changed)
{
return result;
}
\f
-/* Returns proxy host address, in accordance with SCHEME. */
+/* Return the URL of the proxy appropriate for url U. */
char *
-getproxy (enum url_scheme scheme)
+getproxy (struct url *u)
{
char *proxy = NULL;
char *rewritten_url;
static char rewritten_storage[1024];
- switch (scheme)
+ if (!opt.use_proxy)
+ return NULL;
+ if (!no_proxy_match (u->host, (const char **)opt.no_proxy))
+ return NULL;
+
+ switch (u->scheme)
{
case SCHEME_HTTP:
proxy = opt.http_proxy ? opt.http_proxy : getenv ("http_proxy");
if (!proxy || !*proxy)
return NULL;
- /* Handle shorthands. */
+ /* Handle shorthands. `rewritten_storage' is a kludge to allow
+ getproxy() to return static storage. */
rewritten_url = rewrite_shorthand_url (proxy);
if (rewritten_url)
{
int mkalldirs PARAMS ((const char *));
char *url_filename PARAMS ((const struct url *));
-char *getproxy PARAMS ((enum url_scheme));
+char *getproxy PARAMS ((struct url *));
int no_proxy_match PARAMS ((const char *, const char **));
void convert_links PARAMS ((const char *, struct urlpos *));