@@ -139,37 +139,35 @@ initialization.
139
139
140
140
``client() ``
141
141
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.
146
145
147
146
+----------------------+-------------------------------+-------------------------+
148
147
| Parameter Name| Type| Description|
149
148
+======================+===============================+=========================+
150
- | _follow_redirects | ``bool ``| Boolean to specify|
149
+ | follow_redirects | ``bool ``| Boolean to specify|
151
150
| | | whether the client|
152
151
| | | should follow HTTP|
153
152
| | | redirects. Default is|
154
153
| | | ``false ``.|
155
154
+----------------------+-------------------------------+-------------------------+
156
- | _cache_resolved | ``bool ``| Boolean to specify|
155
+ | cache_resolved | ``bool ``| Boolean to specify|
157
156
| | | whether the client|
158
157
| | | should cache resolved|
159
158
| | | endpoints. The default|
160
159
| | | is ``false ``.|
161
160
+----------------------+-------------------------------+-------------------------+
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|
164
162
| | | Boost.Asio|
165
163
| | | ``io_service ``.|
166
164
+----------------------+-------------------------------+-------------------------+
167
- | _openssl_certificate | string| The filename of the|
165
+ | openssl_certificate | string| The filename of the|
168
166
| | | certificate to load for|
169
167
| | | the SSL connection for|
170
168
| | | verification.|
171
169
+----------------------+-------------------------------+-------------------------+
172
- | _openssl_verify_path | string| The directory from|
170
+ | openssl_verify_path | string| The directory from|
173
171
| | | which the certificate|
174
172
| | | authority files are|
175
173
| | | located.|
@@ -182,11 +180,13 @@ the following:
182
180
..code-block ::c++
183
181
184
182
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);
190
190
// useclient _ as normal from here on out.
191
191
192
192
HTTP Methods
@@ -207,7 +207,7 @@ and that there is an appropriately constructed response object named
207
207
208
208
``response_ = client_.get(request_) ``
209
209
Perform an HTTP GET request.
210
- ``response_ = client_.get(request_,_body_handler= callback) ``
210
+ ``response_ = client_.get(request_, callback) ``
211
211
Perform an HTTP GET request, and have the body chunks be handled by the
212
212
``callback `` parameter. The signature of ``callback `` should be the following:
213
213
``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
217
217
``response_ = client_.post(request_) ``
218
218
Perform an HTTP POST, use the data already set in the request object which
219
219
includes the headers, and the body.
220
- ``response_ = client_.post(request_,_body_handler= callback) ``
220
+ ``response_ = client_.post(request_, callback) ``
221
221
Perform an HTTP POST request, and have the body chunks be handled by the
222
222
``callback `` parameter. The signature of ``callback `` should be the following:
223
223
``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
226
226
Body is a string of type ``boost::network::string<Tag>::type `` where ``Tag ``
227
227
is the HTTP Client's ``Tag ``. The default content-type used is
228
228
``x-application/octet-stream ``.
229
- ``response_ = client_.post(request_, body,_body_handler= callback) ``
229
+ ``response_ = client_.post(request_, body, callback) ``
230
230
Body is a string of type ``boost::network::string<Tag>::type `` where ``Tag ``
231
231
is the HTTP Client's ``Tag ``. The default content-type used is
232
232
``x-application/octet-stream ``. Have the response body chunks be handled by
233
233
the ``callback `` parameter. The signature of ``callback `` should be the
234
234
following: ``void(iterator_range<char const *> const &,
235
235
boost::system::error_code const &) ``.
236
- ``response_ = client_.post(request_,content_type, body ) ``
236
+ ``response_ = client_.post(request_,body, content_type ) ``
237
237
The body and content_type parameters are of type
238
238
``boost::network::string<Tag>::type `` where ``Tag `` is the HTTP Client's
239
239
``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) ``
241
241
The body and content_type parameters are of type
242
242
``boost::network::string<Tag>::type `` where ``Tag `` is the HTTP Client's
243
243
``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
247
247
``response_ = client_.put(request_) ``
248
248
Perform an HTTP PUT, use the data already set in the request object which
249
249
includes the headers, and the body.
250
- ``response_ = client_.put(request_,_body_handler= callback) ``
250
+ ``response_ = client_.put(request_, callback) ``
251
251
Perform an HTTP PUT request, and have the body chunks be handled by the
252
252
``callback `` parameter. The signature of ``callback `` should be the following:
253
253
``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
256
256
Body is a string of type ``boost::network::string<Tag>::type `` where ``Tag ``
257
257
is the HTTP Client's ``Tag ``. The default content-type used is
258
258
``x-application/octet-stream ``.
259
- ``response_ = client_.put(request_, body,_body_handler= callback) ``
259
+ ``response_ = client_.put(request_, body, callback) ``
260
260
Body is a string of type ``boost::network::string<Tag>::type `` where ``Tag ``
261
261
is the HTTP Client's ``Tag ``. The default content-type used is
262
262
``x-application/octet-stream ``. Have the response body chunks be handled by
263
263
the ``callback `` parameter. The signature of ``callback `` should be the
264
264
following: ``void(iterator_range<char const *> const &,
265
265
boost::system::error_code const &) ``.
266
- ``response_ = client_.put(request_,content_type, body ) ``
266
+ ``response_ = client_.put(request_,body, content_type ) ``
267
267
The body and content_type parameters are of type
268
268
``boost::network::string<Tag>::type `` where ``Tag `` is the HTTP Client's
269
269
``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) ``
271
271
The body and content_type parameters are of type
272
272
``boost::network::string<Tag>::type `` where ``Tag `` is the HTTP Client's
273
273
``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
276
276
&, boost::system::error_code const &) ``.
277
277
``response_ = client_.delete_(request_) ``
278
278
Perform an HTTP DELETE request.
279
- ``response_ = client_.delete_(request_,_body_handler =callback) ``
279
+ ``response_ = client_.delete_(request_,body_handler =callback) ``
280
280
Perform an HTTP DELETE request, and have the response body chunks be handled
281
281
by the ``callback `` parameter. The signature of ``callback `` should be the
282
282
following: ``void(iterator_range<char const *> const &,
@@ -320,7 +320,7 @@ An example of how to use the macro is shown below:
320
320
// somewhere else
321
321
std::string some_string;
322
322
response _ =client _.get(request("http://cpp-netlib.github.com/"),
323
- _body_handler= body_handler(some_string));
323
+ body_handler(some_string));
324
324
325
325
You can also use if for standalone functions instead if you don't want or need
326
326
to create a function object.
@@ -337,7 +337,7 @@ to create a function object.
337
337
338
338
// somewhere else
339
339
response _ =client _.get(request("http://cpp-netlib.github.com/"),
340
- _body_handler= print_body);
340
+ print_body);
341
341
342
342
The ``BOOST_NETWORK_HTTP_BODY_CALLBACK `` macro is defined in
343
343
``boost/network/protocol/http/client/macros.hpp ``.