Kea 3.3.3
url.h
Go to the documentation of this file.
1// Copyright (C) 2017-2026 Internet Systems Consortium, Inc. ("ISC")
2//
3// This Source Code Form is subject to the terms of the Mozilla Public
4// License, v. 2.0. If a copy of the MPL was not distributed with this
5// file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
7#ifndef KEA_URL_H
8#define KEA_URL_H
9
10#include <asiolink/io_address.h>
11
12#include <cstdint>
13#include <string>
14
15namespace isc {
16namespace http {
17
22class Url {
23public:
24
26 enum Scheme : uint16_t {
29 };
30
36 explicit Url(const std::string& url);
37
44 bool operator<(const Url& url) const;
45
49 bool isValid() const {
50 return (valid_);
51 }
52
54 std::string getErrorMessage() const {
55 return (error_message_);
56 }
57
61 Scheme getScheme() const;
62
67 std::string getStrippedHostname() const;
68
73 unsigned getPort() const;
74
79 std::string getPath() const;
80
84 std::string toText() const;
85
89 const std::string& rawUrl() const {
90 return (url_);
91 }
92
93private:
97 std::string getHostname() const;
98
100 void checkValid() const;
101
106 void parse();
107
109 std::string url_;
110
112 bool valid_;
113
115 std::string error_message_;
116
118 Scheme scheme_;
119
121 std::string hostname_;
122
124 unsigned port_;
125
127 std::string path_;
128};
129
130} // end of namespace isc::http
131} // end of namespace isc
132
133#endif // endif
Represents an URL.
Definition url.h:22
std::string toText() const
Returns textual representation of the URL.
Definition url.cc:65
std::string getStrippedHostname() const
Returns hostname stripped from [ ] characters surrounding IPv6 address.
Definition url.cc:43
std::string getErrorMessage() const
Returns parsing error message.
Definition url.h:54
unsigned getPort() const
Returns port number.
Definition url.cc:53
Scheme getScheme() const
Returns parsed scheme.
Definition url.cc:31
bool operator<(const Url &url) const
compares URLs lexically.
Definition url.cc:26
Url(const std::string &url)
Constructor.
Definition url.cc:19
bool isValid() const
Checks if the URL is valid.
Definition url.h:49
std::string getPath() const
Returns path.
Definition url.cc:59
Scheme
Scheme: https or http.
Definition url.h:26
const std::string & rawUrl() const
Returns the raw, unparsed URL string.
Definition url.h:89
Defines the logger used by the top-level component of kea-lfc.