aboutsummaryrefslogtreecommitdiff
path: root/src/common/http_connection.h
diff options
context:
space:
mode:
authorThomas Winget <tewinget@gmail.com>2015-01-29 17:10:53 -0500
committerThomas Winget <tewinget@gmail.com>2015-02-24 00:05:19 -0500
commit9193d6fb5be92df732af18b08b1e052f84cc2f9d (patch)
treedfe58f501122beec786322d30d04efacf8c90259 /src/common/http_connection.h
parentMerge pull request #221 (diff)
downloadmonero-9193d6fb5be92df732af18b08b1e052f84cc2f9d.tar.xz
Daemonize changes pulled in -- daemon builds
many RPC functions added by the daemonize changes (and related changes on the upstream dev branch that were not merged) were commented out (apart from return). Other than that, this *should* work...at any rate, it builds, and that's something.
Diffstat (limited to '')
-rw-r--r--src/common/http_connection.h42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/common/http_connection.h b/src/common/http_connection.h
new file mode 100644
index 000000000..759145009
--- /dev/null
+++ b/src/common/http_connection.h
@@ -0,0 +1,42 @@
+#pragma once
+
+#include "string_tools.h"
+#include "net/http_client.h"
+
+namespace tools {
+
+class t_http_connection {
+private:
+ epee::net_utils::http::http_simple_client * mp_http_client;
+ bool m_ok;
+public:
+ static unsigned int const TIMEOUT = 200000;
+
+ t_http_connection(
+ epee::net_utils::http::http_simple_client * p_http_client
+ , uint32_t ip
+ , uint16_t port
+ )
+ : mp_http_client(p_http_client)
+ {
+ // TODO fix http client so that it accepts properly typed arguments
+ std::string ip_str = epee::string_tools::get_ip_string_from_int32(ip);
+ std::string port_str = boost::lexical_cast<std::string>(port);
+ m_ok = mp_http_client->connect(ip_str, port_str, TIMEOUT);
+ }
+
+ ~t_http_connection()
+ {
+ if (m_ok)
+ {
+ mp_http_client->disconnect();
+ }
+ }
+
+ bool is_open()
+ {
+ return m_ok;
+ }
+}; // class t_http_connection
+
+} // namespace tools