1
0
mirror of https://github.com/moparisthebest/wget synced 2024-07-03 16:38:41 -04:00

[svn] Fixed recursive HTTP retrieval

This commit is contained in:
mtortonesi 2006-03-02 01:27:45 -08:00
parent 65cc42ee09
commit 46c94e5f26
2 changed files with 38 additions and 33 deletions

View File

@ -1,3 +1,7 @@
2006-03-02 Mauro Tortonesi <mauro@ferrara.linux.it>
* http.c (http_loop): Fixed recursive HTTP retrieval.
2006-02-28 Hrvoje Niksic <hniksic@xemacs.org> 2006-02-28 Hrvoje Niksic <hniksic@xemacs.org>
* http.c (extract_param): Declare extern so it can be used from * http.c (extract_param): Declare extern so it can be used from

View File

@ -2198,7 +2198,7 @@ http_loop (struct url *u, char **newloc, char **local_file, const char *referer,
bool got_head = false; /* used for time-stamping */ bool got_head = false; /* used for time-stamping */
char *tms; char *tms;
const char *tmrate; const char *tmrate;
uerr_t err; uerr_t err, ret = TRYLIMEXC;
time_t tmr = -1; /* remote time-stamp */ time_t tmr = -1; /* remote time-stamp */
wgint local_size = 0; /* the size of the local file */ wgint local_size = 0; /* the size of the local file */
struct http_stat hstat; /* HTTP status */ struct http_stat hstat; /* HTTP status */
@ -2300,8 +2300,7 @@ http_loop (struct url *u, char **newloc, char **local_file, const char *referer,
we require a fresh get. we require a fresh get.
b) caching is explicitly inhibited. */ b) caching is explicitly inhibited. */
if ((proxy && count > 1) /* a */ if ((proxy && count > 1) /* a */
|| !opt.allow_cache /* b */ || !opt.allow_cache) /* b */
)
*dt |= SEND_NOCACHE; *dt |= SEND_NOCACHE;
else else
*dt &= ~SEND_NOCACHE; *dt &= ~SEND_NOCACHE;
@ -2324,26 +2323,23 @@ http_loop (struct url *u, char **newloc, char **local_file, const char *referer,
/* Non-fatal errors continue executing the loop, which will /* Non-fatal errors continue executing the loop, which will
bring them to "while" statement at the end, to judge bring them to "while" statement at the end, to judge
whether the number of tries was exceeded. */ whether the number of tries was exceeded. */
/* free_hstat (&hstat); */
printwhat (count, opt.ntry); printwhat (count, opt.ntry);
continue; continue;
case HOSTERR: case CONIMPOSSIBLE: case PROXERR: case AUTHFAILED:
case SSLINITFAILED: case CONTNOTSUPPORTED:
/* Fatal errors just return from the function. */
free_hstat (&hstat);
return err;
case FWRITEERR: case FOPENERR: case FWRITEERR: case FOPENERR:
/* Another fatal error. */ /* Another fatal error. */
logputs (LOG_VERBOSE, "\n"); logputs (LOG_VERBOSE, "\n");
logprintf (LOG_NOTQUIET, _("Cannot write to `%s' (%s).\n"), logprintf (LOG_NOTQUIET, _("Cannot write to `%s' (%s).\n"),
hstat.local_file, strerror (errno)); hstat.local_file, strerror (errno));
free_hstat (&hstat); case HOSTERR: case CONIMPOSSIBLE: case PROXERR: case AUTHFAILED:
return err; case SSLINITFAILED: case CONTNOTSUPPORTED:
/* Fatal errors just return from the function. */
ret = err;
goto exit;
case CONSSLERR: case CONSSLERR:
/* Another fatal error. */ /* Another fatal error. */
logprintf (LOG_NOTQUIET, _("Unable to establish SSL connection.\n")); logprintf (LOG_NOTQUIET, _("Unable to establish SSL connection.\n"));
free_hstat (&hstat); ret = err;
return err; goto exit;
case NEWLOCATION: case NEWLOCATION:
/* Return the new location to the caller. */ /* Return the new location to the caller. */
if (!*newloc) if (!*newloc)
@ -2351,15 +2347,17 @@ http_loop (struct url *u, char **newloc, char **local_file, const char *referer,
logprintf (LOG_NOTQUIET, logprintf (LOG_NOTQUIET,
_("ERROR: Redirection (%d) without location.\n"), _("ERROR: Redirection (%d) without location.\n"),
hstat.statcode); hstat.statcode);
free_hstat (&hstat); ret = WRONGCODE;
return WRONGCODE;
} }
free_hstat (&hstat); else
return NEWLOCATION; {
ret = NEWLOCATION;
}
goto exit;
case RETRUNNEEDED: case RETRUNNEEDED:
/* The file was already fully retrieved. */ /* The file was already fully retrieved. */
free_hstat (&hstat); ret = RETROK;
return RETROK; goto exit;
case RETRFINISHED: case RETRFINISHED:
/* Deal with you later. */ /* Deal with you later. */
break; break;
@ -2380,8 +2378,8 @@ http_loop (struct url *u, char **newloc, char **local_file, const char *referer,
logprintf (LOG_NOTQUIET, _("%s ERROR %d: %s.\n"), logprintf (LOG_NOTQUIET, _("%s ERROR %d: %s.\n"),
tms, hstat.statcode, escnonprint (hstat.error)); tms, hstat.statcode, escnonprint (hstat.error));
logputs (LOG_VERBOSE, "\n"); logputs (LOG_VERBOSE, "\n");
free_hstat (&hstat); ret = WRONGCODE;
return WRONGCODE; goto exit;
} }
/* Did we get the time-stamp? */ /* Did we get the time-stamp? */
@ -2423,8 +2421,8 @@ Last-modified header invalid -- time-stamp ignored.\n"));
logprintf (LOG_VERBOSE, _("\ logprintf (LOG_VERBOSE, _("\
Server file no newer than local file `%s' -- not retrieving.\n\n"), Server file no newer than local file `%s' -- not retrieving.\n\n"),
hstat.orig_file_name); hstat.orig_file_name);
free_hstat (&hstat); ret = RETROK;
return RETROK; goto exit;
} }
else else
{ {
@ -2469,7 +2467,8 @@ The sizes do not match (local %s) -- retrieving.\n"),
{ {
logprintf (LOG_NOTQUIET, "%d %s\n\n", hstat.statcode, logprintf (LOG_NOTQUIET, "%d %s\n\n", hstat.statcode,
escnonprint (hstat.error)); escnonprint (hstat.error));
return RETROK; ret = RETROK;
goto exit;
} }
tmrate = retr_rate (hstat.rd_size, hstat.dltime); tmrate = retr_rate (hstat.rd_size, hstat.dltime);
@ -2500,8 +2499,8 @@ The sizes do not match (local %s) -- retrieving.\n"),
else else
downloaded_file(FILE_DOWNLOADED_NORMALLY, hstat.local_file); downloaded_file(FILE_DOWNLOADED_NORMALLY, hstat.local_file);
free_hstat (&hstat); ret = RETROK;
return RETROK; goto exit;
} }
else if (hstat.res == 0) /* No read error */ else if (hstat.res == 0) /* No read error */
{ {
@ -2528,8 +2527,8 @@ The sizes do not match (local %s) -- retrieving.\n"),
else else
downloaded_file(FILE_DOWNLOADED_NORMALLY, hstat.local_file); downloaded_file(FILE_DOWNLOADED_NORMALLY, hstat.local_file);
free_hstat (&hstat); ret = RETROK;
return RETROK; goto exit;
} }
else if (hstat.len < hstat.contlen) /* meaning we lost the else if (hstat.len < hstat.contlen) /* meaning we lost the
connection too soon */ connection too soon */
@ -2538,7 +2537,6 @@ The sizes do not match (local %s) -- retrieving.\n"),
_("%s (%s) - Connection closed at byte %s. "), _("%s (%s) - Connection closed at byte %s. "),
tms, tmrate, number_to_static_string (hstat.len)); tms, tmrate, number_to_static_string (hstat.len));
printwhat (count, opt.ntry); printwhat (count, opt.ntry);
/* free_hstat (&hstat); */
continue; continue;
} }
else else
@ -2555,7 +2553,6 @@ The sizes do not match (local %s) -- retrieving.\n"),
tms, tmrate, number_to_static_string (hstat.len), tms, tmrate, number_to_static_string (hstat.len),
hstat.rderrmsg); hstat.rderrmsg);
printwhat (count, opt.ntry); printwhat (count, opt.ntry);
/* free_hstat (&hstat); */
continue; continue;
} }
else /* hstat.res == -1 and contlen is given */ else /* hstat.res == -1 and contlen is given */
@ -2567,7 +2564,6 @@ The sizes do not match (local %s) -- retrieving.\n"),
number_to_static_string (hstat.contlen), number_to_static_string (hstat.contlen),
hstat.rderrmsg); hstat.rderrmsg);
printwhat (count, opt.ntry); printwhat (count, opt.ntry);
/* free_hstat (&hstat); */
continue; continue;
} }
} }
@ -2575,7 +2571,12 @@ The sizes do not match (local %s) -- retrieving.\n"),
} }
while (!opt.ntry || (count < opt.ntry)); while (!opt.ntry || (count < opt.ntry));
return TRYLIMEXC; exit:
if (ret == RETROK)
*local_file = xstrdup (hstat.local_file);
free_hstat (&hstat);
return ret;
} }
/* Check whether the result of strptime() indicates success. /* Check whether the result of strptime() indicates success.