我需要向AWS ES发出签名请求,但我陷入了第一个障碍,因为我似乎无法使用CurlHttpClient
。这是我的代码(verb
,path
和body
别处定义):aws-sdk-cpp:如何使用CurlHttpClient?
Aws::Client::ClientConfiguration clientConfiguration;
clientConfiguration.scheme = Aws::Http::Scheme::HTTPS;
clientConfiguration.region = Aws::Region::US_EAST_1;
auto client = Aws::MakeShared<Aws::Http::CurlHttpClient>(ALLOCATION_TAG, clientConfiguration);
Aws::Http::URI uri;
uri.SetScheme(Aws::Http::Scheme::HTTPS);
uri.SetAuthority(ELASTIC_SEARCH_DOMAIN);
uri.SetPath(path);
Aws::Http::Standard::StandardHttpRequest req(uri, verb);
req.AddContentBody(body);
auto res = client->MakeRequest(req);
Aws::Http::HttpResponseCode resCode = res->GetResponseCode();
if (resCode == Aws::Http::HttpResponseCode::OK) {
Aws::IOStream &body = res->GetResponseBody();
rejoiceAndBeMerry();
}
else {
gotoPanicStations();
}
在执行时,代码抛出一个bad_function_call
深从混合了大量的shared_ptr此的SDK内并分配这一点。我的猜测是,我只是使用SDK错误,但我一直无法找到直接使用CurlHttpClient
的任何示例,例如我需要在此处执行的操作。
如何使用CurlHttpClient
?