From 4ea34b413bd21c0e8ec4c3b93840bfe928d3c9c4 Mon Sep 17 00:00:00 2001 From: deva Date: Mon, 7 Feb 2011 11:15:52 +0000 Subject: Cleaned up the Connection interface a bit. --- server/src/client_connection.cc | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) (limited to 'server/src/client_connection.cc') diff --git a/server/src/client_connection.cc b/server/src/client_connection.cc index af70916..9689ac4 100644 --- a/server/src/client_connection.cc +++ b/server/src/client_connection.cc @@ -54,11 +54,22 @@ ClientConnection::Parameters::Parameters() nocommit = false; } -ClientConnection::ClientConnection(Environment &e, Parameters p) - : parms(p), env(e), parser(&transaction) +ClientConnection::ClientConnection(Environment &e, headers_t &headers) + : env(e), parser(&transaction) { DEBUG(connection, "[%p] CREATE\n", this); + if(headers.contains("SessionID")) + parms.sessionid = headers["SessionID"]; + if(headers.contains("SessionPatientID")) + parms.patientid = headers["SessionPatientID"]; + if(headers.contains("SessionTemplate")) + parms.templ = headers["SessionTemplate"]; + + parms.commit = headers.contains("SessionCommit"); + parms.nocommit = headers.contains("SessionNoCommit"); + parms.discard = headers.contains("SessionDiscard"); + #ifdef TEST_CONNECTION did_commit = false; #endif @@ -183,21 +194,21 @@ bool ClientConnection::handle(const char *data, size_t size) return false; } -std::string ClientConnection::getResponse() -{ - if(parser_complete == false) - return error_box(xml_encode("XML Parser need more data.")); - return response; -} - -headers_t ClientConnection::getHeaders() +void ClientConnection::getReply(Httpd::Reply &reply) { headers_t hdrs; hdrs["Content-Type"] = "text/plain; charset=UTF-8"; hdrs["SessionID"] = parms.sessionid; - return hdrs; + reply.headers = hdrs; + + if(parser_complete == false) + reply.data = error_box(xml_encode("XML Parser need more data.")); + else + reply.data = response; + + reply.status = 200; // http 'OK' } #ifdef TEST_CLIENT_CONNECTION -- cgit v1.2.3