Skip to content

Commit a59ed53

Browse files
committed
Merge pull request google#1 from cpp-netlib/0.11-devel
Update from original
2 parents addf968 + 01743e2 commit a59ed53

Some content is hidden

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

45 files changed

+346
-104
lines changed

.ycm_extra_conf.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
'/usr/include/c++/4.6',
2727
'-isystem',
2828
'/usr/include/clang/3.0/include',
29+
'-isystem',
30+
'/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/c++/v1',
2931
'-I',
3032
os.environ['BOOST_ROOT'],
3133
# Always enable debugging for the project when building for semantic

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_STATUS_MESSAGE_HPP_20100603
22
#define BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_STATUS_MESSAGE_HPP_20100603
33

4-
// Copyright 2010 (c) Dean Michael Berris
4+
// Copyright 2010 (c) Dean Michael Berris <dberris@google.com>
55
// Copyright 2010 (c) Sinefunc, Inc.
6+
// Copyright 2014 (c) Google, Inc.
67
// Distributed under the Boost Software License, Version 1.0.
78
// (See accompanying file LICENSE_1_0.txt or copy at
89
// http://www.boost.org/LICENSE_1_0.txt)
910

11+
#include <boost/network/traits/string.hpp>
12+
1013
namespace boost { namespace network { namespace http {
1114

1215
template <class Tag>
@@ -27,12 +30,19 @@ namespace boost { namespace network { namespace http {
2730
status_message_wrapper(status_message_wrapper const & other)
2831
: response_(other.response_) {}
2932

30-
operator string_type () {
33+
operator string_type () const {
3134
return response_.status_message();
3235
}
3336

3437
};
3538

39+
template <class Tag>
40+
inline std::ostream&
41+
operator<<(std::ostream& os,
42+
const status_message_wrapper<Tag>& wrapper) {
43+
return os << static_cast<typename string<Tag>::type>(wrapper);
44+
}
45+
3646
} // namespace impl
3747

3848
template <class Tag>

libs/network/doc/examples/http/hello_world_client.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ perform the request via HTTP:
8787
http::client client;
8888
http::client::request request("http://my.webservice.com/");
8989
http::client::response =
90-
client.post(request, "application/xml", some_xml_string);
90+
client.post(request, some_xml_string, "application/xml");
9191
std::data = body(response);
9292

9393
The next set of examples show some more practical applications using

libs/network/doc/getting_started.rst

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ the ``~/cpp-netlib`` directory exists, and is the top-level directory of the
114114
Building with CMake
115115
===================
116116

117-
To build the tests that come with cpp-netlib, we first need to configure the
117+
To build the tests that come with :mod:`cpp-netlib`, we first need to configure the
118118
build system to use our compiler of choice. This is done by running the
119119
``cmake`` command at the top-level directory of :mod:`cpp-netlib` with
120120
additional parameters::
@@ -131,6 +131,31 @@ additional parameters::
131131
For the purposes of documentation, we'll assume that all
132132
builds are done in ``~/cpp-netlib-build``.
133133

134+
If you intend to use the SSL support when using the HTTP client libraries in
135+
:mod:`cpp-netlib`, you may need to build it with OpenSSL_ installed or at least
136+
available to CMake. One example for building the library with OpenSSL_ support
137+
is by doing the following::
138+
139+
$ cmake -DCMAKE_BUILD_TYPE=Debug \
140+
> -DCMAKE_C_COMPILER=clang \
141+
> -DCMAKE_CXX_COMPILER=clang++ \
142+
> -DOPENSSL_ROOT_DIR=/Users/dberris/homebrew/Cellar/openssl/1.0.1f
143+
> ../cpp-netlib
144+
145+
.. _OpenSSL: http://www.openssl.org/
146+
147+
You can also use a different root directory for the Boost_ project by using the
148+
``-DBOOST_ROOT`` configuration option to CMake. This is useful if you intend to
149+
build the library with a specific version of Boost that you've built in a
150+
separate directory::
151+
152+
$ cmake -DCMAKE_BUILD_TYPE=Debug \
153+
> -DCMAKE_C_COMPILER=clang \
154+
> -DCMAKE_CXX_COMPILER=clang++ \
155+
> -DOPENSSL_ROOT_DIR=/Users/dberris/homebrew/Cellar/openssl/1.0.1f \
156+
> -DBOOST_ROOT=/Users/dberris/Source/boost_1_55_0
157+
> ../cpp-netlib
158+
134159
Building on Linux
135160
~~~~~~~~~~~~~~~~~
136161

@@ -178,8 +203,8 @@ Building On Windows
178203
~~~~~~~~~~~~~~~~~~~
179204

180205
If you're using the Microsoft Visual C++ compiler or the Microsoft Visual Studio
181-
IDE and you would like to build cpp-netlib from within Visual Studio, you can
182-
look for the solution and project files as the artifacts of the call to
206+
IDE and you would like to build :mod:`cpp-netlib` from within Visual Studio, you
207+
can look for the solution and project files as the artifacts of the call to
183208
``cmake`` -- the file should be named ``CPP-NETLIB.sln`` (the solution) along
184209
with a number of project files for Visual Studio.
185210

libs/network/doc/html/_sources/examples/http/hello_world_client.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ perform the request via HTTP:
8787
http::client client;
8888
http::client::request request("http://my.webservice.com/");
8989
http::client::response =
90-
client.post(request, "application/xml", some_xml_string);
90+
client.post(request, some_xml_string, "application/xml");
9191
std::data = body(response);
9292

9393
The next set of examples show some more practical applications using

libs/network/doc/html/_sources/getting_started.txt

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ the ``~/cpp-netlib`` directory exists, and is the top-level directory of the
114114
Building with CMake
115115
===================
116116

117-
To build the tests that come with cpp-netlib, we first need to configure the
117+
To build the tests that come with :mod:`cpp-netlib`, we first need to configure the
118118
build system to use our compiler of choice. This is done by running the
119119
``cmake`` command at the top-level directory of :mod:`cpp-netlib` with
120120
additional parameters::
@@ -131,6 +131,31 @@ additional parameters::
131131
For the purposes of documentation, we'll assume that all
132132
builds are done in ``~/cpp-netlib-build``.
133133

134+
If you intend to use the SSL support when using the HTTP client libraries in
135+
:mod:`cpp-netlib`, you may need to build it with OpenSSL_ installed or at least
136+
available to CMake. One example for building the library with OpenSSL_ support
137+
is by doing the following::
138+
139+
$ cmake -DCMAKE_BUILD_TYPE=Debug \
140+
> -DCMAKE_C_COMPILER=clang \
141+
> -DCMAKE_CXX_COMPILER=clang++ \
142+
> -DOPENSSL_ROOT_DIR=/Users/dberris/homebrew/Cellar/openssl/1.0.1f
143+
> ../cpp-netlib
144+
145+
.. _OpenSSL: http://www.openssl.org/
146+
147+
You can also use a different root directory for the Boost_ project by using the
148+
``-DBOOST_ROOT`` configuration option to CMake. This is useful if you intend to
149+
build the library with a specific version of Boost that you've built in a
150+
separate directory::
151+
152+
$ cmake -DCMAKE_BUILD_TYPE=Debug \
153+
> -DCMAKE_C_COMPILER=clang \
154+
> -DCMAKE_CXX_COMPILER=clang++ \
155+
> -DOPENSSL_ROOT_DIR=/Users/dberris/homebrew/Cellar/openssl/1.0.1f \
156+
> -DBOOST_ROOT=/Users/dberris/Source/boost_1_55_0
157+
> ../cpp-netlib
158+
134159
Building on Linux
135160
~~~~~~~~~~~~~~~~~
136161

@@ -178,8 +203,8 @@ Building On Windows
178203
~~~~~~~~~~~~~~~~~~~
179204

180205
If you're using the Microsoft Visual C++ compiler or the Microsoft Visual Studio
181-
IDE and you would like to build cpp-netlib from within Visual Studio, you can
182-
look for the solution and project files as the artifacts of the call to
206+
IDE and you would like to build :mod:`cpp-netlib` from within Visual Studio, you
207+
can look for the solution and project files as the artifacts of the call to
183208
``cmake`` -- the file should be named ``CPP-NETLIB.sln`` (the solution) along
184209
with a number of project files for Visual Studio.
185210

libs/network/doc/html/_sources/index.txt

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

44
.. :Authors: Glyn Matthews <glyn.matthews@gmail.com>
55
.. Dean Michael Berris <dberris@google.com>
6-
.. :Date: 2013-12-21
6+
.. :Date: 2014-10-01
77
.. :Version: 0.11.0
88
.. :Description: Complete user documentation, with examples, for the :mod:`cpp-netlib`.
99
.. :Copyright: Copyright Glyn Matthews, Dean Michael Berris 2008-2013.

libs/network/doc/html/_sources/reference/http_client.txt

Lines changed: 46 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,23 @@ asynchronous.
2525
As of 0.11 the `Synchronous Clients`_ are now *DEPRECATED* and will be removed
2626
in subsequent releases.
2727

28+
Features
29+
--------
30+
31+
The HTTP client implementation supports requesting secure HTTP (HTTPS) content
32+
only in the following situations:
33+
34+
* **Client libraries are built with ``BOOST_NETWORK_ENABLE_HTTPS``.** This
35+
tells the implementation to use HTTPS-specific code to handle HTTPS-based
36+
content when making connections associated with HTTPS URI's. This requires
37+
a dependency on OpenSSL_.
38+
* **The ``BOOST_NETWORK_ENABLE_HTTPS`` macro is set when compiling user
39+
code.** It is best to define this either at compile-time of all code using
40+
the library, or before including any of the client headers.
41+
42+
.. _OpenSSL: http://www.openssl.org/
43+
44+
2845
Implementations
2946
---------------
3047

@@ -71,7 +88,7 @@ behave as a fully synchronous client.
7188

7289
The synchronous client implements all the operations of the client underneath
7390
the interface all block to wait for I/O to finish. All the member methods are
74-
synchronous and will block until the response object is ready or throws if erros
91+
synchronous and will block until the response object is ready or throws if errors
7592
are encountered in the performance of the HTTP requests.
7693

7794
.. warning:: The synchronous clients are **NOT** thread safe. You will need to do
@@ -126,6 +143,9 @@ operations on responses. In code, usage should look like the following:
126143

127144
A common mistake is to declare the client inside the try block which invokes
128145
undefined behavior when errors arise from the handling of response objects.
146+
Previous examples cited by the documentation showed the short version of the
147+
code which didn't bother moving the ``http::client`` object outside of the same
148+
``try`` block where the request/response objects are being used.
129149

130150
Member Functions
131151
----------------
@@ -137,7 +157,7 @@ In this section we assume that the following typedef is in effect:
137157
typedef boost::network::http::basic_client<
138158
boost::network::http::tags::http_default_8bit_udp_resolve
139159
, 1
140-
,1
160+
, 1
141161
>
142162
client;
143163

@@ -290,6 +310,17 @@ and that there is an appropriately constructed response object named
290310
body chunks be handled by the ``callback`` parameter. The signature of
291311
``callback`` should be the following: ``void(iterator_range<char const *> const
292312
&, boost::system::error_code const &)``.
313+
``response_ = client_.post(request_, body, content_type, callback, streaming_callback)``
314+
The body and content_type parameters are of type
315+
``boost::network::string<Tag>::type`` where ``Tag`` is the HTTP Client's
316+
``Tag``. This uses the request object's other headers. Have the response
317+
body chunks be handled by the ``callback`` parameter. The signature of
318+
``callback`` should be the following: ``void(iterator_range<char const *> const
319+
&, boost::system::error_code const &)``. The ``streaming_callback``
320+
argument should have a which has a signature of the form:
321+
``bool(string_type&)``. The provided ``string_type&`` will be streamed as
322+
soon as the function returns. A return value of ``false`` signals the
323+
client that the most recent invocation is the last chunk to be sent.
293324
``response_ = client_.post(request_, streaming_callback)``
294325
Perform and HTTP POST request, and have the request's body chunks be
295326
generated by the ``streaming_callback`` which has a signature of the form:
@@ -329,13 +360,25 @@ and that there is an appropriately constructed response object named
329360
The body and content_type parameters are of type
330361
``boost::network::string<Tag>::type`` where ``Tag`` is the HTTP Client's
331362
``Tag``. This uses the request object's other headers.
332-
``response_ = client_.put(request_, body, content_type, body_handler=callback)``
363+
``response_ = client_.put(request_, body, content_type, callback)``
333364
The body and content_type parameters are of type
334365
``boost::network::string<Tag>::type`` where ``Tag`` is the HTTP Client's
335366
``Tag``. This uses the request object's other headers. Have the response
336367
body chunks be handled by the ``callback`` parameter. The signature of
337368
``callback`` should be the following: ``void(iterator_range<char const *> const
338369
&, boost::system::error_code const &)``.
370+
``response_ = client_.put(request_, body, content_type, callback, streaming_callback)``
371+
The body and content_type parameters are of type
372+
``boost::network::string<Tag>::type`` where ``Tag`` is the HTTP Client's
373+
``Tag``. This uses the request object's other headers. Have the response
374+
body chunks be handled by the ``callback`` parameter. The signature of
375+
``callback`` should be the following: ``void(iterator_range<char const *> const
376+
&, boost::system::error_code const &)``. This form also has the request's body
377+
chunks be generated by the ``streaming_callback`` which has a signature of
378+
the form: ``bool(string_type&)``. The provided ``string_type&`` will be
379+
streamed as soon as the function returns. A return value of ``false``
380+
signals the client that the most recent invocation is the last chunk to be
381+
sent
339382
``response_ = client_.put(request_, streaming_callback)``
340383
Perform and HTTP PUT request, and have the request's body chunks be
341384
generated by the ``streaming_callback`` which has a signature of the form:

libs/network/doc/html/contents.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ <h3>Navigation</h3>
187187
<li class="toctree-l1"><a class="reference internal" href="reference.html">Reference Manual</a><ul>
188188
<li class="toctree-l2"><a class="reference internal" href="reference/http_client.html">HTTP Client API</a><ul>
189189
<li class="toctree-l3"><a class="reference internal" href="reference/http_client.html#general">General</a></li>
190+
<li class="toctree-l3"><a class="reference internal" href="reference/http_client.html#features">Features</a></li>
190191
<li class="toctree-l3"><a class="reference internal" href="reference/http_client.html#implementations">Implementations</a><ul>
191192
<li class="toctree-l4"><a class="reference internal" href="reference/http_client.html#synchronous-clients">Synchronous Clients</a></li>
192193
<li class="toctree-l4"><a class="reference internal" href="reference/http_client.html#asynchronous-clients">Asynchronous Clients</a></li>
@@ -281,7 +282,7 @@ <h3>Navigation</h3>
281282
</div>
282283
<div class="footer">
283284
&copy; Copyright 2008-2014, Glyn Matthews, Dean Michael Berris; 2013 Google, Inc..
284-
Last updated on Aug 12, 2014.
285+
Last updated on Sep 01, 2014.
285286
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.2.2.
286287
</div>
287288
</body>

libs/network/doc/html/examples.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ <h3>Navigation</h3>
129129
</div>
130130
<div class="footer">
131131
&copy; Copyright 2008-2014, Glyn Matthews, Dean Michael Berris; 2013 Google, Inc..
132-
Last updated on Aug 12, 2014.
132+
Last updated on Sep 01, 2014.
133133
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.2.2.
134134
</div>
135135
</body>

0 commit comments

Comments
 (0)