Panda3D

Loading...
Searching...
No Matches
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 {
33PUBLISHED:
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
69PUBLISHED:
70 MAKE_PROPERTY(name, get_name, set_name);
71 MAKE_PROPERTY(value, get_value, set_value);
72 MAKE_PROPERTY(domain, get_domain, set_domain);
73 MAKE_PROPERTY(path, get_path, set_path);
74 MAKE_PROPERTY2(expires, has_expires, get_expires, set_expires, clear_expires);
75 MAKE_PROPERTY(secure, get_secure, set_secure);
76
77 private:
78 bool parse_cookie_param(const std::string &param, bool first_param);
79
80 std::string _name;
81 std::string _value;
82 std::string _path;
83 std::string _domain;
84 HTTPDate _expires;
85 bool _secure;
86};
87
88INLINE std::ostream &operator << (std::ostream &out, const HTTPCookie &cookie);
89
90#include "httpCookie.I"
91
92#endif // HAVE_OPENSSL
93
94#endif
HTTPDate::now
static HTTPDate now()
Returns an HTTPDate that represents the current time and date.
Definition httpDate.I:47
httpCookie.I
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
httpDate.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pandabase.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
urlSpec.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.