Kea 2.5.8
url.h
Go to the documentation of this file.
1// Copyright (C) 2017-2022 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#include <string>
12
13namespace isc {
14namespace http {
15
20class Url {
21public:
22
24 enum Scheme {
26 HTTPS
27 };
28
34 explicit Url(const std::string& url);
35
42 bool operator<(const Url& url) const;
43
47 bool isValid() const {
48 return (valid_);
49 }
50
52 std::string getErrorMessage() const {
53 return (error_message_);
54 }
55
59 Scheme getScheme() const;
60
65 std::string getStrippedHostname() const;
66
71 unsigned getPort() const;
72
77 std::string getPath() const;
78
82 std::string toText() const;
83
87 const std::string& rawUrl() const {
88 return (url_);
89 }
90
91private:
95 std::string getHostname() const;
96
98 void checkValid() const;
99
104 void parse();
105
107 std::string url_;
108
110 bool valid_;
111
113 std::string error_message_;
114
116 Scheme scheme_;
117
119 std::string hostname_;
120
122 unsigned port_;
123
125 std::string path_;
126};
127
128} // end of namespace isc::http
129} // end of namespace isc
130
131#endif // endif
Represents an URL.
Definition: url.h:20
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:52
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
bool isValid() const
Checks if the URL is valid.
Definition: url.h:47
std::string getPath() const
Returns path.
Definition: url.cc:59
const std::string & rawUrl() const
Returns the raw, unparsed URL string.
Definition: url.h:87
Scheme
Scheme: https or http.
Definition: url.h:24
Defines the logger used by the top-level component of kea-lfc.