summaryrefslogtreecommitdiff
path: root/src/Cookie.h
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2007-06-10 07:55:43 +0000
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2007-06-10 07:55:43 +0000
commitd5bb035642ed1402eea53ecc5a4a1fd4d104c08f (patch)
treeaac92bd775fe648d7ae9597cabcc7eeb2ee1a1ed /src/Cookie.h
parentaa7cbf60ba1a76877366c977b24fdaf6657a883a (diff)
2007-06-10 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
* src/AbstractCommand.cc (execute): Changed log level of MSG_RESTARTING_DOWNLOAD and MSG_MAX_TRY from error to info. Added MSG_DOWNLOAD_ABORTED after MSG_MAX_TRY. * src/message.h (MSG_TORRENT_DOWNLOAD_ABORTED): New definition. (MSG_DOWNLOAD_ABORTED): Added %s. (MSG_RESTARTING_DOWNLOAD): Added %s. (MSG_DOWNLOAD_ALREADY_COMPLETED): Updated. * src/PeerAbstractCommand.cc (execute): MSG_DOWNLOAD_ABORTED -> MSG_TORRENT_DOWNLOAD_ABORTED * src/Request.h (cookieBox): Made ShardHandle. * src/RequestGroup.h, src/RequestGroup.cc (createNextCommandWithAdj): New function. * src/FileAllocationCommand.cc (executeInternal): Use createNextCommandWithAdj(). * src/CheckIntegrityCommand.cc (executeInternal): Use createNextCommandWithAdj(). Added --load-cookies command-option. * src/OptionHandlerFactory.cc (createOptionHandlers): Added PREF_LOAD_COOKIES. * src/CookieBox.h, src/CookieBox.cc: Rwritten using CookieParser. Now aria2 can handle cookie's expiration date. * src/Cookie.h (expires): Changed its type to time_t. * src/main.cc: Added --load-cookies command-line option. * src/prefs.h (PREF_LOAD_COOKIES): New definition. * src/Util.h, src/Util.cc (httpGMT): New function. * src/Request.cc (Request): Initialize cookieBox using CookieBoxFactory. * src/CookieBoxFactory.h, src/CookieBoxFactory.cc: New class. * src/CookieParser.h, src/CookieParser.cc: New class. * src/main.cc: Chagned the default value of --metalink-servers to 5. * src/HttpResponseCommand.cc (handleOtherEncoding): Call RequestGroup::shouldCancelDownloadForSafety
Diffstat (limited to 'src/Cookie.h')
-rw-r--r--src/Cookie.h98
1 files changed, 98 insertions, 0 deletions
diff --git a/src/Cookie.h b/src/Cookie.h
new file mode 100644
index 00000000..f33d048b
--- /dev/null
+++ b/src/Cookie.h
@@ -0,0 +1,98 @@
+/* <!-- copyright */
+/*
+ * aria2 - The high speed download utility
+ *
+ * Copyright (C) 2006 Tatsuhiro Tsujikawa
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * In addition, as a special exception, the copyright holders give
+ * permission to link the code of portions of this program with the
+ * OpenSSL library under certain conditions as described in each
+ * individual source file, and distribute linked combinations
+ * including the two.
+ * You must obey the GNU General Public License in all respects
+ * for all of the code used other than OpenSSL. If you modify
+ * file(s) with this exception, you may extend this exception to your
+ * version of the file(s), but you are not obligated to do so. If you
+ * do not wish to do so, delete this exception statement from your
+ * version. If you delete this exception statement from all source
+ * files in the program, then also delete it here.
+ */
+/* copyright --> */
+#ifndef _D_COOKIE_H_
+#define _D_COOKIE_H_
+
+#include "common.h"
+
+class Cookie {
+public:
+ string name;
+ string value;
+ time_t expires;
+ string path;
+ string domain;
+ bool secure;
+ bool onetime; // if true, this cookie will expire when the user's session ends.
+public:
+ Cookie(const string& name,
+ const string& value,
+ time_t expires,
+ const string& path,
+ const string& domain,
+ bool secure):
+ name(name),
+ value(value),
+ expires(expires),
+ path(path),
+ domain(domain),
+ secure(secure),
+ onetime(false) {}
+
+ Cookie(const string& name,
+ const string& value,
+ const string& path,
+ const string& domain,
+ bool secure):
+ name(name),
+ value(value),
+ path(path),
+ domain(domain),
+ secure(secure),
+ onetime(true) {}
+
+ Cookie():expires(0), secure(false), onetime(true) {}
+
+ ~Cookie() {}
+ string toString() const {
+ return name+"="+value;
+ }
+ void clear() {
+ name = value = path = domain = "";
+ expires = 0;
+ secure = false;
+ }
+
+ bool good() const
+ {
+ return !name.empty();
+ }
+
+ bool match(const string& host, const string& dir, time_t date, bool secure) const;
+};
+
+typedef deque<Cookie> Cookies;
+
+#endif // _D_COOKIE_H_