Panda3D
httpCookie.h
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.h
10  * @author drose
11  * @date 2004-08-26
12  */
13 
14 #ifndef HTTPCOOKIE_H
15 #define HTTPCOOKIE_H
16 
17 #include "pandabase.h"
18 
19 // This module requires OpenSSL to compile, even if you do not intend to use
20 // this to establish https connections; this is because it uses the OpenSSL
21 // library to portably handle all of the socket communications.
22 
23 #ifdef HAVE_OPENSSL
24 
25 #include "httpDate.h"
26 #include "urlSpec.h"
27 
28 /**
29  * A cookie sent from an HTTP server to be stored on the client and returned
30  * when the path and/or domain matches.
31  */
32 class EXPCL_PANDA_DOWNLOADER HTTPCookie {
33 PUBLISHED:
34  INLINE HTTPCookie();
35  INLINE explicit HTTPCookie(const std::string &format, const URLSpec &url);
36  INLINE explicit HTTPCookie(const std::string &name, const std::string &path,
37  const std::string &domain);
38  INLINE ~HTTPCookie();
39 
40  INLINE void set_name(const std::string &name);
41  INLINE const std::string &get_name() const;
42 
43  INLINE void set_value(const std::string &value);
44  INLINE const std::string &get_value() const;
45 
46  INLINE void set_domain(const std::string &domain);
47  INLINE const std::string &get_domain() const;
48 
49  INLINE void set_path(const std::string &path);
50  INLINE const std::string &get_path() const;
51 
52  INLINE void set_expires(const HTTPDate &expires);
53  INLINE void clear_expires();
54  INLINE bool has_expires() const;
55  INLINE HTTPDate get_expires() const;
56 
57  INLINE void set_secure(bool flag);
58  INLINE bool get_secure() const;
59 
60  bool operator < (const HTTPCookie &other) const;
61  void update_from(const HTTPCookie &other);
62 
63  bool parse_set_cookie(const std::string &format, const URLSpec &url);
64  INLINE bool is_expired(const HTTPDate &now = HTTPDate::now()) const;
65  bool matches_url(const URLSpec &url) const;
66 
67  void output(std::ostream &out) const;
68 
69 private:
70  bool parse_cookie_param(const std::string &param, bool first_param);
71 
72  std::string _name;
73  std::string _value;
74  std::string _path;
75  std::string _domain;
76  HTTPDate _expires;
77  bool _secure;
78 };
79 
80 INLINE std::ostream &operator << (std::ostream &out, const HTTPCookie &cookie);
81 
82 #include "httpCookie.I"
83 
84 #endif // HAVE_OPENSSL
85 
86 #endif
A container for a URL, e.g.
Definition: urlSpec.h:28
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A container for an HTTP-legal time/date indication.
Definition: httpDate.h:27
static HTTPDate now()
Returns an HTTPDate that represents the current time and date.
Definition: httpDate.I:47
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.