MySQL 9.3.0
Source Code Documentation
cookie.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2022, 2025, Oracle and/or its affiliates.
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License, version 2.0,
6 as published by the Free Software Foundation.
7
8 This program is designed to work with certain software (including
9 but not limited to OpenSSL) that is licensed under separate terms,
10 as designated in a particular file or component or in included license
11 documentation. The authors of MySQL hereby grant you an additional
12 permission to link the program and your derivative works with the
13 separately licensed software that they have either included with
14 the program or referenced in the documentation.
15
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
20
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software
23 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 */
25
26#ifndef ROUTER_SRC_REST_MRS_SRC_MRS_HTTP_COOKIE_H_
27#define ROUTER_SRC_REST_MRS_SRC_MRS_HTTP_COOKIE_H_
28
29#include <chrono>
30#include <map>
31#include <string>
32
33#include "http/base/request.h"
34
35namespace mrs {
36namespace http {
37
38class Cookie {
39 public:
40 using duration = std::chrono::steady_clock::duration;
42 using MapWithCookies = std::map<std::string, std::string>;
43 enum SameSite { None, Lex, Strict };
44
45 public:
46 Cookie(Request *request);
47
48 static void clear(Request *request, const char *cookie_name);
49 // static std::string get(HttpRequest *request, const char *cookie_name);
50 static void set(Request *request, const std::string &cookie_name,
51 const std::string &value, const duration duration = {},
52 const std::string &path = {},
53 const SameSite *same_site = nullptr, bool secure = false,
54 bool http_only = false, const std::string &domain = {});
55
56 void set(const std::string &cookie_name, const std::string &value,
57 const duration duration = {}, const std::string &path = {},
58 const SameSite *same_site = nullptr, bool secure = false,
59 bool http_only = false, const std::string &domain = {});
60 std::string get(const std::string &key);
61 void clear(const char *cookie_name);
63
64 private:
65 static const char *kHttpParameterNameCookie;
68};
69
70} // namespace http
71} // namespace mrs
72
73#endif // ROUTER_SRC_REST_MRS_SRC_MRS_HTTP_COOKIE_H_
Definition: request.h:44
Definition: request.h:40
Definition: cookie.h:38
Cookie(Request *request)
Definition: cookie.cc:60
MapWithCookies & direct()
Definition: cookie.cc:129
static void clear(Request *request, const char *cookie_name)
Definition: cookie.cc:77
Request * request_
Definition: cookie.h:67
std::string get(const std::string &key)
Definition: cookie.cc:83
static const char * kHttpParameterNameCookie
Definition: cookie.h:65
MapWithCookies cookies_
Definition: cookie.h:66
static void set(Request *request, const std::string &cookie_name, const std::string &value, const duration duration={}, const std::string &path={}, const SameSite *same_site=nullptr, bool secure=false, bool http_only=false, const std::string &domain={})
Definition: cookie.cc:87
SameSite
Definition: cookie.h:43
@ Lex
Definition: cookie.h:43
@ None
Definition: cookie.h:43
@ Strict
Definition: cookie.h:43
std::chrono::steady_clock::duration duration
Definition: cookie.h:40
std::map< std::string, std::string > MapWithCookies
Definition: cookie.h:42
static char * path
Definition: mysqldump.cc:150
Definition: connection.h:55
ValueType value(const std::optional< ValueType > &v)
Definition: gtid.h:83
Definition: authorize_manager.h:48
required string key
Definition: replication_asynchronous_connection_failover.proto:60
RestClient::Request Request
Definition: rest_client.cc:29