mirror of
https://github.com/moparisthebest/wget
synced 2024-07-03 16:38:41 -04:00
Make -i work with FTP.
This commit is contained in:
parent
f6a33f1dd0
commit
ec6950f1a6
@ -1,3 +1,15 @@
|
||||
2010-03-01 Steven Schubiger <stsc@member.fsf.org>
|
||||
|
||||
* retr.c (retrieve_url): Retrieve the local filename from ftp_loop.
|
||||
(retrieve_from_file): Return if there's no input file.
|
||||
|
||||
* ftp.c (ftp_loop_internal): Duplicate the local filename into
|
||||
retrieve_url's scope when a valid reference is being passed.
|
||||
(ftp_loop): Call ftp_loop_internal here with passing a
|
||||
reference to the local filename, elsewhere with NULL.
|
||||
|
||||
* ftp.h: Adjust declaration of ftp_loop.
|
||||
|
||||
2010-01-27 Paul Townsend <aab@purdue.edu> (tiny change)
|
||||
|
||||
* retr.c (fd_read_body): Be sure to measure timer when time has
|
||||
|
19
src/ftp.c
19
src/ftp.c
@ -1348,7 +1348,7 @@ Error in server response, closing control connection.\n"));
|
||||
This loop either gets commands from con, or (if ON_YOUR_OWN is
|
||||
set), makes them up to retrieve the file given by the URL. */
|
||||
static uerr_t
|
||||
ftp_loop_internal (struct url *u, struct fileinfo *f, ccon *con)
|
||||
ftp_loop_internal (struct url *u, struct fileinfo *f, ccon *con, char **local_file)
|
||||
{
|
||||
int count, orig_lp;
|
||||
wgint restval, len = 0, qtyread = 0;
|
||||
@ -1576,6 +1576,10 @@ Removing file due to --delete-after in ftp_loop_internal():\n"));
|
||||
con->cmd |= LEAVE_PENDING;
|
||||
else
|
||||
con->cmd &= ~LEAVE_PENDING;
|
||||
|
||||
if (local_file)
|
||||
*local_file = xstrdup (locf);
|
||||
|
||||
return RETROK;
|
||||
} while (!opt.ntry || (count < opt.ntry));
|
||||
|
||||
@ -1611,7 +1615,7 @@ ftp_get_listing (struct url *u, ccon *con, struct fileinfo **f)
|
||||
|
||||
con->target = xstrdup (lf);
|
||||
xfree (lf);
|
||||
err = ftp_loop_internal (u, NULL, con);
|
||||
err = ftp_loop_internal (u, NULL, con, NULL);
|
||||
lf = xstrdup (con->target);
|
||||
xfree (con->target);
|
||||
con->target = old_target;
|
||||
@ -1806,7 +1810,7 @@ Already have correct symlink %s -> %s\n\n"),
|
||||
else /* opt.retr_symlinks */
|
||||
{
|
||||
if (dlthis)
|
||||
err = ftp_loop_internal (u, f, con);
|
||||
err = ftp_loop_internal (u, f, con, NULL);
|
||||
} /* opt.retr_symlinks */
|
||||
break;
|
||||
case FT_DIRECTORY:
|
||||
@ -1817,7 +1821,7 @@ Already have correct symlink %s -> %s\n\n"),
|
||||
case FT_PLAINFILE:
|
||||
/* Call the retrieve loop. */
|
||||
if (dlthis)
|
||||
err = ftp_loop_internal (u, f, con);
|
||||
err = ftp_loop_internal (u, f, con, NULL);
|
||||
break;
|
||||
case FT_UNKNOWN:
|
||||
logprintf (LOG_NOTQUIET, _("%s: unknown/unsupported file type.\n"),
|
||||
@ -2096,7 +2100,7 @@ ftp_retrieve_glob (struct url *u, ccon *con, int action)
|
||||
{
|
||||
/* Let's try retrieving it anyway. */
|
||||
con->st |= ON_YOUR_OWN;
|
||||
res = ftp_loop_internal (u, NULL, con);
|
||||
res = ftp_loop_internal (u, NULL, con, NULL);
|
||||
return res;
|
||||
}
|
||||
|
||||
@ -2117,7 +2121,8 @@ ftp_retrieve_glob (struct url *u, ccon *con, int action)
|
||||
of URL. Inherently, its capabilities are limited on what can be
|
||||
encoded into a URL. */
|
||||
uerr_t
|
||||
ftp_loop (struct url *u, int *dt, struct url *proxy, bool recursive, bool glob)
|
||||
ftp_loop (struct url *u, char **local_file, int *dt, struct url *proxy,
|
||||
bool recursive, bool glob)
|
||||
{
|
||||
ccon con; /* FTP connection */
|
||||
uerr_t res;
|
||||
@ -2196,7 +2201,7 @@ ftp_loop (struct url *u, int *dt, struct url *proxy, bool recursive, bool glob)
|
||||
ispattern ? GLOB_GLOBALL : GLOB_GETONE);
|
||||
}
|
||||
else
|
||||
res = ftp_loop_internal (u, NULL, &con);
|
||||
res = ftp_loop_internal (u, NULL, &con, local_file);
|
||||
}
|
||||
if (res == FTPOK)
|
||||
res = RETROK;
|
||||
|
@ -120,7 +120,7 @@ enum wget_ftp_fstatus
|
||||
};
|
||||
|
||||
struct fileinfo *ftp_parse_ls (const char *, const enum stype);
|
||||
uerr_t ftp_loop (struct url *, int *, struct url *, bool, bool);
|
||||
uerr_t ftp_loop (struct url *, char **, int *, struct url *, bool, bool);
|
||||
|
||||
uerr_t ftp_index (const char *, struct url *, struct fileinfo *);
|
||||
|
||||
|
@ -700,7 +700,7 @@ retrieve_url (struct url * orig_parsed, const char *origurl, char **file,
|
||||
if (redirection_count)
|
||||
oldrec = glob = false;
|
||||
|
||||
result = ftp_loop (u, dt, proxy_url, recursive, glob);
|
||||
result = ftp_loop (u, &local_file, dt, proxy_url, recursive, glob);
|
||||
recursive = oldrec;
|
||||
|
||||
/* There is a possibility of having HTTP being redirected to
|
||||
@ -918,7 +918,9 @@ retrieve_from_file (const char *file, bool html, int *count)
|
||||
|
||||
status = retrieve_url (url_parsed, url, &input_file, NULL, NULL, &dt,
|
||||
false, iri, true);
|
||||
if (status != RETROK)
|
||||
url_free (url_parsed);
|
||||
|
||||
if (!input_file || (status != RETROK))
|
||||
return status;
|
||||
|
||||
if (dt & TEXTHTML)
|
||||
|
@ -1,3 +1,8 @@
|
||||
2010-03-01 Steven Schubiger <stsc@member.fsf.org>
|
||||
|
||||
* Test-i-ftp.px: Test --input-file in conjunction with FTP.
|
||||
* run-px, Makefile.am (EXTRA_DIST): Added Test-i-ftp.px.
|
||||
|
||||
2010-02-26 Steven Schubiger <stsc@member.fsf.org>
|
||||
|
||||
* Test-i-http.px: Test --input-file in conjunction with HTTP.
|
||||
|
@ -84,6 +84,7 @@ EXTRA_DIST = FTPServer.pm FTPTest.pm HTTPServer.pm HTTPTest.pm \
|
||||
Test-HTTP-Content-Disposition-1.px \
|
||||
Test-HTTP-Content-Disposition-2.px \
|
||||
Test-HTTP-Content-Disposition.px \
|
||||
Test-i-ftp.px \
|
||||
Test-i-http.px \
|
||||
Test-idn-headers.px \
|
||||
Test-idn-meta.px \
|
||||
|
80
tests/Test-i-ftp.px
Executable file
80
tests/Test-i-ftp.px
Executable file
@ -0,0 +1,80 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use FTPTest;
|
||||
|
||||
|
||||
###############################################################################
|
||||
|
||||
my $urls = <<EOF;
|
||||
ftp://localhost:{{port}}/site1.html
|
||||
ftp://localhost:{{port}}/site2.html
|
||||
EOF
|
||||
|
||||
my $site1 = <<EOF;
|
||||
<html>
|
||||
<head>
|
||||
<title>Site 1</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Nunc eu ligula sed mauris sollicitudin scelerisque. Suspendisse viverra, dolor.</p>
|
||||
</body>
|
||||
</html>
|
||||
EOF
|
||||
|
||||
my $site2 = <<EOF;
|
||||
<html>
|
||||
<head>
|
||||
<title>Site 2</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Suspendisse potenti. Phasellus et magna est, quis consectetur ligula. Integer.</p>
|
||||
</body>
|
||||
</html>
|
||||
EOF
|
||||
|
||||
foreach ($urls, $site1, $site2) {
|
||||
s/\n/\r\n/g;
|
||||
}
|
||||
|
||||
my %urls = (
|
||||
'/urls.txt' => {
|
||||
content => $urls,
|
||||
},
|
||||
'/site1.html' => {
|
||||
content => $site1,
|
||||
},
|
||||
'/site2.html' => {
|
||||
content => $site2,
|
||||
},
|
||||
);
|
||||
|
||||
my $cmdline = $WgetTest::WGETPATH . " -i ftp://localhost:{{port}}/urls.txt";
|
||||
|
||||
my $expected_error_code = 0;
|
||||
|
||||
my %expected_downloaded_files = (
|
||||
'urls.txt' => {
|
||||
content => $urls,
|
||||
},
|
||||
'site1.html' => {
|
||||
content => $site1,
|
||||
},
|
||||
'site2.html' => {
|
||||
content => $site2,
|
||||
},
|
||||
);
|
||||
|
||||
###############################################################################
|
||||
|
||||
my $the_test = FTPTest->new (name => "Test-i-ftp",
|
||||
input => \%urls,
|
||||
cmdline => $cmdline,
|
||||
errcode => $expected_error_code,
|
||||
output => \%expected_downloaded_files);
|
||||
exit $the_test->run();
|
||||
|
||||
# vim: et ts=4 sw=4
|
||||
|
@ -37,6 +37,7 @@ my @tests = (
|
||||
'Test-HTTP-Content-Disposition-1.px',
|
||||
'Test-HTTP-Content-Disposition-2.px',
|
||||
'Test-HTTP-Content-Disposition.px',
|
||||
'Test-i-ftp.px',
|
||||
'Test-i-http.px',
|
||||
'Test-idn-headers.px',
|
||||
'Test-idn-meta.px',
|
||||
|
Loading…
x
Reference in New Issue
Block a user