Skip to content

Commit 9f44859

Browse files
committed
Merge branch '0.7-devel' of git://github.com/mikhailberis/cpp-netlib into 0.7-devel
2 parents 9b271d0 + 79e695d commit 9f44859

25 files changed

+864
-234
lines changed

README.rst

Lines changed: 192 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,192 @@
1+
C++ Network Library
2+
===================
3+
4+
Introduction
5+
------------
6+
7+
cpp-netlib is a collection of network related routines/implementations
8+
geared towards providing a robust cross-platform networking library.
9+
cpp-netlib offers the following implementations:
10+
11+
* Common Message Type -- A generic message type which can be used
12+
to encapsulate and store message related information, used by all
13+
network implementations as the primary means of data exchange.
14+
* Network protocol message parsers -- A collection of parsers which
15+
generate message objects from strings.
16+
* Adapters and Wrappers -- A collection of Adapters and wrappers aimed
17+
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
20+
and server types.
21+
22+
This library is released under the Boost Software License (please see
23+
http://boost.org/LICENSE_1_0.txt or the accompanying LICENSE_1_0.txt file
24+
for the full text.
25+
26+
Downloading cpp-netlib
27+
----------------------
28+
29+
You can find official release packages of the library at::
30+
31+
http://github.com/cpp-netlib/cpp-netlib/downloads
32+
33+
Building and Installing
34+
-----------------------
35+
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+
69+
Building with CMake
70+
~~~~~~~~~~~~~~~~~~~
71+
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.
74+
75+
::
76+
77+
$ cmake --version
78+
cmake version 2.8.1
79+
80+
Inside the cpp-netlib directory, you can issue the following statements to
81+
configure and generate the Makefiles, and build the tests::
82+
83+
$ 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++ \
87+
> .
88+
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+
94+
Once CMake is done with generating the Makefiles and configuring the project,
95+
you can now build the tests and run them::
96+
97+
$ cd ~/cpp-netlib
98+
$ make
99+
$ make test
100+
101+
If for some reason some of the tests fail, you can send the files in
102+
``Testing/Temporary/`` as attachments to the cpp-netlib `developers mailing
103+
list`_.
104+
105+
.. _`developers mailing list`: https://lists.sourceforge.net/lists/listinfo/cpp-netlib-devel
106+
107+
Building with Boost.Build
108+
~~~~~~~~~~~~~~~~~~~~~~~~~
109+
110+
If you don't already have Boost.Build set up on your system, follow the steps
111+
indicated in the Boost Getting Started Guide [#]_ -- you will particularly want
112+
to copy the ``bjam`` executable to a directory that is already in your ``PATH``
113+
so that you don't have to go hunting for it all the time. A good place to put it
114+
is in ``/usr/local/bin``.
115+
116+
.. [#] http://www.boost.org/doc/libs/1_44_0/more/getting_started/index.html
117+
118+
Building and running the tests can be as simple as doing the following::
119+
120+
$ cd ~/cpp-netlib
121+
$ bjam
122+
123+
Doing this will already build all the tests and run them as they are built. In
124+
case you encounter any problems and would like to report it to the developers,
125+
please do the following::
126+
127+
$ cd ~/cpp-netlib
128+
$ bjam 2>&1 >build-test.log
129+
130+
And then attach the ``build-test.log`` file to the email you will send to the
131+
cpp-netlib `developers mailing list`_.
132+
133+
.. _`developers mailing list`: https://lists.sourceforge.net/lists/listinfo/cpp-netlib-devel
134+
135+
Hacking on cpp-netlib
136+
---------------------
137+
138+
cpp-netlib is being developed with the git_ distributed SCM system.
139+
cpp-netlib is hosted on GitHub_ following the GitHub recommended practice of
140+
forking the repository and submitting pull requests to the source repository.
141+
You can read more about the forking_ process and submitting `pull requests`_ if
142+
you're not familiar with either process yet.
143+
144+
.. _git: http://git-scm.com/
145+
.. _GitHub: http://github.com/
146+
.. _forking: http://help.github.com/forking/
147+
.. _`pull requests`: http://help.github.com/pull-requests/
148+
149+
Because cpp-netlib is released under the `Boost Software License`_ it is
150+
recommended that any file you make changes to bear your copyright notice
151+
alongside the original authors' copyright notices on the file. Typically the
152+
copyright notices are at the top of each file in the project.
153+
154+
.. _`Boost Software License`: http://www.boost.org/LICENSE_1_0.txt
155+
156+
At the time of writing, there are no coding conventions being followed but if
157+
you write in the general style that is already existing in the project that
158+
would be greatly appreciated. Copious amounts of comments will be called out,
159+
but code that is not self-explanatory typically at least requires a rationale
160+
documentation in comments explaining "why" the code is written that way.
161+
162+
The main "upstream" repository is the one hosted by the original maintainer of
163+
the project (Dean Michael Berris) at http://github.com/mikhailberis/cpp-netlib.
164+
The "official" release repository is maintained at
165+
http://github.com/cpp-netlib/cpp-netlib -- which is a fork of the upstream
166+
repository. It is recommended that forks be made against the upstream repostory
167+
and pull requests be submitted against the upstream repository so that patches
168+
and other implementations can be curated by the original maintainer.
169+
170+
Contact and Commercial Support
171+
------------------------------
172+
173+
In case you have any questions or would like to make feature requests, you can
174+
contact the development team through the `developers mailing list`_
175+
or by filing issues at http://github.com/mikhailberis/cpp-netlib/issues.
176+
177+
.. _`developers mailing list`:
178+
https://lists.sourceforge.net/lists/listinfo/cpp-netlib-devel
179+
180+
You can reach the maintainers of the project through::
181+
182+
Dean Michael Berris
183+
mikhailberis@gmail.com
184+
185+
Glyn Matthews
186+
187+
Mike Dickey
188+
189+
At this time, paid commercial support is available for cpp-netlib being offered
190+
by the maintainers. In case you have any questions, please feel free to contact
191+
any one of the maintainers above or anybody on the developers mailing list.
192+

README.txt

Lines changed: 0 additions & 22 deletions
This file was deleted.

boost/network/message/directives/source.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
#include <boost/network/message/directives/detail/string_directive.hpp>
1111
#include <boost/network/message/directives/detail/string_value.hpp>
1212

13+
#include <boost/network/support/is_default_string.hpp>
14+
1315
namespace boost { namespace network {
1416

1517
namespace impl {
@@ -26,8 +28,8 @@ namespace boost { namespace network {
2628
void operator()(typename detail::string_value<typename Message::tag>::type const & source) const {
2729
message_.source(source);
2830
}
29-
template <class T> void operator()(T const &) const {
30-
// FIXME -- fail here!
31+
template <class T> void operator()(T const & source) const {
32+
// fail at compile time?
3133
}
3234
};
3335

boost/network/protocol/http/client.hpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@
2626
#include <boost/network/protocol/http/client/facade.hpp>
2727
#include <boost/network/protocol/http/client/pimpl.hpp>
2828

29+
#include <boost/network/support/sync_only.hpp>
30+
31+
2932
namespace boost { namespace network { namespace http {
3033

3134
template <class Tag, unsigned version_major, unsigned version_minor>
@@ -36,7 +39,7 @@ namespace boost { namespace network { namespace http {
3639
typedef basic_client_impl<Tag,version_major,version_minor> pimpl_type;
3740
typedef basic_client_facade<Tag, basic_client<Tag,version_major,version_minor> > base_facade_type;
3841
public:
39-
typedef basic_request<Tag> request;
42+
typedef basic_request<typename sync_only<Tag>::type> request;
4043
typedef basic_response<Tag> response;
4144
typedef typename string<Tag>::type string_type;
4245
typedef Tag tag_type;
@@ -87,7 +90,7 @@ namespace boost { namespace network { namespace http {
8790

8891
friend struct basic_client_facade<Tag,basic_client<Tag,version_major,version_minor> > ;
8992

90-
basic_response<Tag> const request_skeleton(basic_request<Tag> const & request_, string_type method, bool get_body) {
93+
basic_response<Tag> const request_skeleton(request const & request_, string_type method, bool get_body) {
9194
return pimpl->request_skeleton(request_, method, get_body);
9295
}
9396

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <boost/asio/strand.hpp>
1111
#include <boost/thread/thread.hpp>
1212
#include <boost/bind.hpp>
13+
#include <boost/network/support/sync_only.hpp>
1314

1415
namespace boost { namespace network { namespace http {
1516

@@ -47,15 +48,15 @@ namespace boost { namespace network { namespace http {
4748
)));
4849
}
4950

50-
~async_client()
51+
~async_client() throw ()
5152
{
5253
sentinel_.reset();
5354
lifetime_thread_->join();
5455
lifetime_thread_.reset();
5556
}
5657

5758
basic_response<Tag> const request_skeleton(
58-
basic_request<Tag> const & request_,
59+
basic_request<typename sync_only<Tag>::type> const & request_,
5960
string_type const & method,
6061
bool get_body
6162
)

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

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

99
#include <boost/network/protocol/http/request.hpp>
1010
#include <boost/network/protocol/http/response.hpp>
11+
#include <boost/network/support/sync_only.hpp>
1112

1213
namespace boost { namespace network { namespace http {
1314

@@ -21,7 +22,7 @@ namespace boost { namespace network { namespace http {
2122
struct basic_client_facade {
2223

2324
typedef typename string<Tag>::type string_type;
24-
typedef basic_request<Tag> request;
25+
typedef basic_request<typename sync_only<Tag>::type> request;
2526
typedef basic_response<Tag> response;
2627

2728
basic_client_facade()

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
#include <boost/network/protocol/http/traits/connection_policy.hpp>
1717
#include <boost/network/protocol/http/client/async_impl.hpp>
18+
#include <boost/network/support/sync_only.hpp>
1819

1920
namespace boost { namespace network { namespace http {
2021

@@ -46,7 +47,7 @@ namespace boost { namespace network { namespace http {
4647

4748
~sync_client() {}
4849

49-
basic_response<Tag> const request_skeleton(basic_request<Tag> const & request_, string_type method, bool get_body) {
50+
basic_response<Tag> const request_skeleton(basic_request<typename sync_only<Tag>::type> const & request_, string_type method, bool get_body) {
5051
typename connection_base::connection_ptr connection_;
5152
connection_ = connection_base::get_connection(resolver_, request_);
5253
return connection_->send_request(method, request_, get_body);

boost/network/protocol/http/detail/connection_helper.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <boost/network/protocol/http/traits/connection_keepalive.hpp>
1212
#include <boost/asio/streambuf.hpp>
1313
#include <boost/network/traits/string.hpp>
14+
#include <boost/network/support/sync_only.hpp>
1415

1516
namespace boost { namespace network { namespace http { namespace detail {
1617

@@ -20,7 +21,7 @@ namespace boost { namespace network { namespace http { namespace detail {
2021

2122
typedef typename string<Tag>::type string_type;
2223

23-
void create_request(boost::asio::streambuf & request_buffer, string_type const & method, basic_request<Tag> request_) const {
24+
void create_request(boost::asio::streambuf & request_buffer, string_type const & method, basic_request<typename sync_only<Tag>::type> request_) const {
2425
// TODO make this use Boost.Karma instead of an ad-hoc implementation
2526
std::ostream request_stream(&request_buffer);
2627

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ namespace boost { namespace network { namespace http { namespace impl {
2121
typedef typename resolver_base::resolver_type resolver_type;
2222
typedef typename resolver_base::resolve_function resolve_function;
2323
typedef typename string<Tag>::type string_type;
24-
typedef basic_request<Tag> request;
24+
typedef basic_request<typename sync_only<Tag>::type> request;
2525
typedef basic_response<Tag> response;
2626

27-
static async_connection_base<Tag,version_major,version_minor> * new_connection(resolve_function resolve, boost::shared_ptr<resolver_type> resolver, bool follow_redirect, bool https) {
27+
static boost::shared_ptr<async_connection_base<Tag,version_major,version_minor> > new_connection(resolve_function resolve, boost::shared_ptr<resolver_type> resolver, bool follow_redirect, bool https) {
2828
if (https) {
2929
#ifdef BOOST_NETWORK_ENABLE_HTTPS
3030
// FIXME fill this up with the HTTPS implementation.
@@ -33,7 +33,10 @@ namespace boost { namespace network { namespace http { namespace impl {
3333
throw std::runtime_error("HTTPS not supported.");
3434
#endif
3535
}
36-
return dynamic_cast<async_connection_base<Tag,version_major,version_minor>*>(new http_async_connection<Tag,version_major,version_minor>(resolver, resolve, follow_redirect));
36+
boost::shared_ptr<async_connection_base<Tag,version_major,version_minor> > temp;
37+
temp.reset(new http_async_connection<Tag,version_major,version_minor>(resolver, resolve, follow_redirect));
38+
assert(temp.get() != 0);
39+
return temp;
3740
}
3841

3942
virtual response start(request const & request, string_type const & method, bool get_body) = 0;

0 commit comments

Comments
 (0)