Skip to content

Commit 5100e6c

Browse files
committed
Add move constructor and assignment for client_options.
Untested, but should allow in-place definition of client_options in the client constructor.
1 parent 84998d4 commit 5100e6c

File tree

2 files changed

+240
-233
lines changed

2 files changed

+240
-233
lines changed

include/network/protocol/http/client/options.hpp

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,23 @@
1515
#include <network/protocol/http/client/connection_manager.hpp>
1616
#include <network/protocol/http/client/client_connection.hpp>
1717

18-
namespace network {
19-
namespace http {
20-
18+
namespace network { namespace http {
19+
2120
// Forward-declare the pimpl.
2221
class client_options_pimpl;
23-
22+
2423
// This file defines all the options supported by the HTTP client
2524
// implementation.
2625
class client_options {
2726
public:
2827
client_options();
2928
client_options(client_options const &other); // Copy constructible.
30-
client_options& operator=(client_options rhs); // Assignable.
29+
client_options(client_options &&other); // Move constructible.
30+
client_options& operator=(client_options const &rhs); // Copy assignable.
31+
client_options& operator=(client_options &&rhs); // Move assignable.
3132
void swap(client_options &other); // Swappable.
3233
~client_options(); // Non-virtual destructor by design.
33-
34+
3435
// When adding more supported options, follow the pattern:
3536
//
3637
// client_options& name_of_option(type variable);
@@ -46,33 +47,33 @@ namespace http {
4647
// .follow_redirects()
4748
// .cache_resolved();
4849
// client client_(options);
49-
50+
5051
// These are the setter and getter for the Boost.Asio io_service to use.
5152
// The default setting when un-set is nullptr, meaning it signals the client
5253
// implementation that the user doesn't want to use his own io_service
5354
// instance.
5455
client_options& io_service(boost::asio::io_service *io_service);
5556
boost::asio::io_service* io_service() const;
56-
57+
5758
// The following option determines whether the client should follow
5859
// HTTP redirects when the implementation encounters them. The default
5960
// behavior is to return false.
6061
client_options& follow_redirects(bool setting=false);
6162
bool follow_redirects() const;
62-
63+
6364
// The following options determines whether the client should cache
6465
// resolved endpoints. The default behavior is to not cache resolved
6566
// endpoints.
6667
client_options& cache_resolved(bool setting=true);
6768
bool cache_resolved() const;
68-
69+
6970
// The following options provide the OpenSSL certificate paths to use.
7071
// Setting these options without OpenSSL support is valid, but the client
7172
// may throw an exception when attempting to make SSL connections. The
7273
// default implementation doesn't define certificate paths.
7374
client_options& add_openssl_certificate_path(std::string const &path);
7475
std::list<std::string> const & openssl_certificate_paths() const;
75-
76+
7677
// The following options provide the OpenSSL certificate authority paths
7778
// where the certificates can be found. Setting these options without OpenSSL
7879
// support is valid, but the client may throw an exception when attempting
@@ -90,19 +91,19 @@ namespace http {
9091
// for creating the correct instances of the appropriate connection.
9192
client_options& connection_factory(boost::shared_ptr<http::connection_factory> factory);
9293
boost::shared_ptr<http::connection_factory> connection_factory() const;
93-
94+
9495
// More options go here...
95-
96+
9697
private:
9798
// We hide the options in a pimpl, so that when new options get added
9899
// we can keep backward binary compatibility and re-link to the new
99-
// supported options without having to break those
100+
// supported options without having to break those
100101
client_options_pimpl *pimpl;
101102
};
102-
103+
103104
// Forward declare the request_options pimpl.
104105
class request_options_pimpl;
105-
106+
106107
// This is the per-request options we allow users to provide. These allow
107108
// for defining operational options that control a request's flow.
108109
class request_options {
@@ -112,7 +113,7 @@ namespace http {
112113
request_options& operator=(request_options rhs); // Assignable.
113114
void swap(request_options &other); // Swappable.
114115
~request_options(); // Non-virtual destructor by design.
115-
116+
116117
// We follow the same pattern as the client_options class and use the
117118
// chaining call pattern to set the options. When adding new options
118119
// to support, they should look roughly like so:
@@ -121,27 +122,27 @@ namespace http {
121122
// type_of_option name_of_option() const;
122123
//
123124
// See client_options above for a usage example in the same vein.
124-
125+
125126
// These determine the timeout when performing requests. The default timeout
126127
// is 30,000 milliseconds (30 seconds).
127128
request_options& timeout(uint64_t milliseconds = 30 * 1000);
128129
uint64_t timeout() const;
129-
130+
130131
// These determine the maximum number of redirects to follow. The default
131132
// implementation uses 10 as the maximum. A negative value means to keep
132133
// following redirects until they no longer redirect.
133134
request_options& max_redirects(int redirects=10);
134135
int max_redirects() const;
135-
136+
136137
// More options go here...
137-
138+
138139
private:
139140
// For the same reason as the client_options being a pimpl, we do this for
140141
// minimizing the need to break ABI compatibility when adding new supported
141142
// options.
142143
request_options_pimpl *pimpl;
143144
};
144-
145+
145146
} // namespace http
146147
} // namespace network
147148

0 commit comments

Comments
 (0)