Forbit to create http async clients on stack since they are derived from std::shared_from_this.
This commit is contained in:
@@ -2,22 +2,21 @@
|
||||
|
||||
#include "json/json.h"
|
||||
|
||||
#include "webcc/rest_ssl_client.h"
|
||||
#include "webcc/logger.h"
|
||||
#include "webcc/rest_ssl_client.h"
|
||||
|
||||
const bool kSslVerify = false;
|
||||
|
||||
#define PRINT_CONTENT 0
|
||||
|
||||
|
||||
static Json::Value StringToJson(const std::string& str) {
|
||||
Json::Value json;
|
||||
|
||||
Json::CharReaderBuilder builder;
|
||||
std::stringstream stream(str);
|
||||
std::string errs;
|
||||
if (!Json::parseFromStream(builder, stream, &json, &errs)) {
|
||||
std::cerr << errs << std::endl;
|
||||
std::string errors;
|
||||
if (!Json::parseFromStream(builder, stream, &json, &errors)) {
|
||||
std::cerr << errors << std::endl;
|
||||
}
|
||||
|
||||
return json;
|
||||
|
||||
@@ -9,12 +9,10 @@
|
||||
// Only HttpBin.org has this issue.
|
||||
|
||||
static void Test(boost::asio::io_context& io_context) {
|
||||
auto request = webcc::HttpRequest::Make(webcc::kHttpGet, "/get",
|
||||
"httpbin.org");
|
||||
auto request = webcc::HttpRequest::New(webcc::kHttpGet, "/get",
|
||||
"httpbin.org");
|
||||
|
||||
webcc::HttpAsyncClientPtr client{
|
||||
new webcc::HttpAsyncClient(io_context)
|
||||
};
|
||||
auto client = webcc::HttpAsyncClient::New(io_context);
|
||||
|
||||
client->SetTimeout(3);
|
||||
|
||||
|
||||
@@ -14,8 +14,8 @@ static void PrintError(const webcc::HttpClient& client) {
|
||||
int main() {
|
||||
WEBCC_LOG_INIT("", webcc::LOG_CONSOLE);
|
||||
|
||||
auto request = webcc::HttpRequest::Make(webcc::kHttpGet, "/get",
|
||||
"httpbin.org");
|
||||
auto request = webcc::HttpRequest::New(webcc::kHttpGet, "/get",
|
||||
"httpbin.org");
|
||||
|
||||
webcc::HttpClient client;
|
||||
|
||||
|
||||
@@ -26,15 +26,13 @@ int main(int argc, char* argv[]) {
|
||||
boost::asio::io_context io_context;
|
||||
|
||||
// Leave port to default value.
|
||||
auto request = webcc::HttpRequest::Make(webcc::kHttpGet, url, host);
|
||||
auto request = webcc::HttpRequest::New(webcc::kHttpGet, url, host);
|
||||
|
||||
// Verify the certificate of the peer or not.
|
||||
// See HttpSslClient::Request() for more details.
|
||||
bool ssl_verify = false;
|
||||
|
||||
webcc::HttpSslAsyncClientPtr client{
|
||||
new webcc::HttpSslAsyncClient{ io_context, 2000, ssl_verify }
|
||||
};
|
||||
auto client = webcc::HttpSslAsyncClient::New(io_context, 2000, ssl_verify);
|
||||
|
||||
// Response callback.
|
||||
auto callback = [](webcc::HttpResponsePtr response, webcc::Error error,
|
||||
|
||||
Reference in New Issue
Block a user