diff options
author | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2013-02-20 21:55:27 (GMT) |
---|---|---|
committer | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2013-02-20 21:55:27 (GMT) |
commit | 47956a35d11495f2ebf6988c7f9d9dffe0bd3a4b (patch) | |
tree | b991daf52ca2051d2e3f89f8143b843bf1318449 /src/uscxml/plugins/ioprocessor/basichttp/libevent/EventIOProcessor.cpp | |
parent | 8c30e4f664bb8b68f965165035ec29115486b065 (diff) | |
download | uscxml-47956a35d11495f2ebf6988c7f9d9dffe0bd3a4b.zip uscxml-47956a35d11495f2ebf6988c7f9d9dffe0bd3a4b.tar.gz uscxml-47956a35d11495f2ebf6988c7f9d9dffe0bd3a4b.tar.bz2 |
Beautified source code again
Diffstat (limited to 'src/uscxml/plugins/ioprocessor/basichttp/libevent/EventIOProcessor.cpp')
-rw-r--r-- | src/uscxml/plugins/ioprocessor/basichttp/libevent/EventIOProcessor.cpp | 106 |
1 files changed, 53 insertions, 53 deletions
diff --git a/src/uscxml/plugins/ioprocessor/basichttp/libevent/EventIOProcessor.cpp b/src/uscxml/plugins/ioprocessor/basichttp/libevent/EventIOProcessor.cpp index ed51ef8..1b58785 100644 --- a/src/uscxml/plugins/ioprocessor/basichttp/libevent/EventIOProcessor.cpp +++ b/src/uscxml/plugins/ioprocessor/basichttp/libevent/EventIOProcessor.cpp @@ -50,11 +50,11 @@ boost::shared_ptr<IOProcessorImpl> EventIOProcessor::create(Interpreter* interpr io->_interpreter = interpreter; // register at http server - std::string path = interpreter->getName(); - path += "/basichttp"; - if (!HTTPServer::registerServlet(path, io.get())) { - LOG(ERROR) << "Cannot register basichttp ioprocessor at " << path << ": " << " already taken"; - } + std::string path = interpreter->getName(); + path += "/basichttp"; + if (!HTTPServer::registerServlet(path, io.get())) { + LOG(ERROR) << "Cannot register basichttp ioprocessor at " << path << ": " << " already taken"; + } return io; } @@ -67,13 +67,13 @@ Data EventIOProcessor::getDataModelVariables() { } void EventIOProcessor::httpRecvRequest(const HTTPServer::Request& req) { - Event reqEvent; + Event reqEvent; reqEvent.type = Event::EXTERNAL; bool scxmlStructFound = false; - - std::map<std::string, std::string>::const_iterator headerIter = req.headers.begin(); - while(headerIter != req.headers.end()) { - if (boost::iequals("_scxmleventstruct", headerIter->first)) { + + std::map<std::string, std::string>::const_iterator headerIter = req.headers.begin(); + while(headerIter != req.headers.end()) { + if (boost::iequals("_scxmleventstruct", headerIter->first)) { reqEvent = Event::fromXML(evhttp_decode_uri(headerIter->second.c_str())); scxmlStructFound = true; break; @@ -81,33 +81,33 @@ void EventIOProcessor::httpRecvRequest(const HTTPServer::Request& req) { reqEvent.name = evhttp_decode_uri(headerIter->second.c_str()); } else { reqEvent.data.compound[headerIter->first] = Data(evhttp_decode_uri(headerIter->second.c_str()), Data::VERBATIM); - } - headerIter++; - } - + } + headerIter++; + } + if (reqEvent.name.length() == 0) reqEvent.name = req.type; - + if (!scxmlStructFound) { // get content into event reqEvent.data.compound["content"] = Data(req.content, Data::VERBATIM); } - + returnEvent(reqEvent); evhttp_send_reply(req.curlReq, 200, "OK", NULL); } void EventIOProcessor::send(const SendRequest& req) { - std::string target = req.target; - URL targetURL(target); + std::string target = req.target; + URL targetURL(target); - // event name + // event name if (req.name.size() > 0) { - targetURL.addOutHeader("_scxmleventname", evhttp_encode_uri(req.name.c_str())); + targetURL.addOutHeader("_scxmleventname", evhttp_encode_uri(req.name.c_str())); } - // event namelist + // event namelist if (req.namelist.size() > 0) { std::map<std::string, std::string>::const_iterator namelistIter = req.namelist.begin(); while (namelistIter != req.namelist.end()) { @@ -116,7 +116,7 @@ void EventIOProcessor::send(const SendRequest& req) { } } - // event params + // event params if (req.params.size() > 0) { std::multimap<std::string, std::string>::const_iterator paramIter = req.params.begin(); while (paramIter != req.params.end()) { @@ -124,47 +124,47 @@ void EventIOProcessor::send(const SendRequest& req) { paramIter++; } } - + // content if (req.content.size() > 0) - targetURL.setOutContent(req.content); + targetURL.setOutContent(req.content); - targetURL.setRequestType("post"); - targetURL.addMonitor(this); - - _sendRequests[req.sendid] = std::make_pair(targetURL, req); - URLFetcher::fetchURL(targetURL); + targetURL.setRequestType("post"); + targetURL.addMonitor(this); + + _sendRequests[req.sendid] = std::make_pair(targetURL, req); + URLFetcher::fetchURL(targetURL); } - + void EventIOProcessor::downloadStarted(const URL& url) {} void EventIOProcessor::downloadCompleted(const URL& url) { - std::map<std::string, std::pair<URL, SendRequest> >::iterator reqIter = _sendRequests.begin(); - while(reqIter != _sendRequests.end()) { - if (reqIter->second.first == url) { - _sendRequests.erase(reqIter); - return; - } - reqIter++; - } - assert(false); + std::map<std::string, std::pair<URL, SendRequest> >::iterator reqIter = _sendRequests.begin(); + while(reqIter != _sendRequests.end()) { + if (reqIter->second.first == url) { + _sendRequests.erase(reqIter); + return; + } + reqIter++; + } + assert(false); } void EventIOProcessor::downloadFailed(const URL& url, int errorCode) { - - std::map<std::string, std::pair<URL, SendRequest> >::iterator reqIter = _sendRequests.begin(); - while(reqIter != _sendRequests.end()) { - if (reqIter->second.first == url) { - Event failEvent; - failEvent.name = "error.communication"; - returnEvent(failEvent); - - _sendRequests.erase(reqIter); - return; - } - reqIter++; - } - assert(false); + + std::map<std::string, std::pair<URL, SendRequest> >::iterator reqIter = _sendRequests.begin(); + while(reqIter != _sendRequests.end()) { + if (reqIter->second.first == url) { + Event failEvent; + failEvent.name = "error.communication"; + returnEvent(failEvent); + + _sendRequests.erase(reqIter); + return; + } + reqIter++; + } + assert(false); } |