Kea  1.5.0
url.h
Go to the documentation of this file.
1 // Copyright (C) 2017-2018 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 {
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 
64  std::string getHostname() const;
65 
70  std::string getStrippedHostname() const;
71 
76  unsigned getPort() const;
77 
81  std::string getPath() const;
82 
84  std::string toText() const;
85 
86 private:
87 
89  void checkValid() const;
90 
95  void parse();
96 
98  std::string url_;
99 
101  bool valid_;
102 
104  std::string error_message_;
105 
107  Scheme scheme_;
108 
110  std::string hostname_;
111 
113  unsigned port_;
114 
116  std::string path_;
117 };
118 
119 } // end of namespace isc::http
120 } // end of namespace isc
121 
122 #endif // endif
isc::http::Url::operator<
bool operator<(const Url &url) const
compares URLs lexically.
Definition: url.cc:26
io_address.h
isc::http::Url::isValid
bool isValid() const
Checks if the URL is valid.
Definition: url.h:47
isc::http::Url
Represents an URL.
Definition: url.h:20
isc::http::Url::getHostname
std::string getHostname() const
Returns hostname.
Definition: url.cc:37
isc::http::Url::Scheme
Scheme
Scheme: https or http.
Definition: url.h:24
isc::http::Url::getScheme
Scheme getScheme() const
Returns parsed scheme.
Definition: url.cc:31
isc::http::Url::getPort
unsigned getPort() const
Returns port number.
Definition: url.cc:53
isc::http::Url::HTTP
@ HTTP
Definition: url.h:25
isc
Defines the logger used by the top-level component of kea-dhcp-ddns.
Definition: agent_parser.cc:144
isc::http::Url::getErrorMessage
std::string getErrorMessage() const
Returns parsing error message.
Definition: url.h:52
isc::http::Url::toText
std::string toText() const
Returns textual representation of the URL.
Definition: url.cc:65
isc::http::Url::getPath
std::string getPath() const
Returns path.
Definition: url.cc:59
isc::http::Url::HTTPS
@ HTTPS
Definition: url.h:26
isc::http::Url::Url
Url(const std::string &url)
Constructor.
Definition: url.cc:19
isc::http::Url::getStrippedHostname
std::string getStrippedHostname() const
Returns hostname stripped from [ ] characters surrounding IPv6 address.
Definition: url.cc:43