MCPcopy Create free account
hub / github.com/3rdparty/libprocess / URL

Class URL

include/process/http.hpp:129–178  ·  view source on GitHub ↗

Represents a Uniform Resource Locator: scheme://domain|ip:port/path?query#fragment This is actually a URI-reference (see 4.1 of RFC 3986). TODO(bmahler): The default port should depend on the scheme!

Source from the content-addressed store, hash-verified

127//
128// TODO(bmahler): The default port should depend on the scheme!
129struct URL
130{
131 URL() = default;
132
133 URL(const std::string& _scheme,
134 const std::string& _domain,
135 const uint16_t _port = 80,
136 const std::string& _path = "/",
137 const hashmap<std::string, std::string>& _query =
138 (hashmap<std::string, std::string>()),
139 const Option<std::string>& _fragment = None())
140 : scheme(_scheme),
141 domain(_domain),
142 port(_port),
143 path(_path),
144 query(_query),
145 fragment(_fragment) {}
146
147 URL(const std::string& _scheme,
148 const net::IP& _ip,
149 const uint16_t _port = 80,
150 const std::string& _path = "/",
151 const hashmap<std::string, std::string>& _query =
152 (hashmap<std::string, std::string>()),
153 const Option<std::string>& _fragment = None())
154 : scheme(_scheme),
155 ip(_ip),
156 port(_port),
157 path(_path),
158 query(_query),
159 fragment(_fragment) {}
160
161 static Try<URL> parse(const std::string& urlString);
162
163 /**
164 * Returns whether the URL is absolute.
165 * See https://tools.ietf.org/html/rfc3986#section-4.3 for details.
166 */
167 bool isAbsolute() const;
168
169 Option<std::string> scheme;
170
171 // TODO(benh): Consider using unrestricted union for 'domain' and 'ip'.
172 Option<std::string> domain;
173 Option<net::IP> ip;
174 Option<uint16_t> port;
175 std::string path;
176 hashmap<std::string, std::string> query;
177 Option<std::string> fragment;
178};
179
180
181std::ostream& operator<<(std::ostream& stream, const URL& url);

Callers 5

parseMethod · 0.85
TEST_FFunction · 0.85
TEST_PFunction · 0.85
TESTFunction · 0.85
TEST_FFunction · 0.85

Calls

no outgoing calls

Tested by 4

TEST_FFunction · 0.68
TEST_PFunction · 0.68
TESTFunction · 0.68
TEST_FFunction · 0.68