/* */ #include "Cookie.h" #include "Util.h" #include "A2STR.h" namespace aria2 { Cookie::Cookie(const std::string& name, const std::string& value, time_t expires, const std::string& path, const std::string& domain, bool secure): name(name), value(value), expires(expires), path(path), domain(domain), secure(secure), onetime(false) {} Cookie::Cookie(const std::string& name, const std::string& value, const std::string& path, const std::string& domain, bool secure): name(name), value(value), path(path), domain(domain), secure(secure), onetime(true) {} Cookie::Cookie():expires(0), secure(false), onetime(true) {} Cookie::~Cookie() {} std::string Cookie::toString() const { return name+"="+value; } void Cookie::clear() { name = value = path = domain = A2STR::NIL; expires = 0; secure = false; } bool Cookie::good() const { return !name.empty(); } bool Cookie::match(const std::string& host, const std::string& dir, time_t date, bool secure) const { if((secure || (!this->secure && !secure)) && Util::endsWith("."+host, this->domain) && Util::startsWith(dir, this->path) && (this->onetime || (date < this->expires))) { return true; } else { return false; } } } // namespace aria2