#include "connect.h"
#include "hash.h"
+#ifndef errno
+extern int errno;
+#endif
+
#ifdef WINDOWS
LARGE_INTEGER internal_time;
#else
int amount_to_read = (use_expected
? MIN (expected - *len, sizeof (c))
: sizeof (c));
- res = iread (fd, c, amount_to_read);
+#ifdef HAVE_SSL
+ if (rbuf->ssl!=NULL) {
+ res = ssl_iread (rbuf->ssl, c, amount_to_read);
+ } else {
+#endif /* HAVE_SSL */
+ res = iread (fd, c, amount_to_read);
+#ifdef HAVE_SSL
+ }
+#endif /* HAVE_SSL */
if (res > 0)
{
if (fwrite (c, sizeof (char), res, fp) < res)
&& no_proxy_match((u)->host, \
(const char **)opt.no_proxy))
-/* Retrieve the given URL. Decides which loop to call -- HTTP, FTP,
+/* Retrieve the given URL. Decides which loop to call -- HTTP(S), FTP,
or simply copy it with file:// (#### the latter not yet
implemented!). */
uerr_t
freeurl (u, 1);
if (redirections)
string_set_free (redirections);
- free (url);
+ xfree (url);
return result;
}
freeurl (u, 1);
if (redirections)
string_set_free (redirections);
- free (url);
+ xfree (url);
return PROXERR;
}
/* Parse the proxy URL. */
freeurl (u, 1);
if (redirections)
string_set_free (redirections);
- free (url);
+ xfree (url);
return PROXERR;
}
u->proto = URLHTTP;
assert (u->proto != URLFILE); /* #### Implement me! */
mynewloc = NULL;
+#ifdef HAVE_SSL
+ if (u->proto == URLHTTP || u->proto == URLHTTPS )
+#else
if (u->proto == URLHTTP)
+#endif /* HAVE_SSL */
result = http_loop (u, &mynewloc, dt);
else if (u->proto == URLFTP)
{
there break the rules and use relative URLs, and popular
browsers are lenient about this, so wget should be too. */
construced_newloc = url_concat (url, mynewloc);
- free (mynewloc);
+ xfree (mynewloc);
mynewloc = construced_newloc;
/* Now, see if this new location makes sense. */
freeurl (u, 1);
if (redirections)
string_set_free (redirections);
- free (url);
- free (mynewloc);
+ xfree (url);
+ xfree (mynewloc);
return result;
}
/* Now mynewloc will become newloc_struct->url, because if the
Location contained relative paths like .././something, we
don't want that propagating as url. */
- free (mynewloc);
+ xfree (mynewloc);
mynewloc = xstrdup (newloc_struct->url);
if (!redirections)
freeurl (u, 1);
if (redirections)
string_set_free (redirections);
- free (url);
- free (mynewloc);
+ xfree (url);
+ xfree (mynewloc);
return WRONGCODE;
}
string_set_add (redirections, newloc_struct->url);
- free (url);
+ xfree (url);
url = mynewloc;
freeurl (u, 1);
u = newloc_struct;
if (newloc)
*newloc = url;
else
- free (url);
+ xfree (url);
return result;
}
return opt.downloaded > opt.quota;
}
+
+/* If opt.wait or opt.waitretry are specified, and if certain
+ conditions are met, sleep the appropriate number of seconds. See
+ the documentation of --wait and --waitretry for more information.
+
+ COUNT is the count of current retrieval, beginning with 1. */
+
+void
+sleep_between_retrievals (int count)
+{
+ static int first_retrieval = 1;
+
+ if (!first_retrieval && (opt.wait || opt.waitretry))
+ {
+ if (opt.waitretry && count > 1)
+ {
+ /* If opt.waitretry is specified and this is a retry, wait
+ for COUNT-1 number of seconds, or for opt.waitretry
+ seconds. */
+ if (count <= opt.waitretry)
+ sleep (count - 1);
+ else
+ sleep (opt.waitretry);
+ }
+ else if (opt.wait)
+ /* Otherwise, check if opt.wait is specified. If so, sleep. */
+ sleep (opt.wait);
+ }
+ if (first_retrieval)
+ first_retrieval = 0;
+}