diff options
author | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2013-09-18 15:39:30 (GMT) |
---|---|---|
committer | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2013-09-18 15:39:30 (GMT) |
commit | 8dde1311719b29c63efb379566916cb1aa9a7cd7 (patch) | |
tree | 6849ab145936ea5a2bebee5b64e69c4d226c3810 /src/uscxml/server | |
parent | 7938e286967597c7168b855b7e3fdfbd9b949e0e (diff) | |
download | uscxml-8dde1311719b29c63efb379566916cb1aa9a7cd7.zip uscxml-8dde1311719b29c63efb379566916cb1aa9a7cd7.tar.gz uscxml-8dde1311719b29c63efb379566916cb1aa9a7cd7.tar.bz2 |
Work on FFMpegInvoker
Diffstat (limited to 'src/uscxml/server')
-rw-r--r-- | src/uscxml/server/HTTPServer.cpp | 39 | ||||
-rw-r--r-- | src/uscxml/server/InterpreterServlet.cpp | 17 |
2 files changed, 45 insertions, 11 deletions
diff --git a/src/uscxml/server/HTTPServer.cpp b/src/uscxml/server/HTTPServer.cpp index e37d8cc..0521d74 100644 --- a/src/uscxml/server/HTTPServer.cpp +++ b/src/uscxml/server/HTTPServer.cpp @@ -194,14 +194,15 @@ void HTTPServer::httpRecvReqCallback(struct evhttp_request *req, void *callbackD // } // seperate path into components - std::stringstream ss(request.data.compound["path"].atom); - std::string item; - while(std::getline(ss, item, '/')) { - if (item.length() == 0) - continue; - request.data.compound["pathComponent"].array.push_back(Data(item, Data::VERBATIM)); + { + std::stringstream ss(request.data.compound["path"].atom); + std::string item; + while(std::getline(ss, item, '/')) { + if (item.length() == 0) + continue; + request.data.compound["pathComponent"].array.push_back(Data(item, Data::VERBATIM)); + } } - // parse query string struct evkeyvalq params; struct evkeyval *param; @@ -233,9 +234,27 @@ void HTTPServer::httpRecvReqCallback(struct evhttp_request *req, void *callbackD std::string contentType = request.data.compound["header"].compound["Content-Type"].atom; if (false) { } else if (boost::iequals(contentType, "application/x-www-form-urlencoded")) { - char* contentCStr = evhttp_decode_uri(request.data.compound["content"].atom.c_str()); - request.data.compound["content"].atom = contentCStr; - free(contentCStr); + // this is a form submit + std::stringstream ss(request.data.compound["content"].atom); + std::string item; + std::string key; + std::string value; + while(std::getline(ss, item, '=')) { + if (item.length() == 0) + continue; + if (key.length() == 0) { + key = item; + continue; + } + value = item; + char* keyCStr = evhttp_decode_uri(key.c_str()); + char* valueCStr = evhttp_decode_uri(value.c_str()); + request.data.compound["content"].compound[keyCStr] = Data(valueCStr, Data::VERBATIM); + free(keyCStr); + free(valueCStr); + key.clear(); + } + request.data.compound["content"].atom.clear(); } else if (boost::iequals(contentType, "application/json")) { request.data.compound["content"] = Data::fromJSON(request.data.compound["content"].atom); } diff --git a/src/uscxml/server/InterpreterServlet.cpp b/src/uscxml/server/InterpreterServlet.cpp index b59cc05..49f6677 100644 --- a/src/uscxml/server/InterpreterServlet.cpp +++ b/src/uscxml/server/InterpreterServlet.cpp @@ -35,7 +35,22 @@ bool InterpreterServlet::httpRecvRequest(const HTTPServer::Request& req) { event.name = "http." + event.data.compound["type"].atom; event.origin = toStr((uintptr_t)req.curlReq); - event.initContent(event.data.compound["content"].atom); + + if (event.data.compound["content"]) { + if (event.data.compound["content"].compound.size() > 0) { + std::map<std::string, Data>::iterator compoundIter = event.data.compound["content"].compound.begin(); + while(compoundIter != event.data.compound["content"].compound.end()) { +// std::cout << compoundIter->second.atom << std::endl; + Data json = Data::fromJSON(compoundIter->second.atom); + if (json) { +// std::cout << Data::toJSON(json) << std::endl; + compoundIter->second = json; + } + compoundIter++; + } + } + } + _interpreter->receive(event); return true; } |