Skip to content

Commit 4879bbd

Browse files
committed
Merge branch '0.7-devel' of github.com:mikhailberis/cpp-netlib into origin/0.7-devel
2 parents 2e18f32 + 363ccf7 commit 4879bbd

Some content is hidden

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

90 files changed

+1480
-2666
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/protocol/http/impl/http_async_connection.hpp

Lines changed: 34 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,7 @@ namespace boost { namespace network { namespace http { namespace impl {
253253
version.append(boost::begin(result_range), boost::end(result_range));
254254
algorithm::trim(version);
255255
version_promise.set_value(version);
256-
typename buffer_type::const_iterator end = part.end();
257-
std::copy(boost::end(result_range), end, part.begin());
256+
part_begin = boost::end(result_range);
258257
this->parse_status();
259258
} else if (parsed_ok == false) {
260259
std::runtime_error error("Invalid Version Part.");
@@ -267,9 +266,10 @@ namespace boost { namespace network { namespace http { namespace impl {
267266
body_promise.set_exception(boost::copy_exception(error));
268267
} else {
269268
partial_parsed.append(
270-
part.begin(),
271-
part.end()
269+
boost::begin(result_range),
270+
boost::end(result_range)
272271
);
272+
part_begin = part.begin();
273273
boost::asio::async_read(
274274
*socket_,
275275
boost::asio::mutable_buffers_1(part.c_array(), part.size()),
@@ -298,19 +298,20 @@ namespace boost { namespace network { namespace http { namespace impl {
298298

299299
void parse_status() {
300300
logic::tribool parsed_ok;
301-
typename boost::iterator_range<typename buffer_type::const_iterator> result_range;
301+
typename buffer_type::const_iterator part_end = part.end();
302+
typename boost::iterator_range<typename buffer_type::const_iterator> result_range,
303+
input_range = boost::make_iterator_range(part_begin, part_end);
302304
fusion::tie(parsed_ok, result_range) = response_parser_.parse_until(
303305
response_parser_type::http_status_done,
304-
part);
306+
input_range);
305307
if (parsed_ok == true) {
306308
string_type status;
307309
std::swap(status, partial_parsed);
308310
status.append(boost::begin(result_range), boost::end(result_range));
309311
trim(status);
310312
boost::uint16_t status_int = lexical_cast<boost::uint16_t>(status);
311313
status_promise.set_value(status_int);
312-
typename buffer_type::const_iterator end = part.end();
313-
std::copy(boost::end(result_range), end, part.begin());
314+
part_begin = boost::end(result_range);
314315
this->parse_status_message();
315316
} else if (parsed_ok == false) {
316317
std::runtime_error error("Invalid status part.");
@@ -321,7 +322,11 @@ namespace boost { namespace network { namespace http { namespace impl {
321322
destination_promise.set_exception(boost::copy_exception(error));
322323
body_promise.set_exception(boost::copy_exception(error));
323324
} else {
324-
partial_parsed.append(part.begin(), part.end());
325+
partial_parsed.append(
326+
boost::begin(result_range),
327+
boost::end(result_range)
328+
);
329+
part_begin = part.begin();
325330
boost::asio::async_read(*socket_,
326331
boost::asio::mutable_buffers_1(part.c_array(), part.size()),
327332
request_strand_->wrap(
@@ -348,18 +353,19 @@ namespace boost { namespace network { namespace http { namespace impl {
348353

349354
void parse_status_message() {
350355
logic::tribool parsed_ok;
351-
typename boost::iterator_range<typename buffer_type::const_iterator> result_range;
356+
typename buffer_type::const_iterator part_end = part.end();
357+
typename boost::iterator_range<typename buffer_type::const_iterator> result_range,
358+
input_range = boost::make_iterator_range(part_begin, part_end);
352359
fusion::tie(parsed_ok, result_range) = response_parser_.parse_until(
353360
response_parser_type::http_status_message_done,
354-
part);
361+
input_range);
355362
if (parsed_ok == true) {
356363
string_type status_message;
357364
std::swap(status_message, partial_parsed);
358365
status_message.append(boost::begin(result_range), boost::end(result_range));
359366
algorithm::trim(status_message);
360367
status_message_promise.set_value(status_message);
361-
typename buffer_type::const_iterator end = part.end();
362-
std::copy(boost::end(result_range), end, part.c_array());
368+
part_begin = boost::end(result_range);
363369
this->parse_headers();
364370
} else if (parsed_ok == false) {
365371
std::runtime_error error("Invalid status message part.");
@@ -369,7 +375,10 @@ namespace boost { namespace network { namespace http { namespace impl {
369375
destination_promise.set_exception(boost::copy_exception(error));
370376
body_promise.set_exception(boost::copy_exception(error));
371377
} else {
372-
partial_parsed.append(part.begin(), part.end());
378+
partial_parsed.append(
379+
boost::begin(result_range),
380+
boost::end(result_range));
381+
part_begin = part.begin();
373382
boost::asio::async_read(
374383
*socket_,
375384
boost::asio::mutable_buffers_1(part.c_array(), part.size()),
@@ -433,22 +442,24 @@ namespace boost { namespace network { namespace http { namespace impl {
433442

434443
void parse_headers() {
435444
logic::tribool parsed_ok;
436-
typename boost::iterator_range<typename buffer_type::const_iterator> result_range;
445+
typename buffer_type::const_iterator part_end = part.end();
446+
typename boost::iterator_range<typename buffer_type::const_iterator> result_range,
447+
input_range = boost::make_iterator_range(part_begin, part_end);
437448
fusion::tie(parsed_ok, result_range) = response_parser_.parse_until(
438449
response_parser_type::http_headers_done,
439-
part);
450+
input_range);
440451
if (parsed_ok == true) {
441452
string_type headers_string;
442453
std::swap(headers_string, partial_parsed);
443454
headers_string.append(boost::begin(result_range), boost::end(result_range));
444-
typename buffer_type::const_iterator end = part.end();
445-
std::copy(boost::end(result_range), end, part.begin());
455+
part_begin = boost::end(result_range);
446456
this->parse_headers_real(headers_string);
447-
this->parse_body(std::distance(boost::end(result_range), end));
457+
this->parse_body(std::distance(boost::end(result_range), part_end));
448458
} else if (parsed_ok == false) {
449459
std::runtime_error error("Invalid header part.");
450460
} else {
451-
partial_parsed.append(part.begin(), part.end());
461+
partial_parsed.append(boost::begin(result_range), boost::end(result_range));
462+
part_begin = part.begin();
452463
boost::asio::async_read(
453464
*socket_,
454465
boost::asio::mutable_buffers_1(part.c_array(), part.size()),
@@ -473,7 +484,8 @@ namespace boost { namespace network { namespace http { namespace impl {
473484
}
474485

475486
void parse_body(size_t bytes) {
476-
partial_parsed.append(part.begin(), bytes);
487+
partial_parsed.append(part_begin, bytes);
488+
part_begin = part.begin();
477489
boost::asio::async_read(*socket_, boost::asio::mutable_buffers_1(part.c_array(), part.size()),
478490
request_strand_->wrap(
479491
boost::bind(
@@ -524,6 +536,7 @@ namespace boost { namespace network { namespace http { namespace impl {
524536
string_type command_string_;
525537
response_parser_type response_parser_;
526538
buffer_type part;
539+
typename buffer_type::const_iterator part_begin;
527540
string_type partial_parsed;
528541
string_type method;
529542
};

boost/network/tags.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ namespace boost { namespace network { namespace tags {
3838
template <class Tag>
3939
struct components;
4040

41+
// FIXME make this a preprocessor macro!
4142
typedef mpl::inherit_linearly<
4243
http_default_8bit_tcp_resolve_tags,
4344
mpl::inherit<mpl::placeholders::_1, mpl::placeholders::_2>

libs/network/doc/.gitignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

libs/network/doc/CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Copyright (c) Glyn Matthews 2010.
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+
8+
# find "sphinxtogithub"
9+
# generate conf.py using release, sphinxtogithub, todo, style, theme

0 commit comments

Comments
 (0)