/* */ #ifndef _D_COOKIE_H_ #define _D_COOKIE_H_ #include "common.h" #include #include #include "a2time.h" namespace aria2 { class Cookie { private: std::string _name; std::string _value; time_t _expiry; std::string _path; std::string _domain; bool _secure; public: /* * If expires = 0 is given, then the cookie becomes session cookie. */ Cookie(const std::string& name, const std::string& value, time_t expires, const std::string& path, const std::string& domain, bool secure); /* * Creates session cookie. This is equivalent to * Cookie(name, value, 0, path, domain, secure); */ Cookie(const std::string& name, const std::string& value, const std::string& path, const std::string& domain, bool secure); Cookie(); ~Cookie(); std::string toString() const; bool good() const; bool match(const std::string& requestHost, const std::string& requestPath, time_t date, bool secure) const; bool validate(const std::string& requestHost, const std::string& requestPath) const; bool operator==(const Cookie& cookie) const; bool isExpired() const; const std::string& getName() const { return _name; } const std::string& getValue() const { return _value; } const std::string& getPath() const { return _path; } const std::string& getDomain() const { return _domain; } time_t getExpiry() const { return _expiry; } bool isSecureCookie() const { return _secure; } bool isSessionCookie() const { return _expiry == 0; } std::string toNsCookieFormat() const; }; typedef std::deque Cookies; } // namespace aria2 #endif // _D_COOKIE_H_