Skip to content

Commit 4660197

Browse files
committed
Removed tag dispatching from URI.
1 parent 1f07337 commit 4660197

File tree

20 files changed

+179
-366
lines changed

20 files changed

+179
-366
lines changed

boost/network/protocol/http/impl/request.hpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include <boost/fusion/sequence/intrinsic/at_key.hpp>
1616
#include <boost/fusion/sequence/intrinsic/value_at_key.hpp>
1717

18-
#include <boost/network/uri/http/uri.hpp>
18+
#include <boost/network/uri/uri.hpp>
1919
#include <boost/network/traits/vector.hpp>
2020

2121
#include <boost/network/protocol/http/message/async_message.hpp>
@@ -50,7 +50,7 @@ namespace http {
5050
struct basic_request : public basic_message<Tag>
5151
{
5252

53-
mutable boost::network::uri::http::basic_uri<Tag> uri_;
53+
mutable boost::network::uri::basic_uri<typename string<Tag>::type> uri_;
5454
typedef basic_message<Tag> base_type;
5555

5656
public:
@@ -80,19 +80,25 @@ namespace http {
8080
}
8181

8282
void swap(basic_request & other) {
83-
using boost::network::uri::swap;
8483
base_type & base_ref(other);
8584
basic_request<Tag> & this_ref(*this);
8685
base_ref.swap(this_ref);
87-
swap(other.uri_, this->uri_);
86+
boost::swap(other.uri_, this->uri_);
8887
}
8988

9089
string_type const host() const {
9190
return uri_.host();
9291
}
9392

9493
port_type port() const {
95-
return uri::port_us(uri_);
94+
boost::optional<port_type> port = uri::port_us(uri_);
95+
if (!port)
96+
{
97+
typedef constants<Tag> consts;
98+
return boost::iequals(uri_.scheme_range(),
99+
string_type(consts::https()))? 443 : 80;
100+
}
101+
return *port;
96102
}
97103

98104
string_type const path() const {
@@ -115,7 +121,7 @@ namespace http {
115121
uri_ = new_uri;
116122
}
117123

118-
boost::network::uri::http::basic_uri<Tag> const & uri() const {
124+
boost::network::uri::basic_uri<typename string<Tag>::type> const & uri() const {
119125
return uri_;
120126
}
121127

boost/network/protocol/http/message/wrappers/port.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ namespace boost { namespace network { namespace http {
3030
}
3131

3232
operator boost::optional<boost::uint16_t> () {
33-
return port_us(message_.uri());
33+
return uri::port_us(message_.uri());
3434
}
3535
};
3636

boost/network/protocol/http/message/wrappers/uri.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
// (See accompanying file LICENSE_1_0.txt or copy at
88
// http://www.boost.org/LICENSE_1_0.txt)
99

10-
#include <boost/network/uri/http/uri.hpp>
10+
#include <boost/network/uri/uri.hpp>
1111

1212
namespace boost { namespace network { namespace http {
1313

@@ -24,7 +24,7 @@ namespace boost { namespace network { namespace http {
2424
operator string_type() {
2525
return message_.uri().raw();
2626
}
27-
operator boost::network::uri::basic_uri<tags::http_default_8bit_tcp_resolve> () {
27+
operator boost::network::uri::basic_uri<typename string<Tag>::type> () {
2828
return message_.uri();
2929
}
3030
};
@@ -40,6 +40,6 @@ namespace boost { namespace network { namespace http {
4040

4141
} // namespace network
4242

43-
} // nmaespace boost
43+
} // namespace boost
4444

4545
#endif // BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_URI_HPP_20100620

boost/network/uri.hpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,18 @@
88

99
#include <boost/network/traits/string.hpp>
1010
#include <boost/network/uri/uri.hpp>
11-
#include <boost/network/protocol/http/tags.hpp>
12-
#include <boost/network/uri/http/uri.hpp>
11+
//#include <boost/network/protocol/http/tags.hpp>
12+
//#include <boost/network/uri/http/uri.hpp>
1313

1414

1515
namespace boost { namespace network { namespace uri {
1616

17-
typedef basic_uri<boost::network::tags::default_string> uri;
18-
typedef basic_uri<boost::network::tags::default_wstring> wuri;
19-
20-
namespace http {
21-
typedef basic_uri<boost::network::http::tags::http_default_8bit_udp_resolve> uri;
22-
}
17+
typedef basic_uri<std::string> uri;
18+
typedef basic_uri<std::wstring> wuri;
2319

20+
//namespace http {
21+
//typedef basic_uri<boost::network::http::tags::http_default_8bit_udp_resolve> uri;
22+
//}
2423
} // namespace uri
2524
} // namespace network
2625
} // namespace boost

boost/network/uri/accessors.hpp

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -43,72 +43,72 @@ struct key_value_sequence
4343
} // namespace details
4444

4545
template <
46-
class Tag,
46+
class String,
4747
class Map
4848
>
4949
inline
50-
Map &query_map(const basic_uri<Tag> &uri, Map &map) {
51-
typename basic_uri<Tag>::const_range_type range = uri.query_range();
52-
details::key_value_sequence<basic_uri<Tag>, Map> parser;
50+
Map &query_map(const basic_uri<String> &uri, Map &map) {
51+
typename basic_uri<String>::const_range_type range = uri.query_range();
52+
details::key_value_sequence<basic_uri<String>, Map> parser;
5353
spirit::qi::parse(boost::begin(range), boost::end(range), parser, map);
5454
return map;
5555
}
5656

5757
template <
58-
class Tag
58+
class String
5959
>
60-
typename basic_uri<Tag>::string_type username(const basic_uri<Tag> &uri) {
61-
typename basic_uri<Tag>::const_range_type user_info_range = uri.user_info_range();
62-
typename basic_uri<Tag>::const_iterator it(boost::begin(user_info_range)), end(boost::end(user_info_range));
60+
String username(const basic_uri<String> &uri) {
61+
typename basic_uri<String>::const_range_type user_info_range = uri.user_info_range();
62+
typename basic_uri<String>::const_iterator it(boost::begin(user_info_range)), end(boost::end(user_info_range));
6363
for (; it != end; ++it) {
6464
if (*it == ':') {
6565
break;
6666
}
6767
}
68-
return typename string<Tag>::type(boost::begin(user_info_range), it);
68+
return String(boost::begin(user_info_range), it);
6969
}
7070

7171
template <
72-
class Tag
72+
class String
7373
>
74-
typename basic_uri<Tag>::string_type password(const basic_uri<Tag> &uri) {
75-
typename basic_uri<Tag>::const_range_type user_info_range = uri.user_info_range();
76-
typename basic_uri<Tag>::const_iterator it(boost::begin(user_info_range)), end(boost::end(user_info_range));
74+
String password(const basic_uri<String> &uri) {
75+
typename basic_uri<String>::const_range_type user_info_range = uri.user_info_range();
76+
typename basic_uri<String>::const_iterator it(boost::begin(user_info_range)), end(boost::end(user_info_range));
7777
for (; it != end; ++it) {
7878
if (*it == ':') {
7979
++it;
8080
break;
8181
}
8282
}
83-
return typename string<Tag>::type(it, boost::end(user_info_range));
83+
return String(it, boost::end(user_info_range));
8484
}
8585

8686
template <
87-
class Tag
87+
class String
8888
>
89-
typename basic_uri<Tag>::string_type decoded_path(const basic_uri<Tag> &uri) {
90-
typename basic_uri<Tag>::const_range_type path_range = uri.path_range();
91-
typename basic_uri<Tag>::string_type decoded_path;
89+
String decoded_path(const basic_uri<String> &uri) {
90+
typename basic_uri<String>::const_range_type path_range = uri.path_range();
91+
String decoded_path;
9292
decode(path_range, std::back_inserter(decoded_path));
9393
return decoded_path;
9494
}
9595

9696
template <
97-
class Tag
97+
class String
9898
>
99-
typename basic_uri<Tag>::string_type decoded_query(const basic_uri<Tag> &uri) {
100-
typename basic_uri<Tag>::const_range_type query_range = uri.query_range();
101-
typename basic_uri<Tag>::string_type decoded_query;
99+
String decoded_query(const basic_uri<String> &uri) {
100+
typename basic_uri<String>::const_range_type query_range = uri.query_range();
101+
String decoded_query;
102102
decode(query_range, std::back_inserter(decoded_query));
103103
return decoded_query;
104104
}
105105

106106
template <
107-
class Tag
107+
class String
108108
>
109-
typename basic_uri<Tag>::string_type decoded_fragment(const basic_uri<Tag> &uri) {
110-
typename basic_uri<Tag>::const_range_type fragment_range = uri.fragment_range();
111-
typename basic_uri<Tag>::string_type decoded_fragment;
109+
String decoded_fragment(const basic_uri<String> &uri) {
110+
typename basic_uri<String>::const_range_type fragment_range = uri.fragment_range();
111+
String decoded_fragment;
112112
decode(fragment_range, std::back_inserter(decoded_fragment));
113113
return decoded_fragment;
114114
}

boost/network/uri/detail/uri_parts.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99

1010
# include <boost/fusion/include/vector.hpp>
11-
# include <boost/fusion/sequence/intrinsic/at_c.hpp>
1211

1312

1413
namespace boost {

boost/network/uri/directives.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,22 @@ namespace boost {
1717
namespace network {
1818
namespace uri {
1919
template <
20-
class Tag
20+
class String
2121
>
2222
inline
23-
basic_uri<Tag> &operator << (basic_uri<Tag> &uri, const basic_uri<Tag> &root_uri) {
24-
if (root_uri.is_valid()) {
23+
basic_uri<String> &operator << (basic_uri<String> &uri, const basic_uri<String> &root_uri) {
24+
if (empty(uri) && valid(root_uri)) {
2525
uri.append(boost::begin(root_uri), boost::end(root_uri));
2626
}
2727
return uri;
2828
}
2929

3030
template <
31-
class Tag
31+
class String
3232
, class Directive
3333
>
3434
inline
35-
basic_uri<Tag> &operator << (basic_uri<Tag> &uri, const Directive &directive) {
35+
basic_uri<String> &operator << (basic_uri<String> &uri, const Directive &directive) {
3636
directive(uri);
3737
return uri;
3838
}

boost/network/uri/directives/fragment.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ struct fragment_directive {
2020
{}
2121

2222
template <
23-
class Tag
23+
class String
2424
, template <class> class Uri
2525
>
26-
void operator () (Uri<Tag> &uri) const {
27-
typename string<Tag>::type encoded_value;
26+
void operator () (Uri<String> &uri) const {
27+
String encoded_value;
2828
static const char separator[] = {'#'};
2929
uri.append(boost::begin(separator), boost::end(separator));
3030
encode(boost::as_literal(value), std::back_inserter(encoded_value));

boost/network/uri/directives/path.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ struct encoded_path_directive {
4949
{}
5050

5151
template <
52-
class Tag
52+
class StringT
5353
, template <class> class Uri
5454
>
55-
void operator () (Uri<Tag> &uri) const {
56-
typename string<Tag>::type encoded_value;
55+
void operator () (Uri<StringT> &uri) const {
56+
StringT encoded_value;
5757
encode(boost::as_literal(value), std::back_inserter(encoded_value));
5858
uri.append(encoded_value);
5959
}

boost/network/uri/directives/port.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ struct port_directive {
2222
{}
2323

2424
template <
25-
class Tag
25+
class String
2626
, template <class> class Uri
2727
>
28-
void operator () (Uri<Tag> &uri) const {
28+
void operator () (Uri<String> &uri) const {
2929
static const char separator[] = {':'};
3030
uri.append(boost::begin(separator), boost::end(separator));
3131
uri.append(value);
@@ -43,13 +43,13 @@ struct port_directive_us {
4343
{}
4444

4545
template <
46-
class Tag
46+
class String
4747
, template <class> class Uri
4848
>
49-
void operator () (Uri<Tag> &uri) const {
49+
void operator () (Uri<String> &uri) const {
5050
static const char separator[] = {':'};
5151
uri.append(boost::begin(separator), boost::end(separator));
52-
typename string<Tag>::type port = boost::lexical_cast<typename string<Tag>::type>(value);
52+
String port = boost::lexical_cast<String>(value);
5353
uri.append(port);
5454
}
5555

0 commit comments

Comments
 (0)