MySQL 9.3.0
Source Code Documentation
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
uri.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2021, 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_HTTP_INCLUDE_HTTP_BASE_URI_H_
27#define ROUTER_SRC_HTTP_INCLUDE_HTTP_BASE_URI_H_
28
29#include <map>
30#include <string>
31#include <vector>
32
33#include "mysqlrouter/uri.h"
34
36
37namespace http {
38namespace base {
39
41 public:
42 using QueryElements = std::map<std::string, std::string>;
43 using PathElements = std::vector<std::string>;
44
45 public:
46 Uri();
47 Uri(const std::string &uri); // NOLINT(runtime/explicit)
48 Uri(Uri &&uri);
49 Uri(const Uri &uri);
50 virtual ~Uri();
51
52 /**
53 * convert URI to string.
54 */
55 virtual std::string join() const;
56 virtual std::string join_path() const;
57
58 virtual std::string get_scheme() const;
59 virtual void set_scheme(const std::string &scheme);
60
61 virtual std::string get_userinfo() const;
62 virtual void set_userinfo(const std::string &userinfo);
63
64 virtual std::string get_host() const;
65 virtual void set_host(const std::string &host);
66
67 // Return -1 and uint16_t range
68 virtual int32_t get_port() const;
69 virtual void set_port(int32_t port);
70 /**
71 * get path part of the URI.
72 */
73 virtual std::string get_path() const;
74 virtual void set_path(const std::string &path);
75
76 virtual std::string get_fragment() const;
77 virtual void set_fragment(const std::string &fragment);
78
79 virtual std::string get_query() const;
80 virtual bool set_query(const std::string &query);
81
82 virtual QueryElements &get_query_elements();
83 virtual PathElements &get_path_elements();
84
85 virtual const QueryElements &get_query_elements() const;
86 virtual const PathElements &get_path_elements() const;
87
88 /**
89 * check if URI is valid.
90 */
91 bool empty() const;
92
93 Uri &operator=(Uri &&other);
94 Uri &operator=(const Uri &other);
95
96 private:
97 operator bool() const;
99};
100
101/**
102 * canonicalize a URI path.
103 *
104 * input | output
105 * -------|-------
106 * / | /
107 * /./ | /
108 * // | /
109 * /../ | /
110 * /a/../ | /
111 * /../a/ | /a/
112 * /../a | /a
113 */
115 const std::string &uri_path);
116
117} // namespace base
118} // namespace http
119
120#endif // ROUTER_SRC_HTTP_INCLUDE_HTTP_BASE_URI_H_
Definition: uri.h:40
virtual ~Uri()
std::map< std::string, std::string > QueryElements
Definition: uri.h:42
std::vector< std::string > PathElements
Definition: uri.h:43
mysqlrouter::URI uri_impl_
Definition: uri.h:98
Parse and create URIs according to RFC3986.
Definition: uri.h:66
#define HTTP_COMMON_EXPORT
Definition: http_common_export.h:15
static char * query
Definition: myisam_ftdump.cc:47
const char * host
Definition: mysqladmin.cc:66
static char * path
Definition: mysqldump.cc:150
HTTP_COMMON_EXPORT std::string http_uri_path_canonicalize(const std::string &uri_path)
canonicalize a URI path.
Definition: uri.cc:195
Request::Uri Uri
Definition: request.cc:36
Definition: connection.h:55
std::string join(const detail::range auto &rng, std::string_view delim)
join elements of a range into a string separated by a delimiter.
Definition: string.h:74
std::string join_path(const std::vector< std::string > &components)
Definition: utils_path_unix.cc:57
required uint64 port
Definition: replication_asynchronous_connection_failover.proto:33