Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 39 additions & 4 deletions boost/network/uri/uri.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,14 +263,49 @@ uri::string_type fragment(const uri &uri_) {

inline
uri::string_type hierarchical_part(const uri &uri_) {
return uri::string_type(boost::begin(uri_.user_info_range()),
boost::end(uri_.path_range()));
uri::string_type::const_iterator first, last;
uri::const_range_type user_info = uri_.user_info_range();
uri::const_range_type host = uri_.host_range();
uri::const_range_type port = uri_.port_range();
uri::const_range_type path = uri_.path_range();
if (user_info) {
first = boost::begin(user_info);
}
else {
first = boost::begin(host);
}
if (path) {
last = boost::end(path);
}
else if (port) {
last = boost::end(port);
}
else {
last = boost::end(host);
}
return uri::string_type(first, last);
}

inline
uri::string_type authority(const uri &uri_) {
return uri::string_type(boost::begin(uri_.user_info_range()),
boost::end(uri_.port_range()));
uri::string_type::const_iterator first, last;
uri::const_range_type user_info = uri_.user_info_range();
uri::const_range_type host = uri_.host_range();
uri::const_range_type port = uri_.port_range();
if (user_info) {
first = boost::begin(user_info);
}
else {
first = boost::begin(host);
}

if (port) {
last = boost::end(port);
}
else {
last = boost::end(host);
}
return uri::string_type(first, last);
}

inline
Expand Down
6 changes: 6 additions & 0 deletions libs/network/test/uri/uri_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -556,3 +556,9 @@ BOOST_AUTO_TEST_CASE(issue_161_test) {
BOOST_CHECK_EQUAL(uri::decoded(queries["param2"]),
"some plus encoded text");
}

BOOST_AUTO_TEST_CASE(issue_364_test) {
uri::uri instance;
uri::schemes::http(instance) << uri::host("my.awesome.server.com");
BOOST_CHECK_EQUAL("my.awesome.server.com", uri::authority(instance));
}