我需要向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
?