Skip to content

Commit 7976b1d

Browse files
committed
Merge branch '0.9-devel' into http-client-refactoring
Conflicts: boost/network/protocol/http/algorithms/linearize.hpp boost/network/protocol/http/client/connection/async_normal.hpp boost/network/protocol/http/client/connection/ssl_delegate.ipp boost/network/protocol/http/message/wrappers/uri.hpp boost/network/uri/uri.hpp libs/network/test/CMakeLists.txt libs/network/test/http/CMakeLists.txt libs/network/test/uri/CMakeLists.txt
2 parents df8eb44 + fecb65b commit 7976b1d

File tree

333 files changed

+22950
-20575
lines changed

Some content is hidden

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

333 files changed

+22950
-20575
lines changed

CMakeLists.txt

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,37 +3,38 @@
33
# (See accompanying file LICENSE_1_0.txt or copy at
44
# http://www.boost.org/LICENSE_1_0.txt)
55

6-
cmake_minimum_required(VERSION 2.6)
6+
cmake_minimum_required(VERSION 2.8)
77
project(CPP-NETLIB)
8-
find_package( Boost 1.41.0 )
8+
set(Boost_USE_STATIC_LIBS ON)
9+
set(Boost_USE_MULTI_THREADED ON)
10+
find_package( Boost 1.45.0 REQUIRED unit_test_framework system regex date_time thread filesystem program_options )
911
find_package( OpenSSL )
1012
find_package( Threads )
1113
set(CMAKE_VERBOSE_MAKEFILE true)
1214

1315
if (CMAKE_BUILD_TYPE MATCHES Debug)
1416
add_definitions(-DBOOST_NETWORK_DEBUG)
1517
endif()
16-
if (Boost_FOUND)
17-
set(Boost_USE_STATIC_LIBS ON)
18-
set(Boost_USE_MULTI_THREADED ON)
19-
include_directories(${Boost_INCLUDE_DIRS})
20-
endif(Boost_FOUND)
21-
if (MSVC)
22-
add_definitions(-D_SCL_SECURE_NO_WARNINGS)
23-
endif(MSVC)
24-
if (WIN32)
25-
add_definitions(-D_WIN32_WINNT=0x0501)
26-
endif(WIN32)
27-
enable_testing()
2818

2919
if (OPENSSL_FOUND)
3020
add_definitions(-DBOOST_NETWORK_ENABLE_HTTPS)
3121
endif()
3222

33-
add_subdirectory(libs/network/src)
34-
add_subdirectory(libs/network/test)
35-
if (NOT MSVC)
36-
add_subdirectory(libs/mime/test)
37-
endif(NOT MSVC)
38-
add_subdirectory(libs/network/example)
23+
if (Boost_FOUND)
24+
if (MSVC)
25+
add_definitions(-D_SCL_SECURE_NO_WARNINGS)
26+
endif(MSVC)
27+
if (WIN32)
28+
add_definitions(-D_WIN32_WINNT=0x0501)
29+
endif(WIN32)
30+
include_directories(${Boost_INCLUDE_DIRS})
31+
enable_testing()
32+
add_subdirectory(libs/network/src)
33+
add_subdirectory(libs/network/test)
34+
if (NOT MSVC)
35+
add_subdirectory(libs/mime/test)
36+
endif(NOT MSVC)
37+
add_subdirectory(libs/network/example)
38+
endif(Boost_FOUND)
3939

40+
enable_testing()

README.rst

Lines changed: 27 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ cpp-netlib offers the following implementations:
1515
generate message objects from strings.
1616
* Adapters and Wrappers -- A collection of Adapters and wrappers aimed
1717
towards making the message type STL friendly.
18-
* Network protocol client and server implementations -- A collection
19-
of network protocol implementations that include embeddable client
18+
* Network protocol client and server implementations -- A collection
19+
of network protocol implementations that include embeddable client
2020
and server types.
2121

2222
This library is released under the Boost Software License (please see
@@ -33,44 +33,12 @@ You can find official release packages of the library at::
3333
Building and Installing
3434
-----------------------
3535

36-
Since cpp-netlib is a header-only library, there is nothing to build. To install
37-
cpp-netlib, you can choose to copy the contents of the ``boost`` directory into
38-
an existing Boost [#]_ distribution or to a different location. All that is
39-
required is for projects that use cpp-netlib when building, have the directory
40-
where cpp-netlib is installed as part of the include paths.
41-
42-
.. [#] http://www.boost.org/
43-
44-
The recommended installation procedure would be to follow the steps below::
45-
46-
# On Linux/Mac, consider the `$` character as the shell prompt
47-
$ sudo mkdir -p /usr/local/include/cpp-netlib
48-
$ sudo cp -r cpp-netlib/boost /usr/local/include/cpp-netlib
49-
50-
Now don't forget to add ``/usr/local/include/cpp-netlib`` in your project's
51-
compiler include directories to start using cpp-netlib in your projects.
52-
53-
Running Tests
54-
-------------
55-
56-
If you want to run the tests that come with cpp-netlib, there are a few things
57-
you will need. These are:
58-
59-
* A compiler (GCC 4.x or Clang 2.8)
60-
* A build tool (CMake [#]_ recommended, Boost.Build also an option)
61-
* OpenSSL headers (optional with CMake, mandatory for Boost.Build)
62-
* Python 2.6
63-
64-
.. note:: This assumes that you have the cpp-netlib distribution package
65-
unpacked somwhere in your home directory. This specifically assumes that you
66-
have cpp-netlib at the toplevel of your home directory.
67-
.. [#] http://www.cmake.org/
68-
6936
Building with CMake
7037
~~~~~~~~~~~~~~~~~~~
7138

72-
To build and run the tests with CMake, you will need to have CMake version 2.8
73-
or higher installed appropriately in your system.
39+
To build the libraries and run the tests with CMake, you will need to
40+
have CMake version 2.8 or higher installed appropriately in your
41+
system.
7442

7543
::
7644

@@ -81,16 +49,11 @@ Inside the cpp-netlib directory, you can issue the following statements to
8149
configure and generate the Makefiles, and build the tests::
8250

8351
$ cd ~/cpp-netlib # we're assuming it's where cpp-netlib is
84-
$ cmake -DCMAKE_BUILD_TYPE=Debug \
85-
> -CMAKE_C_COMPILER=clang \
86-
> -CMAKE_CXX_COMPILER=clang++ \
52+
$ cmake -DCMAKE_BUILD_TYPE=Debug \
53+
> -DCMAKE_C_COMPILER=clang \
54+
> -DCMAKE_CXX_COMPILER=clang++ \
8755
> .
8856

89-
.. note:: This uses the source directory as the build directory as well. At the
90-
time of this writing, cpp-netlib is meant to be tested in the same directory
91-
where the source files are, because of the way the tests depend on Python
92-
being installed and having access to Python scripts during the build.
93-
9457
Once CMake is done with generating the Makefiles and configuring the project,
9558
you can now build the tests and run them::
9659

@@ -102,7 +65,7 @@ If for some reason some of the tests fail, you can send the files in
10265
``Testing/Temporary/`` as attachments to the cpp-netlib `developers mailing
10366
list`_.
10467

105-
.. _`developers mailing list`: https://lists.sourceforge.net/lists/listinfo/cpp-netlib-devel
68+
.. _`developers mailing list`: cpp-netlib@googlegroups.com
10669

10770
Building with Boost.Build
10871
~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -113,7 +76,7 @@ to copy the ``bjam`` executable to a directory that is already in your ``PATH``
11376
so that you don't have to go hunting for it all the time. A good place to put it
11477
is in ``/usr/local/bin``.
11578

116-
.. [#] http://www.boost.org/doc/libs/1_44_0/more/getting_started/index.html
79+
.. [#] http://www.boost.org/doc/libs/release/more/getting_started/
11780
11881
Building and running the tests can be as simple as doing the following::
11982

@@ -130,7 +93,21 @@ please do the following::
13093
And then attach the ``build-test.log`` file to the email you will send to the
13194
cpp-netlib `developers mailing list`_.
13295

133-
.. _`developers mailing list`: https://lists.sourceforge.net/lists/listinfo/cpp-netlib-devel
96+
.. _`developers mailing list`: cpp-netlib@googlegroups.com
97+
98+
Running Tests
99+
-------------
100+
101+
If you want to run the tests that come with cpp-netlib, there are a few things
102+
you will need. These are:
103+
104+
* A compiler (GCC 4.x, Clang 2.8, MSVC 2008)
105+
* A build tool (CMake [#]_ recommended, Boost.Build also an option)
106+
* OpenSSL headers (optional)
107+
108+
.. note:: This assumes that you have cpp-netlib at the top-level of
109+
your home directory.
110+
[#] http://www.cmake.org/
134111

135112
Hacking on cpp-netlib
136113
---------------------
@@ -174,14 +151,10 @@ In case you have any questions or would like to make feature requests, you can
174151
contact the development team through the `developers mailing list`_
175152
or by filing issues at http://github.com/cpp-netlib/cpp-netlib/issues.
176153

177-
.. _`developers mailing list`:
178-
https://lists.sourceforge.net/lists/listinfo/cpp-netlib-devel
154+
.. _`developers mailing list`: cpp-netlib@googlegroups.com
179155

180156
You can reach the maintainers of the project through::
181157

182158
Dean Michael Berris (dberris@google.com)
183159

184-
Glyn Matthews
185-
186-
Mike Dickey
187-
160+
Glyn Matthews (glyn.matthews@gmail.com)

boost/mime.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,7 @@ class basic_mime {
658658
void check_subpart_index ( size_t idx ) const {
659659
if ( get_part_kind () == simple_part )
660660
throw std::runtime_error ( "Simple Mime parts don't have sub-parts" );
661-
else if ( get_part_kind == multi_part ) {
661+
else if ( get_part_kind () == multi_part ) {
662662
if ( idx >= m_subparts.size ())
663663
throw std::runtime_error (
664664
str ( boost::format ( "Trying to access part %d (of %d) sub-part to a multipart/xxx mime part" ) % idx % m_subparts.size ()));

boost/network/protocol/http/algorithms/linearize.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,4 +151,3 @@ namespace boost { namespace network { namespace http {
151151
} /* boost */
152152

153153
#endif /* BOOST_NETWORK_PROTOCOL_HTTP_ALGORITHMS_LINEARIZE_HPP_20101028 */
154-

boost/network/protocol/http/client/connection/ssl_delegate.ipp

100644100755
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ void boost::network::http::ssl_delegate::connect(
3333
socket_.reset(new asio::ssl::stream<asio::ip::tcp::socket>(service_, *context_));
3434
socket_->lowest_layer().async_connect(
3535
endpoint,
36-
bind(&boost::network::http::ssl_delegate::handle_connected,
37-
boost::network::http::ssl_delegate::shared_from_this(),
36+
::boost::bind(&boost::network::http::impl::ssl_delegate::handle_connected,
37+
boost::network::http::impl::ssl_delegate::shared_from_this(),
3838
asio::placeholders::error,
3939
handler));
4040
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ namespace boost { namespace network { namespace http { namespace impl {
148148
} else {
149149
bool stopping_inner = false;
150150
do {
151-
std::size_t chunk_bytes_read = read(socket_, response_buffer, boost::asio::transfer_at_least(chunk_size + 2), error);
151+
std::size_t chunk_bytes_read = read(socket_, response_buffer, boost::asio::transfer_at_least(chunk_size), error);
152152
if (chunk_bytes_read == 0) {
153153
if (error != boost::asio::error::eof) throw boost::system::system_error(error);
154154
stopping_inner = true;

boost/network/protocol/http/client/macros.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
#ifndef BOOST_NETWORK_HTTP_BODY_CALLBACK
1313
#define BOOST_NETWORK_HTTP_BODY_CALLBACK(function_name, range_name, error_name) \
14-
void function_name (boost::iterator_range<char*> const & range_name, boost::system::error_code const & error_name)
14+
void function_name (boost::iterator_range<const char*> const & range_name, boost::system::error_code const & error_name)
1515
#endif
1616

1717
#endif /* BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_MACROS_HPP_20110430 */

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

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
#include <boost/network/uri/uri.hpp>
1919
#include <boost/network/traits/vector.hpp>
20+
#include <boost/network/constants.hpp>
2021

2122
#include <boost/network/protocol/http/message/async_message.hpp>
2223
#include <boost/network/support/is_async.hpp>
@@ -50,7 +51,7 @@ namespace http {
5051
struct basic_request : public basic_message<Tag>
5152
{
5253

53-
mutable boost::network::uri::basic_uri<typename string<Tag>::type> uri_;
54+
mutable boost::network::uri::uri uri_;
5455
typedef basic_message<Tag> base_type;
5556

5657
public:
@@ -62,10 +63,18 @@ namespace http {
6263
: uri_(uri_)
6364
{ }
6465

66+
explicit basic_request(boost::network::uri::uri const & uri_)
67+
: uri_(uri_)
68+
{ }
69+
6570
void uri(string_type const & new_uri) {
6671
uri_ = new_uri;
6772
}
6873

74+
void uri(boost::network::uri::uri const & new_uri) {
75+
uri_ = new_uri;
76+
}
77+
6978
basic_request()
7079
: base_type()
7180
{ }
@@ -95,7 +104,7 @@ namespace http {
95104
if (!port)
96105
{
97106
typedef constants<Tag> consts;
98-
return boost::iequals(uri_.scheme_range(),
107+
return boost::iequals(uri_.scheme(),
99108
string_type(consts::https()))? 443 : 80;
100109
}
101110
return *port;
@@ -121,7 +130,7 @@ namespace http {
121130
uri_ = new_uri;
122131
}
123132

124-
boost::network::uri::basic_uri<typename string<Tag>::type> const & uri() const {
133+
boost::network::uri::uri const & uri() const {
125134
return uri_;
126135
}
127136

boost/network/uri/accessors.hpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -45,58 +45,58 @@ template <
4545
>
4646
inline
4747
Map &query_map(const uri &uri_, Map &map) {
48-
uri::const_range_type range = uri_.query_range();
48+
const std::string range = uri_.query();
4949
details::key_value_sequence<Map> parser;
5050
spirit::qi::parse(boost::begin(range), boost::end(range), parser, map);
5151
return map;
5252
}
5353

5454
inline
5555
std::string username(const uri &uri_) {
56-
uri::const_range_type user_info_range = uri_.user_info_range();
57-
uri::const_iterator it(boost::begin(user_info_range)), end(boost::end(user_info_range));
56+
const std::string user_info = uri_.user_info();
57+
uri::const_iterator it(boost::begin(user_info)), end(boost::end(user_info));
5858
for (; it != end; ++it) {
5959
if (*it == ':') {
6060
break;
6161
}
6262
}
63-
return std::string(boost::begin(user_info_range), it);
63+
return std::string(boost::begin(user_info), it);
6464
}
6565

6666
inline
6767
std::string password(const uri &uri_) {
68-
uri::const_range_type user_info_range = uri_.user_info_range();
69-
uri::const_iterator it(boost::begin(user_info_range)), end(boost::end(user_info_range));
68+
const std::string user_info = uri_.user_info();
69+
uri::const_iterator it(boost::begin(user_info)), end(boost::end(user_info));
7070
for (; it != end; ++it) {
7171
if (*it == ':') {
7272
++it;
7373
break;
7474
}
7575
}
76-
return std::string(it, boost::end(user_info_range));
76+
return std::string(it, boost::end(user_info));
7777
}
7878

7979
inline
8080
std::string decoded_path(const uri &uri_) {
81-
uri::const_range_type path_range = uri_.path_range();
81+
const std::string path = uri_.path();
8282
std::string decoded_path;
83-
decode(path_range, std::back_inserter(decoded_path));
83+
decode(path, std::back_inserter(decoded_path));
8484
return decoded_path;
8585
}
8686

8787
inline
8888
std::string decoded_query(const uri &uri_) {
89-
uri::const_range_type query_range = uri_.query_range();
89+
const std::string query = uri_.query();
9090
std::string decoded_query;
91-
decode(query_range, std::back_inserter(decoded_query));
91+
decode(query, std::back_inserter(decoded_query));
9292
return decoded_query;
9393
}
9494

9595
inline
9696
std::string decoded_fragment(const uri &uri_) {
97-
uri::const_range_type fragment_range = uri_.fragment_range();
97+
const std::string fragment = uri_.fragment();
9898
std::string decoded_fragment;
99-
decode(fragment_range, std::back_inserter(decoded_fragment));
99+
decode(fragment, std::back_inserter(decoded_fragment));
100100
return decoded_fragment;
101101
}
102102
} // namespace uri

boost/network/uri/decode.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,13 @@ OutputIterator decode(const SinglePassRange &range,
9393
const OutputIterator &out) {
9494
return decode(boost::begin(range), boost::end(range), out);
9595
}
96+
97+
inline
98+
std::string decoded(const std::string &input) {
99+
std::string decoded;
100+
decode(input, std::back_inserter(decoded));
101+
return decoded;
102+
}
96103
} // namespace uri
97104
} // namespace network
98105
} // namespace boost

0 commit comments

Comments
 (0)