diff options
author | deva <deva> | 2011-02-07 11:15:52 +0000 |
---|---|---|
committer | deva <deva> | 2011-02-07 11:15:52 +0000 |
commit | 4ea34b413bd21c0e8ec4c3b93840bfe928d3c9c4 (patch) | |
tree | 693c2416ad98911b98b2249c324de640841bfa20 /server/src/client_connection.cc | |
parent | 1f3b20415c59ce08479d9291b92bbe5ffa8b2f6c (diff) |
Cleaned up the Connection interface a bit.
Diffstat (limited to 'server/src/client_connection.cc')
-rw-r--r-- | server/src/client_connection.cc | 33 |
1 files changed, 22 insertions, 11 deletions
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 |