summaryrefslogtreecommitdiffstats
path: root/src/uscxml/plugins/element/response/ResponseElement.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/uscxml/plugins/element/response/ResponseElement.cpp')
-rw-r--r--src/uscxml/plugins/element/response/ResponseElement.cpp76
1 files changed, 38 insertions, 38 deletions
diff --git a/src/uscxml/plugins/element/response/ResponseElement.cpp b/src/uscxml/plugins/element/response/ResponseElement.cpp
index ce25036..814f726 100644
--- a/src/uscxml/plugins/element/response/ResponseElement.cpp
+++ b/src/uscxml/plugins/element/response/ResponseElement.cpp
@@ -17,52 +17,52 @@ bool connect(pluma::Host& host) {
#endif
boost::shared_ptr<ExecutableContentImpl> ResponseElement::create(Interpreter* interpreter) {
- boost::shared_ptr<ResponseElement> invoker = boost::shared_ptr<ResponseElement>(new ResponseElement());
+ 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);
+ 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