From a5ae3c459e098a904ee0092cffab3ec555161cdf Mon Sep 17 00:00:00 2001 From: Stefan Radomski Date: Wed, 30 Oct 2013 17:19:07 +0100 Subject: Process application/xml in http requests and try to fix layout of README.md --- README.md | 36 +++++++++++------------ src/uscxml/plugins/invoker/xhtml/XHTMLInvoker.cpp | 2 +- src/uscxml/server/HTTPServer.cpp | 10 ++++++- 3 files changed, 28 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 08bd3ff..1dbe133 100644 --- a/README.md +++ b/README.md @@ -6,28 +6,28 @@ It runs on Linux, Windows and MacOSX, each 32- as well as 6 There are still a few rough edges though, especially with the plugins and custom extensions. * Datamodels - * Full [ECMAScript datamodel](https://github.com/tklab-tud/uscxml/tree/master/src/uscxml/plugins/datamodel/ecmascript) using Google's v8 (and JavaScriptCore on MacOSX and iOS) - * Simplified support for [Web Storage](http://www.w3.org/TR/2013/REC-webstorage-20130730/) in document.localStorage - * Support for binary data via [TypedArrays](https://www.khronos.org/registry/typedarray/specs/latest/) (will not throw exceptions yet) - * Full [NULL datamodel](https://github.com/tklab-tud/uscxml/tree/master/src/uscxml/plugins/datamodel/null) with required In predicate - * Early [Prolog datamodel](https://github.com/tklab-tud/uscxml/tree/master/src/uscxml/plugins/datamodel/prolog/swi) using SWI prolog - * Rudimentary support for [XPath datamodel](https://github.com/tklab-tud/uscxml/tree/master/src/uscxml/plugins/datamodel/xpath) + * Full [ECMAScript datamodel](https://github.com/tklab-tud/uscxml/tree/master/src/uscxml/plugins/datamodel/ecmascript) using Google's v8 (and JavaScriptCore on MacOSX and iOS) + * Simplified support for [Web Storage](http://www.w3.org/TR/2013/REC-webstorage-20130730/) in document.localStorage + * Support for binary data via [TypedArrays](https://www.khronos.org/registry/typedarray/specs/latest/) (will not throw exceptions yet) + * Full [NULL datamodel](https://github.com/tklab-tud/uscxml/tree/master/src/uscxml/plugins/datamodel/null) with required In predicate + * Early [Prolog datamodel](https://github.com/tklab-tud/uscxml/tree/master/src/uscxml/plugins/datamodel/prolog/swi) using SWI prolog + * Rudimentary support for [XPath datamodel](https://github.com/tklab-tud/uscxml/tree/master/src/uscxml/plugins/datamodel/xpath) * Invokers - * scxml: Invoke a nested scxml interpreter - * dirmon: Watches a directory for changes to files - * scenegraph: Simplified 3D scenegraphs with custom markup - * heartbeat: Periodically sends events - * umundo: Subscribe to channels and publish events + * scxml: Invoke a nested scxml interpreter + * dirmon: Watches a directory for changes to files + * scenegraph: Simplified 3D scenegraphs with custom markup + * heartbeat: Periodically sends events + * umundo: Subscribe to channels and publish events * DOM - * DOM Core Level 2 + XPath extensions available for ecmascript datamodel - * Namespace aware to embed custom markup for special invokers + * DOM Core Level 2 + XPath extensions available for ecmascript datamodel + * Namespace aware to embed custom markup for special invokers * Communication - * Features the standard basichttp io-processor - * Features the required SCXML io-processor - * No DOM io-processor - * Can actually respond to HTTP requests with data via <response> + * Features the standard basichttp io-processor + * Features the required SCXML io-processor + * No DOM io-processor + * Can actually respond to HTTP requests with data via <response> * Language Bindings - * PHP module for apache and cli interpreter + * PHP module for apache and cli interpreter ## Test Reports diff --git a/src/uscxml/plugins/invoker/xhtml/XHTMLInvoker.cpp b/src/uscxml/plugins/invoker/xhtml/XHTMLInvoker.cpp index 13c3e40..04cb143 100644 --- a/src/uscxml/plugins/invoker/xhtml/XHTMLInvoker.cpp +++ b/src/uscxml/plugins/invoker/xhtml/XHTMLInvoker.cpp @@ -199,7 +199,7 @@ void XHTMLInvoker::reply(const SendRequest& req, const HTTPServer::Request& long reply.headers["Content-Type"] = "application/json"; } else if (req.content.length() > 0) { reply.content = req.content; - reply.headers["Content-Type"] = "application/text"; + reply.headers["Content-Type"] = "text/plain"; } if (req.params.find("Content-Type") != req.params.end()) diff --git a/src/uscxml/server/HTTPServer.cpp b/src/uscxml/server/HTTPServer.cpp index efd49a5..15f347c 100644 --- a/src/uscxml/server/HTTPServer.cpp +++ b/src/uscxml/server/HTTPServer.cpp @@ -25,6 +25,7 @@ #endif #include "uscxml/server/HTTPServer.h" +#include "uscxml/NameSpacingParser.h" #include #include @@ -364,7 +365,7 @@ void HTTPServer::httpRecvReqCallback(struct evhttp_request *req, void *callbackD request.data.compound["header"].compound.find("Content-Type") != request.data.compound["header"].compound.end()) { std::string contentType = request.data.compound["header"].compound["Content-Type"].atom; if (false) { - } else if (iequals(contentType, "application/x-www-form-urlencoded")) { + } else if (iequals(contentType.substr(0, 33), "application/x-www-form-urlencoded")) { // this is a form submit std::stringstream ss(request.data.compound["content"].atom); std::string item; @@ -389,6 +390,13 @@ void HTTPServer::httpRecvReqCallback(struct evhttp_request *req, void *callbackD request.data.compound["content"].atom.clear(); } else if (iequals(contentType.substr(0, 16), "application/json")) { request.data.compound["content"] = Data::fromJSON(request.data.compound["content"].atom); + } else if (iequals(contentType.substr(0, 15), "application/xml")) { + NameSpacingParser parser = NameSpacingParser::fromXML(request.data.compound["content"].atom); + if (parser.errorsReported()) { + LOG(ERROR) << "Cannot parse contents of HTTP request as XML"; + } else { + request.data.compound["content"].node = parser.getDocument().getDocumentElement(); + } } } -- cgit v0.12