Commit 8901a69a authored by Mccaskey, Alex's avatar Mccaskey, Alex
Browse files

updating remote accelerator to fix ssl handshake bug



Signed-off-by: Mccaskey, Alex's avatarAlex McCaskey <mccaskeyaj@ornl.gov>
parent c00f7998
......@@ -32,7 +32,7 @@ void setCredentials(const std::string& accelerator, const std::string& apiKey, c
filename += ".ibm_config";
std::string tmpUrl = url;
if (url.empty()) {
tmpUrl = "https://quantumexperience.mybluemix.net";
tmpUrl = "https://quantumexperience.ng.bluemix.net";
}
s << "url: " << tmpUrl << "\n";
......
......@@ -24,14 +24,18 @@ const std::string RestClient::post(const std::string& remoteUrl,
}
http::uri uri = http::uri(remoteUrl);
http_client_config config;
config.set_validate_certificates(false);
http_client postClient(
http::uri_builder(uri).append_path(U(path)).to_uri());
http::uri_builder(uri).append_path(U(path)).to_uri(), config);
http_request postRequest(methods::POST);
for (auto& kv : headers) {
postRequest.headers().add(kv.first, kv.second);
}
postRequest.set_body(postStr);
// xacc::info("POSTING: " + postStr + " to " + remoteUrl + ", " + path);// << "\n";
// Post the problem, get the response as json
auto postResponse = postClient.request(postRequest);
auto respJson = postResponse.get().extract_string().get();
......@@ -39,25 +43,29 @@ const std::string RestClient::post(const std::string& remoteUrl,
// Map that response to a string
std::stringstream ss;
ss << respJson;
// xacc::info("post response was " + ss.str());// << "\n";
return ss.str();
}
const std::string RestClient::get(const std::string& remoteUrl,
const std::string& path, std::map<std::string, std::string> headers) {
http_client_config config;
config.set_validate_certificates(false);
http_client getClient(
http::uri_builder(http::uri(remoteUrl)).append_path(U(path)).to_uri());
http::uri_builder(http::uri(remoteUrl)).append_path(U(path)).to_uri(), config);
http_request getRequest(methods::GET);
for (auto& kv : headers) {
getRequest.headers().add(kv.first, kv.second);
}
// xacc::info("Getting IBM at " + remoteUrl + ", " + path);
auto getResponse = getClient.request(getRequest);
// get the result as a string
std::stringstream z;
try {
z << getResponse.get().extract_json().get();
// xacc::info("GET RESPONSE: " + z.str());
// xacc::info("GET RESPONSE: " + z.str());
} catch (std::exception& e) {
std::cout << "HELLO WORLD!, Caught exception, " << e.what() << "\n";
xacc::error("XACC RemoteAccelerator caught exception, " + std::string(e.what()));
}
return z.str();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment