81 auto addr = request.address();
82 auto headers = request.headers();
83 auto ct = headers.get<Http::Header::ContentType>();
85 auto res = response.send(Http::Code::Not_Acceptable,
"Not a JSON command!\n");
87 auto ansport = headers.getRaw(
"X-Answer-Port");
88 auto anshost = headers.tryGetRaw(
"X-Answer-Host");
89 meta.
data[
"ans-port"] = ansport.value();
90 meta.
data[
"ans-host"] = ( !anshost.isEmpty() ? anshost.get().value() : addr.host() );
92 auto res = response.send(Http::Code::Accepted,
"Command received\n");
99 std::ostringstream addrstr;
100 addrstr << meta.
data[
"ans-host"].get<std::string>() <<
":" << meta.
data[
"ans-port"].get<std::string>() <<
"/response";
101 meta.
data[
"cmdid"] = command.
id;
102 TLOG() <<
"Sending POST request to " << addrstr.str();
104 nlohmann::json body_json;
106 auto response =
http_client_->post(addrstr.str()).body(body_json.dump()).send();
108 [&](Http::Response response) {
109 TLOG() <<
"Response code = " << response.code();
111 [&](std::exception_ptr exc) {
114 std::rethrow_exception(exc);
116 catch (
const std::exception &e) {
117 TLOG() <<
"Exception thrown by Http::Client::post() call: \"" << e.what() <<
"\"; errno = " << errno;