30 operator < (
const HTTPCookie &other)
const {
31 if (_domain != other._domain) {
32 return _domain < other._domain;
35 if (_path != other._path) {
38 return _path > other._path;
41 if (_name != other._name) {
42 return _name < other._name;
56 update_from(
const HTTPCookie &other) {
57 nassertv(!(other < *
this) && !(*
this < other));
59 _value = other._value;
60 _expires = other._expires;
61 _secure = other._secure;
70 parse_set_cookie(
const string &format,
const URLSpec &url) {
79 bool first_param =
true;
82 while (start < format.length() && isspace(format[start])) {
85 size_t semicolon = format.find(
';', start);
87 while (semicolon != string::npos) {
88 if (!parse_cookie_param(format.substr(start, semicolon - start),
93 start = semicolon + 1;
94 while (start < format.length() && isspace(format[start])) {
97 semicolon = format.find(
';', start);
100 if (!parse_cookie_param(format.substr(start), first_param)) {
112 matches_url(
const URLSpec &url)
const {
113 if (_domain.empty()) {
117 if (server == _domain ||
118 (
string(
".") + server) == _domain ||
119 (server.length() > _domain.length() &&
120 server.substr(server.length() - _domain.length()) == _domain &&
121 (_domain[0] ==
'.' || server[server.length() - _domain.length() - 1] ==
'.'))) {
125 if (path.length() >= _path.length() &&
126 path.substr(0, _path.length()) == _path) {
129 if (_secure && !url.
is_ssl()) {
145 output(std::ostream &out)
const {
146 out << _name <<
"=" << _value
147 <<
"; path=" << _path <<
"; domain=" << _domain;
150 out <<
"; expires=" << _expires;
165 parse_cookie_param(
const string ¶m,
bool first_param) {
166 size_t equals = param.find(
'=');
169 if (equals == string::npos) {
172 key = param.substr(0, equals);
173 value = param.substr(equals + 1);
182 if (key ==
"expires") {
184 if (!_expires.is_valid()) {
188 }
else if (key ==
"path") {
191 }
else if (key ==
"domain") {
196 if (!_domain.empty() && _domain[0] !=
'.') {
197 _domain = string(
".") + _domain;
200 }
else if (key ==
"secure") {
211 #endif // HAVE_OPENSSL is_ssl
Returns true if the URL's scheme specifies an SSL-secured protocol such as https, or false otherwise.
A container for a URL, e.g.
string downcase(const string &s)
Returns the input string with all uppercase letters converted to lowercase.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
get_path
Returns the path specified by the URL, or "/" if no path is specified.
A container for an HTTP-legal time/date indication.
get_server
Returns the server name specified by the URL, if any.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.