Kea  1.9.9-git
url.h
Go to the documentation of this file.
1 // Copyright (C) 2017-2021 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 
13 namespace isc {
14 namespace http {
15 
20 class Url {
21 public:
22 
24  enum Scheme {
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 
64  std::string getHostname() const;
65 
70  std::string getStrippedHostname() const;
71 
76  unsigned getPort() const;
77 
82  std::string getPath() const;
83 
87  std::string toText() const;
88 
92  const std::string& rawUrl() const {
93  return (url_);
94  }
95 
96 private:
97 
99  void checkValid() const;
100 
105  void parse();
106 
108  std::string url_;
109 
111  bool valid_;
112 
114  std::string error_message_;
115 
117  Scheme scheme_;
118 
120  std::string hostname_;
121 
123  unsigned port_;
124 
126  std::string path_;
127 };
128 
129 } // end of namespace isc::http
130 } // end of namespace isc
131 
132 #endif // endif
std::string getStrippedHostname() const
Returns hostname stripped from [ ] characters surrounding IPv6 address.
Definition: url.cc:43
bool operator<(const Url &url) const
compares URLs lexically.
Definition: url.cc:26
std::string toText() const
Returns textual representation of the URL.
Definition: url.cc:65
std::string getPath() const
Returns path.
Definition: url.cc:59
bool isValid() const
Checks if the URL is valid.
Definition: url.h:47
Scheme
Scheme: https or http.
Definition: url.h:24
Represents an URL.
Definition: url.h:20
std::string getErrorMessage() const
Returns parsing error message.
Definition: url.h:52
std::string getHostname() const
Returns hostname.
Definition: url.cc:37
const std::string & rawUrl() const
Returns the raw, unparsed URL string.
Definition: url.h:92
Defines the logger used by the top-level component of kea-dhcp-ddns.
Url(const std::string &url)
Constructor.
Definition: url.cc:19
Scheme getScheme() const
Returns parsed scheme.
Definition: url.cc:31
unsigned getPort() const
Returns port number.
Definition: url.cc:53