You should have received a copy of the GNU General Public License
along with Wget; if not, write to the Free Software
-Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+In addition, as a special exception, the Free Software Foundation
+gives permission to link the code of its release of Wget with the
+OpenSSL project's "OpenSSL" library (or with modified versions of it
+that use the same license as the "OpenSSL" library), and distribute
+the linked executables. You must obey the GNU General Public License
+in all respects for all of the code used other than "OpenSSL". If you
+modify this file, you may extend this exception to your version of the
+file, but you are not obligated to do so. If you do not wish to do
+so, delete this exception statement from your version. */
#include <config.h>
#endif
\f
static int cookies_loaded_p;
+struct cookie_jar *wget_cookie_jar;
#define TEXTHTML_S "text/html"
#define HTTP_ACCEPT "*/*"
*flag = 1;
return 1;
}
+
+/* Commit the cookie to the cookie jar. */
+
+int
+http_process_set_cookie (const char *hdr, void *arg)
+{
+ struct url *u = (struct url *)arg;
+
+ /* The jar should have been created by now. */
+ assert (wget_cookie_jar != NULL);
+
+ cookie_jar_process_set_cookie (wget_cookie_jar, u->host, u->port, u->path,
+ hdr);
+ return 1;
+}
+
\f
/* Persistent connections. Currently, we cache the most recently used
connection as persistent, provided that the HTTP server agrees to
char *remote_time; /* remote time-stamp string */
char *error; /* textual HTTP error */
int statcode; /* status code */
- long dltime; /* time of the download */
+ double dltime; /* time of the download in msecs */
int no_truncate; /* whether truncating the file is
forbidden. */
const char *referer; /* value of the referer header. */
const char *));
static int known_authentication_scheme_p PARAMS ((const char *));
-time_t http_atotm PARAMS ((char *));
+time_t http_atotm PARAMS ((const char *));
#define BEGINS_WITH(line, string_constant) \
(!strncasecmp (line, string_constant, sizeof (string_constant) - 1) \
address_list_release (al);
if (sock < 0)
- return errno == ECONNREFUSED ? CONREFUSED : CONERROR;
+ return CONNECT_ERROR (errno);
#ifdef HAVE_SSL
if (conn->scheme == SCHEME_HTTPS)
request_keep_alive = NULL;
if (opt.cookies)
- cookies = build_cookies_request (u->host, u->port, u->path,
+ cookies = cookie_jar_generate_cookie_header (wget_cookie_jar, u->host,
+ u->port, u->path,
#ifdef HAVE_SSL
- u->scheme == SCHEME_HTTPS
+ u->scheme == SCHEME_HTTPS
#else
- 0
+ 0
#endif
- );
+ );
if (opt.post_data || opt.post_file_name)
{
goto done_header;
/* Try getting cookies. */
if (opt.cookies)
- if (header_process (hdr, "Set-Cookie", set_cookie_header_cb, u))
+ if (header_process (hdr, "Set-Cookie", http_process_set_cookie, u))
goto done_header;
/* Try getting www-authentication. */
if (!authenticate_h)
#### A possible solution to this would be to remember the
file position in the output document and to seek to that
- position, instead of rewinding. */
- if (!hs->restval && global_download_count == 0)
+ position, instead of rewinding.
+
+ We don't truncate stdout, since that breaks
+ "wget -O - [...] >> foo".
+ */
+ if (!hs->restval && global_download_count == 0 && opt.dfp != stdout)
{
/* This will silently fail for streams that don't correspond
to regular files, but that's OK. */
/* This used to be done in main(), but it's a better idea to do it
here so that we don't go through the hoops if we're just using
FTP or whatever. */
- if (opt.cookies && opt.cookies_input && !cookies_loaded_p)
+ if (opt.cookies)
{
- load_cookies (opt.cookies_input);
- cookies_loaded_p = 1;
+ if (!wget_cookie_jar)
+ wget_cookie_jar = cookie_jar_new ();
+ if (opt.cookies_input && !cookies_loaded_p)
+ {
+ cookie_jar_load (wget_cookie_jar, opt.cookies_input);
+ cookies_loaded_p = 1;
+ }
}
*newloc = NULL;
hstat.local_file = local_file;
else if (local_file)
{
- *local_file = url_filename (u);
+ *local_file = url_file_name (u);
hstat.local_file = local_file;
}
else
{
- dummy = url_filename (u);
+ dummy = url_file_name (u);
hstat.local_file = &dummy;
}
it is not assigned to the FSF. So I stuck it with strptime. */
time_t
-http_atotm (char *time_string)
+http_atotm (const char *time_string)
{
/* NOTE: Solaris strptime man page claims that %n and %t match white
space, but that's not universally available. Instead, we simply