mirror of
https://github.com/moparisthebest/wget
synced 2024-07-03 16:38:41 -04:00
Move duplicated code in http.c to a function
This commit is contained in:
parent
2f6aa1d741
commit
e076a6d39d
@ -1,3 +1,9 @@
|
||||
2011-02-22 Steven Schubiger <stsc@member.fsf.org>
|
||||
|
||||
* http.c (gethttp, http_loop): Move duplicated code which is run
|
||||
when an existing file is not to be clobbered to a function.
|
||||
(get_file_flags): New static function.
|
||||
|
||||
2010-12-10 Evgeniy Philippov <egphilippov@googlemail.com> (tiny change)
|
||||
|
||||
* main.c (main): Initialize `total_downloaded_bytes'.
|
||||
|
39
src/http.c
39
src/http.c
@ -1448,6 +1448,20 @@ free_hstat (struct http_stat *hs)
|
||||
hs->error = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
get_file_flags (const char *filename, int *dt)
|
||||
{
|
||||
logprintf (LOG_VERBOSE, _("\
|
||||
File %s already there; not retrieving.\n\n"), quote (filename));
|
||||
/* If the file is there, we suppose it's retrieved OK. */
|
||||
*dt |= RETROKF;
|
||||
|
||||
/* #### Bogusness alert. */
|
||||
/* If its suffix is "html" or "htm" or similar, assume text/html. */
|
||||
if (has_html_suffix_p (filename))
|
||||
*dt |= TEXTHTML;
|
||||
}
|
||||
|
||||
#define BEGINS_WITH(line, string_constant) \
|
||||
(!strncasecmp (line, string_constant, sizeof (string_constant) - 1) \
|
||||
&& (c_isspace (line[sizeof (string_constant) - 1]) \
|
||||
@ -2158,16 +2172,7 @@ read_header:
|
||||
/* If opt.noclobber is turned on and file already exists, do not
|
||||
retrieve the file. But if the output_document was given, then this
|
||||
test was already done and the file didn't exist. Hence the !opt.output_document */
|
||||
logprintf (LOG_VERBOSE, _("\
|
||||
File %s already there; not retrieving.\n\n"), quote (hs->local_file));
|
||||
/* If the file is there, we suppose it's retrieved OK. */
|
||||
*dt |= RETROKF;
|
||||
|
||||
/* #### Bogusness alert. */
|
||||
/* If its suffix is "html" or "htm" or similar, assume text/html. */
|
||||
if (has_html_suffix_p (hs->local_file))
|
||||
*dt |= TEXTHTML;
|
||||
|
||||
get_file_flags (hs->local_file, dt);
|
||||
xfree (head);
|
||||
xfree_null (message);
|
||||
return RETRUNNEEDED;
|
||||
@ -2639,24 +2644,12 @@ http_loop (struct url *u, struct url *original_url, char **newloc,
|
||||
got_name = true;
|
||||
}
|
||||
|
||||
/* TODO: Ick! This code is now in both gethttp and http_loop, and is
|
||||
* screaming for some refactoring. */
|
||||
if (got_name && file_exists_p (hstat.local_file) && opt.noclobber && !opt.output_document)
|
||||
{
|
||||
/* If opt.noclobber is turned on and file already exists, do not
|
||||
retrieve the file. But if the output_document was given, then this
|
||||
test was already done and the file didn't exist. Hence the !opt.output_document */
|
||||
logprintf (LOG_VERBOSE, _("\
|
||||
File %s already there; not retrieving.\n\n"),
|
||||
quote (hstat.local_file));
|
||||
/* If the file is there, we suppose it's retrieved OK. */
|
||||
*dt |= RETROKF;
|
||||
|
||||
/* #### Bogusness alert. */
|
||||
/* If its suffix is "html" or "htm" or similar, assume text/html. */
|
||||
if (has_html_suffix_p (hstat.local_file))
|
||||
*dt |= TEXTHTML;
|
||||
|
||||
get_file_flags (hstat.local_file, dt);
|
||||
ret = RETROK;
|
||||
goto exit;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user