15
15
#include < network/protocol/http/client/connection_manager.hpp>
16
16
#include < network/protocol/http/client/client_connection.hpp>
17
17
18
- namespace network {
19
- namespace http {
20
-
18
+ namespace network { namespace http {
19
+
21
20
// Forward-declare the pimpl.
22
21
class client_options_pimpl ;
23
-
22
+
24
23
// This file defines all the options supported by the HTTP client
25
24
// implementation.
26
25
class client_options {
27
26
public:
28
27
client_options ();
29
28
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.
31
32
void swap (client_options &other); // Swappable.
32
33
~client_options (); // Non-virtual destructor by design.
33
-
34
+
34
35
// When adding more supported options, follow the pattern:
35
36
//
36
37
// client_options& name_of_option(type variable);
@@ -46,33 +47,33 @@ namespace http {
46
47
// .follow_redirects()
47
48
// .cache_resolved();
48
49
// client client_(options);
49
-
50
+
50
51
// These are the setter and getter for the Boost.Asio io_service to use.
51
52
// The default setting when un-set is nullptr, meaning it signals the client
52
53
// implementation that the user doesn't want to use his own io_service
53
54
// instance.
54
55
client_options& io_service (boost::asio::io_service *io_service);
55
56
boost::asio::io_service* io_service () const ;
56
-
57
+
57
58
// The following option determines whether the client should follow
58
59
// HTTP redirects when the implementation encounters them. The default
59
60
// behavior is to return false.
60
61
client_options& follow_redirects (bool setting=false );
61
62
bool follow_redirects () const ;
62
-
63
+
63
64
// The following options determines whether the client should cache
64
65
// resolved endpoints. The default behavior is to not cache resolved
65
66
// endpoints.
66
67
client_options& cache_resolved (bool setting=true );
67
68
bool cache_resolved () const ;
68
-
69
+
69
70
// The following options provide the OpenSSL certificate paths to use.
70
71
// Setting these options without OpenSSL support is valid, but the client
71
72
// may throw an exception when attempting to make SSL connections. The
72
73
// default implementation doesn't define certificate paths.
73
74
client_options& add_openssl_certificate_path (std::string const &path);
74
75
std::list<std::string> const & openssl_certificate_paths () const ;
75
-
76
+
76
77
// The following options provide the OpenSSL certificate authority paths
77
78
// where the certificates can be found. Setting these options without OpenSSL
78
79
// support is valid, but the client may throw an exception when attempting
@@ -90,19 +91,19 @@ namespace http {
90
91
// for creating the correct instances of the appropriate connection.
91
92
client_options& connection_factory (boost::shared_ptr<http::connection_factory> factory);
92
93
boost::shared_ptr<http::connection_factory> connection_factory () const ;
93
-
94
+
94
95
// More options go here...
95
-
96
+
96
97
private:
97
98
// We hide the options in a pimpl, so that when new options get added
98
99
// 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
100
101
client_options_pimpl *pimpl;
101
102
};
102
-
103
+
103
104
// Forward declare the request_options pimpl.
104
105
class request_options_pimpl ;
105
-
106
+
106
107
// This is the per-request options we allow users to provide. These allow
107
108
// for defining operational options that control a request's flow.
108
109
class request_options {
@@ -112,7 +113,7 @@ namespace http {
112
113
request_options& operator =(request_options rhs); // Assignable.
113
114
void swap (request_options &other); // Swappable.
114
115
~request_options (); // Non-virtual destructor by design.
115
-
116
+
116
117
// We follow the same pattern as the client_options class and use the
117
118
// chaining call pattern to set the options. When adding new options
118
119
// to support, they should look roughly like so:
@@ -121,27 +122,27 @@ namespace http {
121
122
// type_of_option name_of_option() const;
122
123
//
123
124
// See client_options above for a usage example in the same vein.
124
-
125
+
125
126
// These determine the timeout when performing requests. The default timeout
126
127
// is 30,000 milliseconds (30 seconds).
127
128
request_options& timeout (uint64_t milliseconds = 30 * 1000 );
128
129
uint64_t timeout () const ;
129
-
130
+
130
131
// These determine the maximum number of redirects to follow. The default
131
132
// implementation uses 10 as the maximum. A negative value means to keep
132
133
// following redirects until they no longer redirect.
133
134
request_options& max_redirects (int redirects=10 );
134
135
int max_redirects () const ;
135
-
136
+
136
137
// More options go here...
137
-
138
+
138
139
private:
139
140
// For the same reason as the client_options being a pimpl, we do this for
140
141
// minimizing the need to break ABI compatibility when adding new supported
141
142
// options.
142
143
request_options_pimpl *pimpl;
143
144
};
144
-
145
+
145
146
} // namespace http
146
147
} // namespace network
147
148
0 commit comments