| 75 | WalletNode::~WalletNode() = default; // we have unique_ptr to incomplete type |
| 76 | |
| 77 | bool WalletNode::on_api_http_request(http::Client *who, http::RequestBody &&request, http::ResponseBody &response) { |
| 78 | response.r.add_headers_nocache(); |
| 79 | bool method_found = false; |
| 80 | if (request.r.uri == api::walletd::url()) { |
| 81 | bool result = on_json_rpc(who, std::move(request), response, method_found); |
| 82 | if (method_found) |
| 83 | return result; |
| 84 | } |
| 85 | m_log(logging::INFO) << "http_request node tunneling url=" << request.r.uri |
| 86 | << " start of body=" << request.body.substr(0, 200); |
| 87 | http::RequestBody original_request; |
| 88 | original_request.r = request.r; |
| 89 | request.r.http_version_major = 1; |
| 90 | request.r.http_version_minor = 1; |
| 91 | request.r.keep_alive = true; |
| 92 | request.r.basic_authorization = m_config.bytecoind_authorization; |
| 93 | add_waiting_command(who, std::move(original_request), json_rpc::Request{}, std::move(request), |
| 94 | [](const WaitingClient &wc, http::ResponseBody &&send_response) mutable { |
| 95 | send_response.r.http_version_major = wc.original_request.r.http_version_major; |
| 96 | send_response.r.http_version_minor = wc.original_request.r.http_version_minor; |
| 97 | send_response.r.keep_alive = wc.original_request.r.keep_alive; |
| 98 | // bytecoind never sends connection-close, so we are safe to retain all headers |
| 99 | http::Server::write(wc.original_who, std::move(send_response)); |
| 100 | }, |
| 101 | [](const WaitingClient &wc, std::string err) { |
| 102 | http::ResponseBody send_response; |
| 103 | send_response.r.http_version_major = wc.original_request.r.http_version_major; |
| 104 | send_response.r.http_version_minor = wc.original_request.r.http_version_minor; |
| 105 | send_response.r.keep_alive = wc.original_request.r.keep_alive; |
| 106 | send_response.r.status = 504; // TODO -test this code path |
| 107 | send_response.set_body(std::string{}); |
| 108 | http::Server::write(wc.original_who, std::move(send_response)); |
| 109 | }); |
| 110 | return false; |
| 111 | } |
| 112 | |
| 113 | void WalletNode::on_api_http_disconnect(http::Client *who) { |
| 114 | for (auto &&wc : m_waiting_command_requests) { |
nothing calls this directly
no test coverage detected