Fix async client issues.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include "json/json.h"
|
||||
|
||||
#include "webcc/logger.h"
|
||||
#include "webcc/rest_async_client.h"
|
||||
#include "webcc/async_rest_client.h"
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
@@ -44,7 +44,7 @@ class BookListClient {
|
||||
}
|
||||
|
||||
private:
|
||||
webcc::RestAsyncClient rest_client_;
|
||||
webcc::AsyncRestClient rest_client_;
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
@@ -84,7 +84,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
webcc::RestAsyncClient rest_client_;
|
||||
webcc::AsyncRestClient rest_client_;
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
@@ -113,7 +113,8 @@ int main(int argc, char* argv[]) {
|
||||
|
||||
// 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 {
|
||||
|
||||
@@ -34,8 +34,8 @@ protected:
|
||||
|
||||
void PrintError() {
|
||||
std::cout << webcc::DescribeError(rest_client_.error());
|
||||
if (rest_client_.timeout_occurred()) {
|
||||
std::cout << " (timeout)";
|
||||
if (rest_client_.timed_out()) {
|
||||
std::cout << " (timed out)";
|
||||
}
|
||||
std::cout << std::endl;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user