Skip to content

Commit 5056125

Browse files
committed
Merge branch 'master' of github.com:cpp-netlib/cpp-netlib
Conflicts: boost/network/protocol/http/client/connection/async_normal.hpp boost/network/protocol/http/server/async_connection.hpp boost/network/uri/uri.hpp libs/network/test/uri/CMakeLists.txt libs/network/test/uri/url_builder_test.cpp
2 parents 42feebf + a796329 commit 5056125

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+2989
-1008
lines changed

boost/network/protocol/http/client/connection/async_normal.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#ifndef BOOST_NETWORK_PROTOCOL_HTTP_IMPL_HTTP_ASYNC_CONNECTION_HPP_20100601
22
#define BOOST_NETWORK_PROTOCOL_HTTP_IMPL_HTTP_ASYNC_CONNECTION_HPP_20100601
33

4+
// Copyright 2010 (C) Dean Michael Berris
5+
// Copyright 2010 (C) Sinefunc, Inc.
46
// Copyright 2011 Dean Michael Berris ([email protected]).
57
// Copyright 2011 Google,Inc.
68
// Distributed under the Boost Software License, Version 1.0.

boost/network/uri/builder.hpp

Lines changed: 75 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010

1111
# include <boost/network/uri/uri.hpp>
12+
# include <boost/asio/ip/address.hpp>
1213

1314

1415
namespace boost {
@@ -25,7 +26,7 @@ class builder {
2526

2627
}
2728

28-
builder &scheme(const string_type &scheme) {
29+
builder &set_scheme(const string_type &scheme) {
2930
uri_.uri_.append(scheme);
3031
if (opaque_schemes::exists(scheme)) {
3132
uri_.uri_.append(":");
@@ -37,52 +38,102 @@ class builder {
3738
return *this;
3839
}
3940

40-
builder &user_info(const string_type &user_info) {
41+
builder &scheme(const string_type &scheme) {
42+
return set_scheme(scheme);
43+
}
44+
45+
builder &set_user_info(const string_type &user_info) {
4146
uri_.uri_.append(user_info);
4247
uri_.uri_.append("@");
4348
uri_.parse();
4449
return *this;
4550
}
4651

47-
builder &host(const string_type &host) {
52+
builder &user_info(const string_type &user_info) {
53+
return set_user_info(user_info);
54+
}
55+
56+
builder &set_host(const string_type &host) {
4857
uri_.uri_.append(host);
4958
uri_.parse();
5059
return *this;
5160
}
5261

53-
builder &port(const string_type &port) {
62+
builder &host(const string_type &host) {
63+
return set_host(host);
64+
}
65+
66+
builder &set_host(const asio::ip::address &address) {
67+
uri_.uri_.append(address.to_string());
68+
uri_.parse();
69+
return *this;
70+
}
71+
72+
builder &host(const asio::ip::address &host) {
73+
return set_host(host);
74+
}
75+
76+
builder &set_host(const asio::ip::address_v4 &address) {
77+
uri_.uri_.append(address.to_string());
78+
uri_.parse();
79+
return *this;
80+
}
81+
82+
builder &host(const asio::ip::address_v4 &host) {
83+
return set_host(host);
84+
}
85+
86+
builder &set_host(const asio::ip::address_v6 &address) {
87+
uri_.uri_.append("[");
88+
uri_.uri_.append(address.to_string());
89+
uri_.uri_.append("]");
90+
uri_.parse();
91+
return *this;
92+
}
93+
94+
builder &host(const asio::ip::address_v6 &host) {
95+
return set_host(host);
96+
}
97+
98+
builder &set_port(const string_type &port) {
5499
uri_.uri_.append(":");
55100
uri_.uri_.append(port);
56101
uri_.parse();
57102
return *this;
58103
}
59104

105+
builder &port(const string_type &port) {
106+
return set_port(port);
107+
}
108+
60109
builder &port(uint16_t port) {
61-
return this->port(boost::lexical_cast<string_type>(port));
110+
return set_port(boost::lexical_cast<string_type>(port));
62111
}
63112

64-
builder &path(const string_type &path) {
113+
builder &set_path(const string_type &path) {
65114
uri_.uri_.append(path);
66115
uri_.parse();
67116
return *this;
68117
}
69118

119+
builder &path(const string_type &path) {
120+
return set_path(path);
121+
}
122+
70123
builder &encoded_path(const string_type &path) {
71124
string_type encoded_path;
72125
encode(path, std::back_inserter(encoded_path));
73-
uri_.uri_.append(encoded_path);
74-
uri_.parse();
75-
return *this;
126+
return set_path(encoded_path);
76127
}
77128

78-
builder &query(const string_type &query) {
129+
builder &set_query(const string_type &query) {
79130
uri_.uri_.append("?");
80131
uri_.uri_.append(query);
81132
uri_.parse();
82133
return *this;
83134
}
84135

85-
builder &query(const string_type &key, const string_type &value) {
136+
builder &set_query(const string_type &key, const string_type &value) {
86137
if (!uri_.query_range())
87138
{
88139
uri_.uri_.append("?");
@@ -98,13 +149,25 @@ class builder {
98149
return *this;
99150
}
100151

101-
builder &fragment(const string_type &fragment) {
152+
builder &query(const string_type &query) {
153+
return set_query(query);
154+
}
155+
156+
builder &query(const string_type &key, const string_type &value) {
157+
return set_query(key, value);
158+
}
159+
160+
builder &set_fragment(const string_type &fragment) {
102161
uri_.uri_.append("#");
103162
uri_.uri_.append(fragment);
104163
uri_.parse();
105164
return *this;
106165
}
107166

167+
builder &fragment(const string_type &fragment) {
168+
return set_fragment(fragment);
169+
}
170+
108171
private:
109172

110173
uri &uri_;

boost/network/uri/uri.hpp

Lines changed: 61 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,19 @@
77
#ifndef __BOOST_NETWORK_URI_INC__
88
# define __BOOST_NETWORK_URI_INC__
99

10-
# include <boost/network/constants.hpp>
10+
# pragma once
11+
1112
# include <boost/network/uri/config.hpp>
1213
# include <boost/network/uri/detail/uri_parts.hpp>
1314
# include <boost/network/uri/schemes.hpp>
1415
# include <boost/utility/swap.hpp>
1516
# include <boost/range/algorithm/equal.hpp>
1617
# include <boost/range/algorithm/copy.hpp>
18+
# include <boost/range/as_literal.hpp>
1719
# include <boost/range/iterator_range.hpp>
1820
# include <boost/lexical_cast.hpp>
1921
# include <boost/optional.hpp>
22+
# include <boost/functional/hash_fwd.hpp>
2023

2124

2225
namespace boost {
@@ -36,14 +39,25 @@ class BOOST_URI_DECL uri {
3639
public:
3740

3841
typedef std::string string_type;
42+
typedef string_type::value_type value_type;
3943
typedef string_type::const_iterator const_iterator;
40-
typedef boost::iterator_range<std::string::const_iterator> const_range_type;
44+
typedef boost::iterator_range<const_iterator> const_range_type;
4145

4246
uri()
4347
: is_valid_(false) {
4448

4549
}
4650

51+
//uri(const value_type *uri)
52+
// : uri_(uri), is_valid_(false) {
53+
// parse();
54+
//}
55+
56+
uri(const string_type &uri)
57+
: uri_(uri), is_valid_(false) {
58+
parse();
59+
}
60+
4761
template <
4862
class FwdIter
4963
>
@@ -52,16 +66,9 @@ class BOOST_URI_DECL uri {
5266
parse();
5367
}
5468

55-
uri(const string_type &uri)
56-
: uri_(uri), is_valid_(false) {
57-
parse();
58-
}
59-
6069
uri(const uri &other)
61-
: uri_(other.uri_),
62-
uri_parts_(other.uri_parts_),
63-
is_valid_(other.is_valid_) {
64-
70+
: uri_(other.uri_) {
71+
parse();
6572
}
6673

6774
uri &operator = (uri other) {
@@ -70,9 +77,8 @@ class BOOST_URI_DECL uri {
7077
return *this;
7178
}
7279

73-
uri &operator = (const string_type &uri) {
74-
uri_ = uri;
75-
parse();
80+
uri &operator = (const string_type &uri_string) {
81+
uri(uri_string).swap(*this);
7682
return *this;
7783
}
7884

@@ -82,7 +88,8 @@ class BOOST_URI_DECL uri {
8288

8389
void swap(uri &other) {
8490
boost::swap(uri_, other.uri_);
85-
parse();
91+
boost::swap(uri_parts_, other.uri_parts_);
92+
boost::swap(is_valid_, other.is_valid_);
8693
}
8794

8895
const_iterator begin() const {
@@ -297,21 +304,59 @@ bool is_valid(const uri &uri_) {
297304
return valid(uri_);
298305
}
299306

307+
inline
308+
void swap(uri &lhs, uri &rhs) {
309+
lhs.swap(rhs);
310+
}
311+
312+
inline
313+
std::size_t hash_value(const uri &uri_)
314+
{
315+
std::size_t seed = 0;
316+
for (uri::const_iterator it = begin(uri_); it != end(uri_); ++it) {
317+
hash_combine(seed, *it);
318+
}
319+
return seed;
320+
}
321+
300322
inline
301323
bool operator == (const uri &lhs, const uri &rhs) {
302324
return boost::equal(lhs, rhs);
303325
}
304326

327+
inline
328+
bool operator == (const uri &lhs, const uri::string_type &rhs) {
329+
return boost::equal(lhs, rhs);
330+
}
331+
332+
inline
333+
bool operator == (const uri::string_type &lhs, const uri &rhs) {
334+
return boost::equal(lhs, rhs);
335+
}
336+
337+
inline
338+
bool operator == (const uri &lhs, const uri::value_type *rhs) {
339+
return boost::equal(lhs, boost::as_literal(rhs));
340+
}
341+
342+
inline
343+
bool operator == (const uri::value_type *lhs, const uri &rhs) {
344+
return boost::equal(boost::as_literal(lhs), rhs);
345+
}
346+
305347
inline
306348
bool operator != (const uri &lhs, const uri &rhs) {
307349
return !(lhs == rhs);
308350
}
309351

352+
inline
353+
bool operator < (const uri &lhs, const uri &rhs) {
354+
return lhs.string() < rhs.string();
355+
}
310356
} // namespace uri
311357
} // namespace network
312358
} // namespace boost
313359

314-
315360
# include <boost/network/uri/accessors.hpp>
316361
# include <boost/network/uri/directives.hpp>
317362
# include <boost/network/uri/builder.hpp>

libs/network/src/uri/parse.cpp renamed to boost/network/uri/uri.ipp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2009, 2010, 2011 Dean Michael Berris, Jeroen Habraken, Glyn Matthews.
1+
// Copyright 2009, 2010, 2011, 2012 Dean Michael Berris, Jeroen Habraken, Glyn Matthews.
22
// Distributed under the Boost Software License, Version 1.0.
33
// (See accompanying file LICENSE_1_0.txt or copy at
44
// http://www.boost.org/LICENSE_1_0.txt)

include/network/uri.hpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright (c) Glyn Matthews 2012.
2+
// Distributed under the Boost Software License, Version 1.0.
3+
// (See accompanying file LICENSE_1_0.txt or copy at
4+
// http://www.boost.org/LICENSE_1_0.txt)
5+
6+
7+
#ifndef __NETWORK_URI_INC__
8+
# define __NETWORK_URI_INC__
9+
10+
#include <network/uri/uri.hpp>
11+
#include <network/uri/uri_io.hpp>
12+
13+
#endif // __NETWORK_URI_INC__

0 commit comments

Comments
 (0)