Add a base class for http async clients; refine examples.

This commit is contained in:
Chunting Gu
2019-02-12 17:06:26 +08:00
parent 9ecec5de0b
commit 43eaf90621
43 changed files with 803 additions and 507 deletions
+3 -5
View File
@@ -22,8 +22,7 @@ void AdjustHostPort(std::string& host, std::string& port) {
}
}
void PrintEndpoint(std::ostream& ostream,
const boost::asio::ip::tcp::endpoint& endpoint) {
void PrintEndpoint(std::ostream& ostream, const TcpEndpoint& endpoint) {
ostream << endpoint;
if (endpoint.protocol() == tcp::v4()) {
ostream << ", v4";
@@ -32,8 +31,7 @@ void PrintEndpoint(std::ostream& ostream,
}
}
void PrintEndpoints(std::ostream& ostream,
const tcp::resolver::results_type& endpoints) {
void PrintEndpoints(std::ostream& ostream, const TcpEndpoints& endpoints) {
ostream << "Endpoints: " << endpoints.size() << std::endl;
tcp::resolver::results_type::iterator it = endpoints.begin();
for (; it != endpoints.end(); ++it) {
@@ -43,7 +41,7 @@ void PrintEndpoints(std::ostream& ostream,
}
}
std::string EndpointToString(const boost::asio::ip::tcp::endpoint& endpoint) {
std::string EndpointToString(const TcpEndpoint& endpoint) {
std::stringstream ss;
PrintEndpoint(ss, endpoint);
return ss.str();