Panda3D

httpCookie.I

00001 // Filename: httpCookie.I
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 
00016 ////////////////////////////////////////////////////////////////////
00017 //     Function: HTTPCookie::Constructor
00018 //       Access: Published
00019 //  Description: Constructs an empty cookie.
00020 ////////////////////////////////////////////////////////////////////
00021 INLINE HTTPCookie::
00022 HTTPCookie() :
00023   _secure(false)
00024 {
00025 }
00026 
00027 ////////////////////////////////////////////////////////////////////
00028 //     Function: HTTPCookie::Constructor
00029 //       Access: Published
00030 //  Description: Constructs a cookie according to the indicated
00031 //               string, presumably the tag of a Set-Cookie header.
00032 //               There is no way to detect a formatting error in the
00033 //               string with this constructor.
00034 ////////////////////////////////////////////////////////////////////
00035 INLINE HTTPCookie::
00036 HTTPCookie(const string &format, const URLSpec &url) {
00037   parse_set_cookie(format, url);
00038 }
00039 
00040 ////////////////////////////////////////////////////////////////////
00041 //     Function: HTTPCookie::Constructor
00042 //       Access: Published
00043 //  Description: Constructs a cookie with the indicated name, path,
00044 //               and domain values, but no other data.  This is most
00045 //               useful for looking up an existing cookie in the
00046 //               HTTPClient.
00047 ////////////////////////////////////////////////////////////////////
00048 INLINE HTTPCookie::
00049 HTTPCookie(const string &name, const string &path, const string &domain) :
00050   _name(name),
00051   _path(path),
00052   _domain(domain),
00053   _secure(false)
00054 {
00055 }
00056 
00057 ////////////////////////////////////////////////////////////////////
00058 //     Function: HTTPCookie::Destructor
00059 //       Access: Published
00060 //  Description: 
00061 ////////////////////////////////////////////////////////////////////
00062 INLINE HTTPCookie::
00063 ~HTTPCookie() {
00064 }
00065 
00066 ////////////////////////////////////////////////////////////////////
00067 //     Function: HTTPCookie::set_name
00068 //       Access: Published
00069 //  Description: 
00070 ////////////////////////////////////////////////////////////////////
00071 INLINE void HTTPCookie::
00072 set_name(const string &name) {
00073   _name = name;
00074 }
00075 
00076 ////////////////////////////////////////////////////////////////////
00077 //     Function: HTTPCookie::get_name
00078 //       Access: Published
00079 //  Description: Returns the name of the cookie.  This is the key
00080 //               value specified by the server.
00081 ////////////////////////////////////////////////////////////////////
00082 INLINE const string &HTTPCookie::
00083 get_name() const {
00084   return _name;
00085 }
00086 
00087 ////////////////////////////////////////////////////////////////////
00088 //     Function: HTTPCookie::set_value
00089 //       Access: Published
00090 //  Description: 
00091 ////////////////////////////////////////////////////////////////////
00092 INLINE void HTTPCookie::
00093 set_value(const string &value) {
00094   _value = value;
00095 }
00096 
00097 ////////////////////////////////////////////////////////////////////
00098 //     Function: HTTPCookie::get_value
00099 //       Access: Published
00100 //  Description: Returns the value of the cookie.  This is the
00101 //               arbitrary string associated with the cookie's name,
00102 //               as specified by the server.
00103 ////////////////////////////////////////////////////////////////////
00104 INLINE const string &HTTPCookie::
00105 get_value() const {
00106   return _value;
00107 }
00108 
00109 ////////////////////////////////////////////////////////////////////
00110 //     Function: HTTPCookie::set_domain
00111 //       Access: Published
00112 //  Description: 
00113 ////////////////////////////////////////////////////////////////////
00114 INLINE void HTTPCookie::
00115 set_domain(const string &domain) {
00116   _domain = domain;
00117 }
00118 
00119 ////////////////////////////////////////////////////////////////////
00120 //     Function: HTTPCookie::get_domain
00121 //       Access: Published
00122 //  Description: 
00123 ////////////////////////////////////////////////////////////////////
00124 INLINE const string &HTTPCookie::
00125 get_domain() const {
00126   return _domain;
00127 }
00128 
00129 ////////////////////////////////////////////////////////////////////
00130 //     Function: HTTPCookie::set_path
00131 //       Access: Published
00132 //  Description: 
00133 ////////////////////////////////////////////////////////////////////
00134 INLINE void HTTPCookie::
00135 set_path(const string &path) {
00136   _path = path;
00137 }
00138 
00139 ////////////////////////////////////////////////////////////////////
00140 //     Function: HTTPCookie::get_path
00141 //       Access: Published
00142 //  Description: Returns the prefix of the URL paths on the server for
00143 //               which this cookie will be sent.
00144 ////////////////////////////////////////////////////////////////////
00145 INLINE const string &HTTPCookie::
00146 get_path() const {
00147   return _path;
00148 }
00149 
00150 ////////////////////////////////////////////////////////////////////
00151 //     Function: HTTPCookie::set_expires
00152 //       Access: Published
00153 //  Description: 
00154 ////////////////////////////////////////////////////////////////////
00155 INLINE void HTTPCookie::
00156 set_expires(const HTTPDate &expires) {
00157   _expires = expires;
00158 }
00159 
00160 ////////////////////////////////////////////////////////////////////
00161 //     Function: HTTPCookie::clear_expires
00162 //       Access: Published
00163 //  Description: Removes the expiration date on the cookie.
00164 ////////////////////////////////////////////////////////////////////
00165 INLINE void HTTPCookie::
00166 clear_expires() {
00167   _expires = HTTPDate();
00168 }
00169 
00170 ////////////////////////////////////////////////////////////////////
00171 //     Function: HTTPCookie::has_expires
00172 //       Access: Published
00173 //  Description: Returns true if the cookie has an expiration date,
00174 //               false otherwise.
00175 ////////////////////////////////////////////////////////////////////
00176 INLINE bool HTTPCookie::
00177 has_expires() const {
00178   return _expires.is_valid();
00179 }
00180 
00181 ////////////////////////////////////////////////////////////////////
00182 //     Function: HTTPCookie::get_expires
00183 //       Access: Published
00184 //  Description: Returns the expiration date of the cookie if it is
00185 //               set, or an invalid date if it is not.
00186 ////////////////////////////////////////////////////////////////////
00187 INLINE HTTPDate HTTPCookie::
00188 get_expires() const {
00189   return _expires;
00190 }
00191 
00192 ////////////////////////////////////////////////////////////////////
00193 //     Function: HTTPCookie::set_secure
00194 //       Access: Published
00195 //  Description: 
00196 ////////////////////////////////////////////////////////////////////
00197 INLINE void HTTPCookie::
00198 set_secure(bool secure) {
00199   _secure = secure;
00200 }
00201 
00202 ////////////////////////////////////////////////////////////////////
00203 //     Function: HTTPCookie::get_secure
00204 //       Access: Published
00205 //  Description: Returns true if the server has indicated this is a
00206 //               "secure" cookie which should only be sent over an
00207 //               HTTPS channel.
00208 ////////////////////////////////////////////////////////////////////
00209 INLINE bool HTTPCookie::
00210 get_secure() const {
00211   return _secure;
00212 }
00213 
00214 ////////////////////////////////////////////////////////////////////
00215 //     Function: HTTPCookie::is_expired
00216 //       Access: Published
00217 //  Description: Returns true if the cookie's expiration date is
00218 //               before the indicated date, false otherwise.
00219 ////////////////////////////////////////////////////////////////////
00220 INLINE bool HTTPCookie::
00221 is_expired(const HTTPDate &now) const {
00222   return _expires.is_valid() && _expires < now;
00223 }
00224 
00225 INLINE ostream &operator << (ostream &out, const HTTPCookie &cookie) {
00226   cookie.output(out);
00227   return out;
00228 }
 All Classes Functions Variables Enumerations