@@ -16,36 +16,40 @@ namespace network {
1616bool operator == (const uri &lhs,const uri &rhs) {
1717// the scheme can be compared insensitive to case
1818bool equal =boost::iequals (lhs.scheme_range (), rhs.scheme_range ());
19- if (equal)
20- {
19+ if (equal) {
2120// the user info must be case sensitive
2221equal =boost::equals (lhs.user_info_range (), rhs.user_info_range ());
2322}
2423
25- if (equal)
26- {
24+ if (equal){
2725// the host can be compared insensitive to case
28- equal =boost::iequals (
29- std::make_pair (std::begin (lhs.host_range ()),std::end (lhs.host_range ())),
30- std::make_pair (std::begin (rhs.host_range ()),std::end (rhs.host_range ())));
26+ equal =boost::iequals (lhs.host_range (), rhs.host_range ());
3127}
3228
33- if (equal)
34- {
35- // TODO: test default ports according to scheme
36- equal =boost::equals (
37- std::make_pair (std::begin (lhs.port_range ()),std::end (lhs.port_range ())),
38- std::make_pair (std::begin (rhs.port_range ()),std::end (rhs.port_range ())));
29+ if (equal) {
30+ if (lhs.port_range () && rhs.port_range ()) {
31+ equal =boost::equals (lhs.port_range (), rhs.port_range ());
32+ }
33+ else if (!lhs.port_range () && rhs.port_range ()) {
34+ auto port =default_port (lhs.scheme ());
35+ if (port) {
36+ equal =boost::equals (*port, rhs.port_range ());
37+ }
38+ }
39+ else if (lhs.port_range () && !rhs.port_range ()) {
40+ auto port =default_port (rhs.scheme ());
41+ if (port) {
42+ equal =boost::equals (lhs.port_range (), *port);
43+ }
44+ }
3945}
4046
41- if (equal)
42- {
47+ if (equal) {
4348// TODO: test normalized paths
4449equal =boost::iequals (lhs.path_range (), rhs.path_range ());
4550}
4651
47- if (equal)
48- {
52+ if (equal) {
4953// test query, independent of order
5054std::map<uri::string_type, uri::string_type> lhs_query_params, rhs_query_params;
5155equal = (query_map (lhs, lhs_query_params) ==query_map (rhs, rhs_query_params));