Skip to content

Commit b3c3471

Browse files
committed
Updating reference on options.
1 parent 3dc98b6 commit b3c3471

File tree

2 files changed

+89
-96
lines changed

2 files changed

+89
-96
lines changed

libs/network/doc/reference/http_client.rst

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -139,37 +139,35 @@ initialization.
139139

140140
``client()``
141141
Default constructor.
142-
``client(boost::asio::io_service & io_service)``
143-
Construct a client to use an existing Boost.Asio ``io_service`` instance.
144-
``template <class ArgPack> client(ArgPack const & args)``
145-
Pass in an argument pack. See supported parameters in the table below.
142+
``explicit client(client::options const &)``
143+
Constructor taking a ``client_options<Tag>`` object. The following table
144+
shows the options you can set on a ``client_options<Tag>`` instance.
146145

147146
+----------------------+-------------------------------+-------------------------+
148147
| Parameter Name | Type | Description |
149148
+======================+===============================+=========================+
150-
| _follow_redirects | ``bool`` | Boolean to specify |
149+
| follow_redirects | ``bool`` | Boolean to specify |
151150
| | | whether the client |
152151
| | | should follow HTTP |
153152
| | | redirects. Default is |
154153
| | | ``false``. |
155154
+----------------------+-------------------------------+-------------------------+
156-
| _cache_resolved | ``bool`` | Boolean to specify |
155+
| cache_resolved | ``bool`` | Boolean to specify |
157156
| | | whether the client |
158157
| | | should cache resolved |
159158
| | | endpoints. The default |
160159
| | | is ``false``. |
161160
+----------------------+-------------------------------+-------------------------+
162-
| _io_service | ``boost::asio::io_service &`` | Reference to an |
163-
| | | instance of a |
161+
| io_service | ``shared_ptr<io_service>`` | Shared pointer to a |
164162
| | | Boost.Asio |
165163
| | | ``io_service``. |
166164
+----------------------+-------------------------------+-------------------------+
167-
| _openssl_certificate | string | The filename of the |
165+
| openssl_certificate | string | The filename of the |
168166
| | | certificate to load for |
169167
| | | the SSL connection for |
170168
| | | verification. |
171169
+----------------------+-------------------------------+-------------------------+
172-
| _openssl_verify_path | string | The directory from |
170+
| openssl_verify_path | string | The directory from |
173171
| | | which the certificate |
174172
| | | authority files are |
175173
| | | located. |
@@ -182,11 +180,13 @@ the following:
182180
.. code-block:: c++
183181

184182
using namespace boost::network::http; // parameters are in this namespace
185-
boost::asio::io_service my_io_service;
186-
client client_(_follow_redirects=true, _cache_resolved=true,
187-
_io_service=my_io_service
188-
, _openssl_certificate="/tmp/my-cert"
189-
, _openssl_verify_path="/tmp/ca-certs/");
183+
client::options options;
184+
options.follow_redirects(true)
185+
.cache_resolved(true)
186+
.io_service(boost::make_shared<boost::asio::io_service>())
187+
.openssl_certificate("/tmp/my-cert")
188+
.openssl_verify_path("/tmp/ca-certs");
189+
client client_(options);
190190
// use client_ as normal from here on out.
191191

192192
HTTP Methods
@@ -207,7 +207,7 @@ and that there is an appropriately constructed response object named
207207

208208
``response_ = client_.get(request_)``
209209
Perform an HTTP GET request.
210-
``response_ = client_.get(request_, _body_handler=callback)``
210+
``response_ = client_.get(request_, callback)``
211211
Perform an HTTP GET request, and have the body chunks be handled by the
212212
``callback`` parameter. The signature of ``callback`` should be the following:
213213
``void(iterator_range<char const *> const &, boost::system::error_code const
@@ -217,7 +217,7 @@ and that there is an appropriately constructed response object named
217217
``response_ = client_.post(request_)``
218218
Perform an HTTP POST, use the data already set in the request object which
219219
includes the headers, and the body.
220-
``response_ = client_.post(request_, _body_handler=callback)``
220+
``response_ = client_.post(request_, callback)``
221221
Perform an HTTP POST request, and have the body chunks be handled by the
222222
``callback`` parameter. The signature of ``callback`` should be the following:
223223
``void(iterator_range<char const *> const &, boost::system::error_code const
@@ -226,18 +226,18 @@ and that there is an appropriately constructed response object named
226226
Body is a string of type ``boost::network::string<Tag>::type`` where ``Tag``
227227
is the HTTP Client's ``Tag``. The default content-type used is
228228
``x-application/octet-stream``.
229-
``response_ = client_.post(request_, body, _body_handler=callback)``
229+
``response_ = client_.post(request_, body, callback)``
230230
Body is a string of type ``boost::network::string<Tag>::type`` where ``Tag``
231231
is the HTTP Client's ``Tag``. The default content-type used is
232232
``x-application/octet-stream``. Have the response body chunks be handled by
233233
the ``callback`` parameter. The signature of ``callback`` should be the
234234
following: ``void(iterator_range<char const *> const &,
235235
boost::system::error_code const &)``.
236-
``response_ = client_.post(request_, content_type, body)``
236+
``response_ = client_.post(request_, body, content_type)``
237237
The body and content_type parameters are of type
238238
``boost::network::string<Tag>::type`` where ``Tag`` is the HTTP Client's
239239
``Tag``. This uses the request object's other headers.
240-
``response_ = client_.post(request_, content_type, body, _body_handler=callback)``
240+
``response_ = client_.post(request_, body, content_type, callback)``
241241
The body and content_type parameters are of type
242242
``boost::network::string<Tag>::type`` where ``Tag`` is the HTTP Client's
243243
``Tag``. This uses the request object's other headers. Have the response
@@ -247,7 +247,7 @@ and that there is an appropriately constructed response object named
247247
``response_ = client_.put(request_)``
248248
Perform an HTTP PUT, use the data already set in the request object which
249249
includes the headers, and the body.
250-
``response_ = client_.put(request_, _body_handler=callback)``
250+
``response_ = client_.put(request_, callback)``
251251
Perform an HTTP PUT request, and have the body chunks be handled by the
252252
``callback`` parameter. The signature of ``callback`` should be the following:
253253
``void(iterator_range<char const *> const &, boost::system::error_code const
@@ -256,18 +256,18 @@ and that there is an appropriately constructed response object named
256256
Body is a string of type ``boost::network::string<Tag>::type`` where ``Tag``
257257
is the HTTP Client's ``Tag``. The default content-type used is
258258
``x-application/octet-stream``.
259-
``response_ = client_.put(request_, body, _body_handler=callback)``
259+
``response_ = client_.put(request_, body, callback)``
260260
Body is a string of type ``boost::network::string<Tag>::type`` where ``Tag``
261261
is the HTTP Client's ``Tag``. The default content-type used is
262262
``x-application/octet-stream``. Have the response body chunks be handled by
263263
the ``callback`` parameter. The signature of ``callback`` should be the
264264
following: ``void(iterator_range<char const *> const &,
265265
boost::system::error_code const &)``.
266-
``response_ = client_.put(request_, content_type, body)``
266+
``response_ = client_.put(request_, body, content_type)``
267267
The body and content_type parameters are of type
268268
``boost::network::string<Tag>::type`` where ``Tag`` is the HTTP Client's
269269
``Tag``. This uses the request object's other headers.
270-
``response_ = client_.put(request_, content_type, body, _body_handler=callback)``
270+
``response_ = client_.put(request_, body, content_type, body_handler=callback)``
271271
The body and content_type parameters are of type
272272
``boost::network::string<Tag>::type`` where ``Tag`` is the HTTP Client's
273273
``Tag``. This uses the request object's other headers. Have the response
@@ -276,7 +276,7 @@ and that there is an appropriately constructed response object named
276276
&, boost::system::error_code const &)``.
277277
``response_ = client_.delete_(request_)``
278278
Perform an HTTP DELETE request.
279-
``response_ = client_.delete_(request_, _body_handler=callback)``
279+
``response_ = client_.delete_(request_, body_handler=callback)``
280280
Perform an HTTP DELETE request, and have the response body chunks be handled
281281
by the ``callback`` parameter. The signature of ``callback`` should be the
282282
following: ``void(iterator_range<char const *> const &,
@@ -320,7 +320,7 @@ An example of how to use the macro is shown below:
320320
// somewhere else
321321
std::string some_string;
322322
response_ = client_.get(request("http://cpp-netlib.github.com/"),
323-
_body_handler=body_handler(some_string));
323+
body_handler(some_string));
324324

325325
You can also use if for standalone functions instead if you don't want or need
326326
to create a function object.
@@ -337,7 +337,7 @@ to create a function object.
337337

338338
// somewhere else
339339
response_ = client_.get(request("http://cpp-netlib.github.com/"),
340-
_body_handler=print_body);
340+
print_body);
341341

342342
The ``BOOST_NETWORK_HTTP_BODY_CALLBACK`` macro is defined in
343343
``boost/network/protocol/http/client/macros.hpp``.

0 commit comments

Comments
 (0)