diff options
Diffstat (limited to 'server/src')
-rw-r--r-- | server/src/server.cc | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/server/src/server.cc b/server/src/server.cc index b9b3743..0b2f6d6 100644 --- a/server/src/server.cc +++ b/server/src/server.cc @@ -79,6 +79,9 @@ static std::string error_box(std::string message) std::string errorbox = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" "<pracro version=\"1.0\">\n" +#if 0 + " <error>" + message + "</error>\n" +#else " <template name=\"error\">\n" " <macro name=\"error\" static=\"true\">\n" " <widgets caption=\"ERROR!\" layout=\"vbox\" name=\"error\">\n" @@ -86,6 +89,7 @@ static std::string error_box(std::string message) " </widgets>\n" " </macro>\n" " </template>\n" +#endif "</pracro>\n"; return errorbox; } @@ -175,7 +179,7 @@ static std::string handleRequest(Transaction *transaction, macro.attributes["name"], time(NULL)-Conf::db_max_ttl); - answer += " <macro completed="; + answer += " <macro uid=\"42\" completed="; if(completed) answer += "\"true\""; else answer += "\"false\""; @@ -390,19 +394,32 @@ static int handle_request(void *cls, url, method, version, *data_size); sessionid_t sessionid; bool commitsession = false; - + bool sid_ok = true; + const char *sessionids = MHD_lookup_connection_value(con, MHD_HEADER_KIND, "SessionID"); - if(sessionids == NULL) sessionid = newSessionID(conn); - else sessionid = atoll(sessionids); - printf("SessionID: %llu\n", sessionid); + if(sessionids == NULL) { + sessionid = newSessionID(conn); + } else { + sessionid = atoll(sessionids); + conn->mutex.lock(); + sid_ok = conn->sessions.find(sessionid) != conn->sessions.end(); + conn->mutex.unlock(); + } + PRACRO_DEBUG(httpd, "SessionID: %llu\n", sessionid); const char *session_commit = MHD_lookup_connection_value(con, MHD_HEADER_KIND, "SessionCommit"); if(session_commit) { - printf("COMMIT: sessionid %llu\n", sessionid); + PRACRO_DEBUG(httpd, "COMMIT: sessionid %llu\n", sessionid); commitsession = true; } - std::string reply = handleConnection(data, *data_size, conn, sessionid, commitsession); + std::string reply; + if(sid_ok) { + reply = handleConnection(data, *data_size, conn, sessionid, commitsession); + } else { + PRACRO_ERR(httpd, "No such sessionid %llu\n", sessionid); + reply = error_box("No such session ID!"); + } struct MHD_Response *rsp; rsp = MHD_create_response_from_data(reply.length(), (char*)reply.c_str(), MHD_NO, MHD_YES); |