summaryrefslogtreecommitdiff
path: root/src/cookie_helper.h
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2010-10-09 14:22:49 +0000
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2010-10-09 14:22:49 +0000
commit8b17d4b276222b203722eea9ded9cd3797a4b656 (patch)
treefd20f43edf2e3891707cbff18bd1f7160cf627d2 /src/cookie_helper.h
parent9b1280f7a3c0d0223ad8bbc20e108b776d9c53af (diff)
2010-10-09 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Rewritten Cookie class and Cookie parser based on http://tools.ietf.org/html/draft-ietf-httpstate-cookie-14 with some modifications. When parsing cookie date, match time first so that it parses asctime() format. The request-path must be ends with '/' so that request-path '/foo/' path-matches cookie-path '/foo' and '/foo/' in the proposed algorithm. * src/Cookie.cc * src/Cookie.h * src/CookieParser.cc: Removed * src/CookieParser.h: Removed * src/CookieStorage.cc * src/CookieStorage.h * src/HttpResponse.cc * src/Makefile.am * src/Makefile.in * src/MultiUrlRequestInfo.cc * src/NsCookieParser.cc * src/NsCookieParser.h * src/Sqlite3CookieParser.cc * src/Sqlite3CookieParser.h * src/a2functional.h * src/cookie_helper.cc * src/cookie_helper.h * src/util.cc * src/util.h * test/CookieBoxFactoryTest.cc: Removed * test/CookieHelperTest.cc * test/CookieParserTest.cc: Removed * test/CookieStorageTest.cc * test/CookieTest.cc * test/HttpRequestTest.cc * test/Makefile.am * test/Makefile.in * test/NsCookieParserTest.cc * test/Sqlite3CookieParserTest.cc * test/TestUtil.cc * test/TestUtil.h * test/a2functionalTest.cc * test/chromium_cookies.sqlite * test/cookies.sqlite * test/nscookietest.txt
Diffstat (limited to 'src/cookie_helper.h')
-rw-r--r--src/cookie_helper.h75
1 files changed, 75 insertions, 0 deletions
diff --git a/src/cookie_helper.h b/src/cookie_helper.h
new file mode 100644
index 00000000..6dc249eb
--- /dev/null
+++ b/src/cookie_helper.h
@@ -0,0 +1,75 @@
+/* <!-- copyright */
+/*
+ * aria2 - The high speed download utility
+ *
+ * Copyright (C) 2010 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_HELPER_H
+#define D_COOKIE_HELPER_H
+
+#include "common.h"
+
+#include <string>
+
+#include "a2time.h"
+
+namespace aria2 {
+
+class Cookie;
+
+namespace cookie {
+
+bool parseDate(time_t& time, const std::string& cookieDate);
+
+bool parse
+(Cookie& cookie,
+ const std::string& cookieStr,
+ const std::string& requestHost,
+ const std::string& defaultPath,
+ time_t creationTime);
+
+std::string removePrecedingDots(const std::string& host);
+
+bool goodPath(const std::string& cookiePath);
+
+std::string canonicalizeHost(const std::string& host);
+
+bool domainMatch(const std::string& requestHost, const std::string& domain);
+
+bool pathMatch(const std::string& requestPath, const std::string& path);
+
+std::string reverseDomainLevel(const std::string& domain);
+
+} // namespace cookie
+
+} // namespace aria2
+
+#endif // D_COOKIE_HELPER_H