Skip to content

Commit ccebaeb

Browse files
committed
Formatted source code and add source comments.
1 parent 03dddb2 commit ccebaeb

13 files changed

+350
-180
lines changed

http/src/http/v2/client/client.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// (See accompanying file LICENSE_1_0.txt or copy at
44
// http://www.boost.org/LICENSE_1_0.txt)
55

6-
#include <future>
76
#include <boost/asio/strand.hpp>
87
#include <boost/algorithm/string/trim.hpp>
98
#include <boost/algorithm/string/predicate.hpp>

http/src/network/http/v2/client/client.hpp

+26-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
namespace network {
3131
namespace http {
32-
namespace v2 {
32+
inline namespace v2 {
3333
namespace client_connection {
3434
class async_resolver;
3535
class async_connection;
@@ -177,6 +177,7 @@ class client_options {
177177
* \brief Tells the client to use a proxy.
178178
* \param use_proxy If \c true, then the client must use a
179179
* proxy, if \c false it doesn't.
180+
* \returns \c *this
180181
*/
181182
client_options &use_proxy(bool use_proxy) {
182183
use_proxy_ = use_proxy;
@@ -195,6 +196,7 @@ class client_options {
195196
/**
196197
* \brief Sets the client timeout in milliseconds.
197198
* \param timeout The timeout value in milliseconds.
199+
* \returns \c *this
198200
*/
199201
client_options &timeout(std::chrono::milliseconds timeout) {
200202
timeout_ = timeout;
@@ -212,6 +214,7 @@ class client_options {
212214
/**
213215
* \brief Adds an OpenSSL certificate path.
214216
* \param path The certificate path.
217+
* \returns \c *this
215218
*/
216219
client_options &openssl_certificate_path(std::string path) {
217220
openssl_certificate_paths_.emplace_back(std::move(path));
@@ -229,6 +232,7 @@ class client_options {
229232
/**
230233
* \brief Adds an OpenSSL verify path.
231234
* \param path The verify path.
235+
* \returns \c *this
232236
*/
233237
client_options &openssl_verify_path(std::string path) {
234238
openssl_verify_paths_.emplace_back(std::move(path));
@@ -243,20 +247,36 @@ class client_options {
243247
return openssl_verify_paths_;
244248
}
245249

250+
/**
251+
* \brief
252+
* \returns \c *this
253+
*/
246254
client_options &always_verify_peer(bool always_verify_peer) {
247255
always_verify_peer_ = always_verify_peer;
248256
return *this;
249257
}
250258

259+
/**
260+
* \brief
261+
* \returns
262+
*/
251263
bool always_verify_peer() const {
252264
return always_verify_peer_;
253265
}
254266

267+
/**
268+
* \brief
269+
* \returns \c *this
270+
*/
255271
client_options &user_agent(const std::string &user_agent) {
256272
user_agent_ = user_agent;
257273
return *this;
258274
}
259275

276+
/**
277+
* \brief
278+
* \returns
279+
*/
260280
std::string user_agent() const {
261281
return user_agent_;
262282
}
@@ -275,6 +295,11 @@ class client_options {
275295

276296
};
277297

298+
/**
299+
* \brief
300+
* \param lhs
301+
* \param rhs
302+
*/
278303
inline
279304
void swap(client_options &lhs, client_options &rhs) noexcept {
280305
lhs.swap(rhs);

http/src/network/http/v2/client/client_errors.hpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
namespace network {
2020
namespace http {
21-
namespace v2 {
21+
inline namespace v2 {
2222
/**
2323
* \ingroup http_client
2424
* \enum client_error network/http/v2/client/client_errors.hpp network/http/v2/client.hpp
@@ -29,8 +29,8 @@ enum class client_error {
2929
invalid_request,
3030

3131
// response
32-
invalid_response,
33-
};
32+
invalid_response,
33+
};
3434

3535
/**
3636
* \brief Gets the error category for HTTP client errors.

http/src/network/http/v2/client/connection/async_connection.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
namespace network {
2222
namespace http {
23-
namespace v2 {
23+
inline namespace v2 {
2424
namespace client_connection {
2525
/**
2626
* \class async_connection network/http/v2/client/connection/async_connection.hpp

http/src/network/http/v2/client/connection/async_resolver.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
namespace network {
2020
namespace http {
21-
namespace v2 {
21+
inline namespace v2 {
2222
namespace client_connection {
2323
/**
2424
* \class async_resolver network/http/v2/client/connection/async_resolver.hpp

http/src/network/http/v2/client/connection/endpoint_cache.hpp

+72-44
Original file line numberDiff line numberDiff line change
@@ -18,52 +18,80 @@
1818

1919
namespace network {
2020
namespace http {
21-
namespace v2 {
21+
inline namespace v2 {
2222
namespace client_connection {
2323

24-
class endpoint_cache {
25-
26-
typedef boost::asio::ip::tcp::resolver resolver;
27-
28-
typedef resolver::iterator resolver_iterator;
29-
30-
typedef std::unordered_map<std::string,
31-
resolver_iterator> cache_type;
32-
33-
public:
34-
35-
typedef cache_type::iterator iterator;
36-
37-
cache_type::iterator begin() {
38-
return endpoints_.begin();
39-
}
40-
41-
cache_type::iterator end() {
42-
return endpoints_.end();
43-
}
44-
45-
void insert(const std::string &host,
46-
resolver_iterator endpoint_iterator) {
47-
endpoints_.insert(std::make_pair(host, endpoint_iterator));
48-
}
49-
50-
iterator find(const std::string &host) {
51-
return endpoints_.find(boost::to_lower_copy(host));
52-
}
53-
54-
void clear() {
55-
endpoint_cache().swap(*this);
56-
}
57-
58-
void swap(endpoint_cache &other) noexcept {
59-
endpoints_.swap(other.endpoints_);
60-
}
61-
62-
private:
63-
64-
cache_type endpoints_;
65-
66-
};
24+
/**
25+
* \class endpoint_cache network/http/v2/client/connection/endpoint_cache.hpp
26+
* \brief
27+
*/
28+
class endpoint_cache {
29+
30+
/**
31+
* \brief
32+
*/
33+
typedef boost::asio::ip::tcp::resolver resolver;
34+
35+
typedef resolver::iterator resolver_iterator;
36+
37+
typedef std::unordered_map<std::string,
38+
resolver_iterator> cache_type;
39+
40+
public:
41+
42+
/**
43+
* \brief
44+
*/
45+
typedef cache_type::iterator iterator;
46+
47+
/**
48+
* \brief
49+
*/
50+
cache_type::iterator begin() {
51+
return endpoints_.begin();
52+
}
53+
54+
/**
55+
* \brief
56+
*/
57+
cache_type::iterator end() {
58+
return endpoints_.end();
59+
}
60+
61+
/**
62+
* \brief
63+
*/
64+
void insert(const std::string &host,
65+
resolver_iterator endpoint_iterator) {
66+
endpoints_.insert(std::make_pair(host, endpoint_iterator));
67+
}
68+
69+
/**
70+
* \brief
71+
*/
72+
iterator find(const std::string &host) {
73+
return endpoints_.find(boost::to_lower_copy(host));
74+
}
75+
76+
/**
77+
* \brief
78+
*/
79+
void clear() {
80+
endpoint_cache().swap(*this);
81+
}
82+
83+
/**
84+
* \brief
85+
*/
86+
void swap(endpoint_cache &other) noexcept {
87+
endpoints_.swap(other.endpoints_);
88+
}
89+
90+
private:
91+
92+
cache_type endpoints_;
93+
94+
};
6795
} // namespace client_connection
6896
} // namespace v2
6997
} // namespace http

http/src/network/http/v2/client/connection/normal_connection.hpp

+49-38
Original file line numberDiff line numberDiff line change
@@ -21,59 +21,70 @@
2121

2222
namespace network {
2323
namespace http {
24-
namespace v2 {
24+
inline namespace v2 {
2525
namespace client_connection {
26-
class normal_connection : public async_connection {
2726

28-
normal_connection(const normal_connection &) = delete;
29-
normal_connection &operator = (const normal_connection &) = delete;
27+
/**
28+
* \class
29+
* \brief
30+
*/
31+
class normal_connection : public async_connection {
3032

31-
public:
33+
normal_connection(const normal_connection &) = delete;
34+
normal_connection &operator = (const normal_connection &) = delete;
3235

33-
explicit normal_connection(boost::asio::io_service &io_service)
34-
: io_service_(io_service) {
36+
public:
3537

36-
}
38+
/**
39+
* \brief
40+
*/
41+
explicit normal_connection(boost::asio::io_service &io_service)
42+
: io_service_(io_service) {
3743

38-
virtual ~normal_connection() noexcept {
44+
}
3945

40-
}
46+
/**
47+
* \brief Destructor.
48+
*/
49+
virtual ~normal_connection() noexcept {
4150

42-
virtual void async_connect(const boost::asio::ip::tcp::endpoint &endpoint,
43-
const std::string &host,
44-
connect_callback callback) {
45-
using boost::asio::ip::tcp;
46-
socket_.reset(new tcp::socket{io_service_});
47-
socket_->async_connect(endpoint, callback);
48-
}
51+
}
4952

50-
virtual void async_write(boost::asio::streambuf &command_streambuf,
51-
write_callback callback) {
52-
boost::asio::async_write(*socket_, command_streambuf, callback);
53-
}
53+
virtual void async_connect(const boost::asio::ip::tcp::endpoint &endpoint,
54+
const std::string &host,
55+
connect_callback callback) {
56+
using boost::asio::ip::tcp;
57+
socket_.reset(new tcp::socket{io_service_});
58+
socket_->async_connect(endpoint, callback);
59+
}
5460

55-
virtual void async_read_until(boost::asio::streambuf &command_streambuf,
56-
const std::string &delim,
57-
read_callback callback) {
58-
boost::asio::async_read_until(*socket_, command_streambuf, delim, callback);
59-
}
61+
virtual void async_write(boost::asio::streambuf &command_streambuf,
62+
write_callback callback) {
63+
boost::asio::async_write(*socket_, command_streambuf, callback);
64+
}
6065

61-
virtual void async_read(boost::asio::streambuf &command_streambuf,
62-
read_callback callback) {
63-
boost::asio::async_read(*socket_, command_streambuf,
64-
boost::asio::transfer_at_least(1), callback);
65-
}
66+
virtual void async_read_until(boost::asio::streambuf &command_streambuf,
67+
const std::string &delim,
68+
read_callback callback) {
69+
boost::asio::async_read_until(*socket_, command_streambuf, delim, callback);
70+
}
6671

67-
virtual void cancel() {
68-
socket_->cancel();
69-
}
72+
virtual void async_read(boost::asio::streambuf &command_streambuf,
73+
read_callback callback) {
74+
boost::asio::async_read(*socket_, command_streambuf,
75+
boost::asio::transfer_at_least(1), callback);
76+
}
7077

71-
private:
78+
virtual void cancel() {
79+
socket_->cancel();
80+
}
7281

73-
boost::asio::io_service &io_service_;
74-
std::unique_ptr<boost::asio::ip::tcp::socket> socket_;
82+
private:
7583

76-
};
84+
boost::asio::io_service &io_service_;
85+
std::unique_ptr<boost::asio::ip::tcp::socket> socket_;
86+
87+
};
7788
} // namespace client_connection
7889
} // namespace v2
7990
} // namespace http

0 commit comments

Comments
 (0)