Fix async client issues.

This commit is contained in:
Adam Gu
2018-06-14 17:21:24 +08:00
parent 781121aea3
commit 44271eb2cc
17 changed files with 339 additions and 238 deletions
+9 -4
View File
@@ -3,7 +3,7 @@
#include "boost/asio/io_context.hpp"
#include "webcc/logger.h"
#include "webcc/http_async_client.h"
#include "webcc/async_http_client.h"
// In order to test this client, create a file index.html whose content is
// simply "Hello, World!", then start a HTTP server with Python 3:
@@ -19,15 +19,20 @@ void Test(boost::asio::io_context& ioc) {
request->Build();
webcc::HttpAsyncClientPtr client(new webcc::HttpAsyncClient(ioc));
webcc::HttpAsyncClientPtr client(new webcc::AsyncHttpClient(ioc));
// Response handler.
auto handler = [](std::shared_ptr<webcc::HttpResponse> response,
webcc::Error error) {
webcc::Error error,
bool timed_out) {
if (error == webcc::kNoError) {
std::cout << response->content() << std::endl;
} else {
std::cout << webcc::DescribeError(error) << std::endl;
std::cout << webcc::DescribeError(error);
if (timed_out) {
std::cout << " (timed out)";
}
std::cout << std::endl;
}
};