Panda3D

Loading...
Searching...
No Matches
httpCookie.I
Go to the documentation of this file.
1/**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file httpCookie.I
10 * @author drose
11 * @date 2004-08-26
12 */
13
14/**
15 * Constructs an empty cookie.
16 */
17INLINE HTTPCookie::
18HTTPCookie() :
19 _secure(false)
20{
21}
22
23/**
24 * Constructs a cookie according to the indicated string, presumably the tag
25 * of a Set-Cookie header. There is no way to detect a formatting error in
26 * the string with this constructor.
27 */
28INLINE HTTPCookie::
29HTTPCookie(const std::string &format, const URLSpec &url) {
30 parse_set_cookie(format, url);
31}
32
33/**
34 * Constructs a cookie with the indicated name, path, and domain values, but
35 * no other data. This is most useful for looking up an existing cookie in
36 * the HTTPClient.
37 */
38INLINE HTTPCookie::
39HTTPCookie(const std::string &name, const std::string &path, const std::string &domain) :
40 _name(name),
41 _path(path),
42 _domain(domain),
43 _secure(false)
44{
45}
46
47/**
48 *
49 */
50INLINE HTTPCookie::
51~HTTPCookie() {
52}
53
54/**
55 *
56 */
57INLINE void HTTPCookie::
58set_name(const std::string &name) {
59 _name = name;
60}
61
62/**
63 * Returns the name of the cookie. This is the key value specified by the
64 * server.
65 */
66INLINE const std::string &HTTPCookie::
67get_name() const {
68 return _name;
69}
70
71/**
72 *
73 */
74INLINE void HTTPCookie::
75set_value(const std::string &value) {
76 _value = value;
77}
78
79/**
80 * Returns the value of the cookie. This is the arbitrary string associated
81 * with the cookie's name, as specified by the server.
82 */
83INLINE const std::string &HTTPCookie::
84get_value() const {
85 return _value;
86}
87
88/**
89 *
90 */
91INLINE void HTTPCookie::
92set_domain(const std::string &domain) {
93 _domain = domain;
94}
95
96/**
97 *
98 */
99INLINE const std::string &HTTPCookie::
100get_domain() const {
101 return _domain;
102}
103
104/**
105 *
106 */
107INLINE void HTTPCookie::
108set_path(const std::string &path) {
109 _path = path;
110}
111
112/**
113 * Returns the prefix of the URL paths on the server for which this cookie
114 * will be sent.
115 */
116INLINE const std::string &HTTPCookie::
117get_path() const {
118 return _path;
119}
120
121/**
122 *
123 */
124INLINE void HTTPCookie::
125set_expires(const HTTPDate &expires) {
126 _expires = expires;
127}
128
129/**
130 * Removes the expiration date on the cookie.
131 */
132INLINE void HTTPCookie::
133clear_expires() {
134 _expires = HTTPDate();
135}
136
137/**
138 * Returns true if the cookie has an expiration date, false otherwise.
139 */
140INLINE bool HTTPCookie::
141has_expires() const {
142 return _expires.is_valid();
143}
144
145/**
146 * Returns the expiration date of the cookie if it is set, or an invalid date
147 * if it is not.
148 */
149INLINE HTTPDate HTTPCookie::
150get_expires() const {
151 return _expires;
152}
153
154/**
155 *
156 */
157INLINE void HTTPCookie::
158set_secure(bool secure) {
159 _secure = secure;
160}
161
162/**
163 * Returns true if the server has indicated this is a "secure" cookie which
164 * should only be sent over an HTTPS channel.
165 */
166INLINE bool HTTPCookie::
167get_secure() const {
168 return _secure;
169}
170
171/**
172 * Returns true if the cookie's expiration date is before the indicated date,
173 * false otherwise.
174 */
175INLINE bool HTTPCookie::
176is_expired(const HTTPDate &now) const {
177 return _expires.is_valid() && _expires < now;
178}
179
180INLINE std::ostream &operator << (std::ostream &out, const HTTPCookie &cookie) {
181 cookie.output(out);
182 return out;
183}
HTTPDate
A container for an HTTP-legal time/date indication.
Definition httpDate.h:27
HTTPDate::is_valid
bool is_valid() const
Returns true if the date is meaningful, or false if it is -1 (which generally indicates the source st...
Definition httpDate.I:56
URLSpec
A container for a URL, e.g.
Definition urlSpec.h:28