Panda3D
|
00001 // Filename: httpCookie.h 00002 // Created by: drose (26Aug04) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #ifndef HTTPCOOKIE_H 00016 #define HTTPCOOKIE_H 00017 00018 #include "pandabase.h" 00019 00020 // This module requires OpenSSL to compile, even if you do not intend 00021 // to use this to establish https connections; this is because it uses 00022 // the OpenSSL library to portably handle all of the socket 00023 // communications. 00024 00025 #ifdef HAVE_OPENSSL 00026 00027 #include "httpDate.h" 00028 #include "urlSpec.h" 00029 00030 //////////////////////////////////////////////////////////////////// 00031 // Class : HTTPCookie 00032 // Description : A cookie sent from an HTTP server to be stored on the 00033 // client and returned when the path and/or domain 00034 // matches. 00035 //////////////////////////////////////////////////////////////////// 00036 class EXPCL_PANDAEXPRESS HTTPCookie { 00037 PUBLISHED: 00038 INLINE HTTPCookie(); 00039 INLINE HTTPCookie(const string &format, const URLSpec &url); 00040 INLINE HTTPCookie(const string &name, const string &path, const string &domain); 00041 INLINE ~HTTPCookie(); 00042 00043 INLINE void set_name(const string &name); 00044 INLINE const string &get_name() const; 00045 00046 INLINE void set_value(const string &value); 00047 INLINE const string &get_value() const; 00048 00049 INLINE void set_domain(const string &domain); 00050 INLINE const string &get_domain() const; 00051 00052 INLINE void set_path(const string &path); 00053 INLINE const string &get_path() const; 00054 00055 INLINE void set_expires(const HTTPDate &expires); 00056 INLINE void clear_expires(); 00057 INLINE bool has_expires() const; 00058 INLINE HTTPDate get_expires() const; 00059 00060 INLINE void set_secure(bool flag); 00061 INLINE bool get_secure() const; 00062 00063 bool operator < (const HTTPCookie &other) const; 00064 void update_from(const HTTPCookie &other); 00065 00066 bool parse_set_cookie(const string &format, const URLSpec &url); 00067 INLINE bool is_expired(const HTTPDate &now = HTTPDate::now()) const; 00068 bool matches_url(const URLSpec &url) const; 00069 00070 void output(ostream &out) const; 00071 00072 private: 00073 bool parse_cookie_param(const string ¶m, bool first_param); 00074 00075 string _name; 00076 string _value; 00077 string _path; 00078 string _domain; 00079 HTTPDate _expires; 00080 bool _secure; 00081 }; 00082 00083 INLINE ostream &operator << (ostream &out, const HTTPCookie &cookie); 00084 00085 #include "httpCookie.I" 00086 00087 #endif // HAVE_OPENSSL 00088 00089 #endif