summaryrefslogtreecommitdiff
path: root/server/src/admin_connection.cc
diff options
context:
space:
mode:
Diffstat (limited to 'server/src/admin_connection.cc')
-rw-r--r--server/src/admin_connection.cc34
1 files changed, 18 insertions, 16 deletions
diff --git a/server/src/admin_connection.cc b/server/src/admin_connection.cc
index 21fe331..ae427a3 100644
--- a/server/src/admin_connection.cc
+++ b/server/src/admin_connection.cc
@@ -46,11 +46,6 @@ static std::string admin_sessionunlock(Environment &env, std::string id)
return "Session " + id + " does not exist or has been committed.";
}
-static std::string admin_favicon()
-{
- return admin_rc("favicon");
-}
-
AdminConnection::AdminConnection(Environment &e, headers_t a, std::string u)
: env(e), args(a), uri(u) {}
@@ -61,13 +56,22 @@ bool AdminConnection::handle(const char *data, size_t size)
if(data == NULL && size == 0) {
DEBUG(admin, "URI: %s\n", uri.c_str());
+ if(uri == "/") {
+ reply = admin_rc("header") +
+ "Command list:\n"
+ "/sessionunlock?id=[ID] unlock session with [ID] as its session id.\n"
+ + admin_rc("footer");
+ return true;
+ }
+
if(uri == "/sessionunlock" && args.find("id") != args.end()) {
- reply = admin_sessionunlock(env, args["id"]);
+ reply = admin_rc("header") + admin_sessionunlock(env, args["id"])
+ + admin_rc("footer");
return true;
}
if(uri == "/favicon.ico") {
- reply = admin_favicon();
+ reply = admin_rc("favicon");
return true;
}
@@ -78,18 +82,16 @@ bool AdminConnection::handle(const char *data, size_t size)
return true;
}
-std::string AdminConnection::getResponse()
-{
- return reply;
-}
-
-headers_t AdminConnection::getHeaders()
+void AdminConnection::getReply(Httpd::Reply &r)
{
headers_t hdrs;
- hdrs["Content-Type"] = "text/plain; charset=UTF-8";
- return hdrs;
-}
+ if(uri == "/favicon.ico") hdrs["Content-Type"] = "image/ico";
+ else hdrs["Content-Type"] = "text/html; charset=UTF-8";
+ r.data = reply;
+ r.headers = hdrs;
+ r.status = 200; // http 'OK'
+}
#ifdef TEST_ADMIN_CONNECTION
//deps: