summaryrefslogtreecommitdiffstats
path: root/src/uscxml/plugins/element/response/ResponseElement.cpp
diff options
context:
space:
mode:
authorStefan Radomski <radomski@tk.informatik.tu-darmstadt.de>2013-02-20 21:13:02 (GMT)
committerStefan Radomski <radomski@tk.informatik.tu-darmstadt.de>2013-02-20 21:13:02 (GMT)
commita56f28b0db56ff3e39f0b50e4c55c52b7aeec696 (patch)
tree41cf67ea5cee9593e86272ab55367653fbd1c2f3 /src/uscxml/plugins/element/response/ResponseElement.cpp
parent7c779099b3acd1fa969dde718299484ebe0d2775 (diff)
downloaduscxml-a56f28b0db56ff3e39f0b50e4c55c52b7aeec696.zip
uscxml-a56f28b0db56ff3e39f0b50e4c55c52b7aeec696.tar.gz
uscxml-a56f28b0db56ff3e39f0b50e4c55c52b7aeec696.tar.bz2
See detailled log
- Builds on windows again - All HTTP requests are no passed into interpreter - New response element to reply with data - Moved basichttp URL - New HTTP servlet invoker to register additional URLs - More bugfixes than I care to mention
Diffstat (limited to 'src/uscxml/plugins/element/response/ResponseElement.cpp')
-rw-r--r--src/uscxml/plugins/element/response/ResponseElement.cpp68
1 files changed, 68 insertions, 0 deletions
diff --git a/src/uscxml/plugins/element/response/ResponseElement.cpp b/src/uscxml/plugins/element/response/ResponseElement.cpp
new file mode 100644
index 0000000..ce25036
--- /dev/null
+++ b/src/uscxml/plugins/element/response/ResponseElement.cpp
@@ -0,0 +1,68 @@
+#include "ResponseElement.h"
+#include "uscxml/plugins/invoker/http/HTTPServletInvoker.h"
+#include <glog/logging.h>
+
+#ifdef BUILD_AS_PLUGINS
+#include <Pluma/Connector.hpp>
+#endif
+
+namespace uscxml {
+
+#ifdef BUILD_AS_PLUGINS
+PLUMA_CONNECTOR
+bool connect(pluma::Host& host) {
+ host.add( new ResponseElementProvider() );
+ return true;
+}
+#endif
+
+boost::shared_ptr<ExecutableContentImpl> ResponseElement::create(Interpreter* interpreter) {
+ boost::shared_ptr<ResponseElement> invoker = boost::shared_ptr<ResponseElement>(new ResponseElement());
+ invoker->_interpreter = interpreter;
+ return invoker;
+}
+
+void ResponseElement::enterElement(const Arabica::DOM::Node<std::string>& node) {
+ if (!HAS_ATTR(node, "request") && !HAS_ATTR(node, "requestexpr")) {
+ LOG(ERROR) << "Response element requires request or requestexpr";
+ return;
+ }
+ if (HAS_ATTR(node, "requestexpr") && !_interpreter->getDataModel()) {
+ LOG(ERROR) << "Response element with requestexpr requires datamodel";
+ return;
+ }
+ if (HAS_ATTR(node, "close")) {
+
+ }
+
+ std::string requestId = (HAS_ATTR(node, "request") ? ATTR(node, "request") : _interpreter->getDataModel().evalAsString(ATTR(node, "requestexpr")));
+
+ HTTPServletInvoker* servlet = _interpreter->getHTTPServlet();
+ tthread::lock_guard<tthread::recursive_mutex> lock(servlet->getMutex());
+
+ if (servlet->getRequests().find(requestId) == servlet->getRequests().end()) {
+ LOG(ERROR) << "No matching HTTP request for response element";
+ return;
+ }
+
+ std::string statusStr = (HAS_ATTR(node, "status") ? ATTR(node, "status") : "200");
+ if (!isNumeric(statusStr.c_str(), 10)) {
+ LOG(ERROR) << "Response element with non-numeric status " << statusStr;
+ return;
+ }
+ int status = strTo<int>(statusStr);
+
+ HTTPServer::Request httpReq = servlet->getRequests()[requestId];
+
+ HTTPServer::Reply httpReply(httpReq);
+ httpReply.status = status;
+
+ HTTPServer::reply(httpReply);
+ servlet->getRequests().erase(requestId);
+}
+
+void ResponseElement::exitElement(const Arabica::DOM::Node<std::string>& node) {
+
+}
+
+} \ No newline at end of file