2022-06-26 17:03:06 +02:00
|
|
|
#ifndef WEB_SERVER_COOKIE_H
|
|
|
|
#define WEB_SERVER_COOKIE_H
|
2022-06-25 01:55:54 +02:00
|
|
|
|
2023-12-18 00:25:33 +01:00
|
|
|
/*************************************************************************/
|
|
|
|
/* web_server_cookie.h */
|
|
|
|
/*************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* PANDEMONIUM ENGINE */
|
|
|
|
/* https://github.com/Relintai/pandemonium_engine */
|
|
|
|
/*************************************************************************/
|
|
|
|
/* Copyright (c) 2022-present Péter Magyar. */
|
|
|
|
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
|
|
|
|
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
|
|
|
/* */
|
|
|
|
/* Permission is hereby granted, free of charge, to any person obtaining */
|
|
|
|
/* a copy of this software and associated documentation files (the */
|
|
|
|
/* "Software"), to deal in the Software without restriction, including */
|
|
|
|
/* without limitation the rights to use, copy, modify, merge, publish, */
|
|
|
|
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
|
|
|
/* permit persons to whom the Software is furnished to do so, subject to */
|
|
|
|
/* the following conditions: */
|
|
|
|
/* */
|
|
|
|
/* The above copyright notice and this permission notice shall be */
|
|
|
|
/* included in all copies or substantial portions of the Software. */
|
|
|
|
/* */
|
|
|
|
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
|
|
|
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
|
|
|
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
|
|
|
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
|
|
|
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
|
|
|
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
|
|
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
|
|
|
/*************************************************************************/
|
|
|
|
|
2022-07-21 14:05:55 +02:00
|
|
|
#include "core/os/os.h"
|
2022-08-17 14:19:55 +02:00
|
|
|
#include "core/string/ustring.h"
|
2022-06-26 17:03:06 +02:00
|
|
|
|
2022-08-17 13:45:14 +02:00
|
|
|
#include "core/object/reference.h"
|
2022-06-26 17:03:06 +02:00
|
|
|
|
|
|
|
class WebServerCookie : public Reference {
|
|
|
|
GDCLASS(WebServerCookie, Reference);
|
2022-06-25 01:55:54 +02:00
|
|
|
|
|
|
|
public:
|
2022-07-21 15:36:04 +02:00
|
|
|
enum SameSiteValues {
|
|
|
|
SAME_SITE_UNSET = 0,
|
|
|
|
SAME_SITE_NONE,
|
|
|
|
SAME_SITE_LAX,
|
|
|
|
SAME_SITE_STRICT,
|
|
|
|
};
|
|
|
|
|
2022-06-26 17:03:06 +02:00
|
|
|
String get_domain();
|
|
|
|
void set_domain(const String &val);
|
|
|
|
|
|
|
|
String get_path();
|
|
|
|
void set_path(const String &val);
|
|
|
|
|
|
|
|
String get_key();
|
|
|
|
void set_key(const String &val);
|
|
|
|
|
|
|
|
String get_value();
|
|
|
|
void set_value(const String &val);
|
|
|
|
|
|
|
|
bool get_http_only();
|
|
|
|
void set_http_only(const bool val);
|
|
|
|
|
|
|
|
bool get_secure();
|
|
|
|
void set_secure(const bool val);
|
|
|
|
|
2022-07-21 14:05:55 +02:00
|
|
|
bool get_delete();
|
|
|
|
void set_delete(const bool val);
|
|
|
|
|
2022-07-21 15:36:04 +02:00
|
|
|
SameSiteValues get_same_site();
|
|
|
|
void set_same_site(const SameSiteValues val);
|
|
|
|
|
|
|
|
bool get_use_max_age();
|
|
|
|
void set_use_max_age(const bool val);
|
|
|
|
|
|
|
|
int get_max_age();
|
|
|
|
void set_max_age(const int val);
|
|
|
|
|
|
|
|
bool get_use_expiry_date();
|
|
|
|
void set_use_expiry_date(const bool val);
|
2022-07-21 14:05:55 +02:00
|
|
|
|
|
|
|
uint64_t get_expiry_date_unix_time();
|
|
|
|
void set_expiry_date_unix_time(const uint64_t unix_time);
|
|
|
|
|
|
|
|
OS::DateTime get_expiry_date();
|
|
|
|
void set_expiry_date(OS::DateTime date_time);
|
|
|
|
void set_expiry_date(OS::Date date, OS::Time time);
|
|
|
|
|
|
|
|
Dictionary get_expiry_date_dict();
|
|
|
|
void set_expiry_date_dict(const Dictionary &date, const Dictionary &time);
|
|
|
|
void set_expiry_date_dt_dict(const Dictionary &date_time);
|
|
|
|
|
2022-06-26 17:03:06 +02:00
|
|
|
void set_data(const String &p_key, const String &p_value);
|
|
|
|
|
2022-07-21 14:05:55 +02:00
|
|
|
String get_response_header_string();
|
|
|
|
|
2022-06-26 17:03:06 +02:00
|
|
|
WebServerCookie();
|
|
|
|
~WebServerCookie();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
static void _bind_methods();
|
2022-07-21 14:05:55 +02:00
|
|
|
|
2022-07-21 15:36:04 +02:00
|
|
|
bool _use_max_age;
|
|
|
|
int _max_age;
|
|
|
|
bool _use_expiry_date;
|
2022-07-21 14:05:55 +02:00
|
|
|
OS::DateTime _expiry_date;
|
|
|
|
String _domain;
|
|
|
|
String _path;
|
|
|
|
String _key;
|
|
|
|
String _value;
|
|
|
|
bool _http_only;
|
|
|
|
bool _secure;
|
|
|
|
bool _delete;
|
2022-07-21 15:36:04 +02:00
|
|
|
SameSiteValues _same_site;
|
2022-06-25 01:55:54 +02:00
|
|
|
};
|
|
|
|
|
2022-07-21 15:36:04 +02:00
|
|
|
VARIANT_ENUM_CAST(WebServerCookie::SameSiteValues);
|
|
|
|
|
2022-06-26 15:00:25 +02:00
|
|
|
#endif
|