summaryrefslogtreecommitdiffstats
path: root/src/uscxml/util
diff options
context:
space:
mode:
authorStefan Radomski <github@mintwerk.de>2017-06-12 14:37:12 (GMT)
committerStefan Radomski <github@mintwerk.de>2017-06-12 14:37:12 (GMT)
commitbfdd2f8e72005d1e2ef2a87d19d8ac242bb22557 (patch)
tree5c3e73450534bd8b4279d20f0171dcfb45167786 /src/uscxml/util
parent090016a3f5bcd66d6265fe1504430430f1dee7ed (diff)
downloaduscxml-bfdd2f8e72005d1e2ef2a87d19d8ac242bb22557.zip
uscxml-bfdd2f8e72005d1e2ef2a87d19d8ac242bb22557.tar.gz
uscxml-bfdd2f8e72005d1e2ef2a87d19d8ac242bb22557.tar.bz2
respond element and proper http ioproc
Diffstat (limited to 'src/uscxml/util')
-rw-r--r--src/uscxml/util/Predicates.cpp2
-rw-r--r--src/uscxml/util/URL.cpp28
-rw-r--r--src/uscxml/util/URL.h3
3 files changed, 33 insertions, 0 deletions
diff --git a/src/uscxml/util/Predicates.cpp b/src/uscxml/util/Predicates.cpp
index c4effdb..3f6128f 100644
--- a/src/uscxml/util/Predicates.cpp
+++ b/src/uscxml/util/Predicates.cpp
@@ -325,6 +325,8 @@ DOMElement* getState(const std::string& stateId, const DOMElement* root) {
stateStack.insert(stateStack.end(), children.begin(), children.end());
}
+ // no state with such an id in document!
+ assert(false);
return NULL;
}
diff --git a/src/uscxml/util/URL.cpp b/src/uscxml/util/URL.cpp
index b429e22..e64139c 100644
--- a/src/uscxml/util/URL.cpp
+++ b/src/uscxml/util/URL.cpp
@@ -144,6 +144,34 @@ std::string URL::getTempDir(bool shared) {
#endif
}
+std::map<std::string, std::string> URL::mimeTypes;
+std::string URL::getMimeType(const std::string extension, std::string magic) {
+ if (mimeTypes.empty()) {
+ mimeTypes["txt"] = "text/plain";
+ mimeTypes["c"] = "text/plain";
+ mimeTypes["h"] = "text/plain";
+ mimeTypes["html"] = "text/html";
+ mimeTypes["htm"] = "text/htm";
+ mimeTypes["css"] = "text/css";
+ mimeTypes["bmp"] = "image/bmp";
+ mimeTypes["gif"] = "image/gif";
+ mimeTypes["jpg"] = "image/jpeg";
+ mimeTypes["jpeg"] = "image/jpeg";
+ mimeTypes["mpg"] = "video/mpeg";
+ mimeTypes["mov"] = "video/quicktime";
+ mimeTypes["png"] = "image/png";
+ mimeTypes["pdf"] = "application/pdf";
+ mimeTypes["ps"] = "application/postscript";
+ mimeTypes["tif"] = "image/tiff";
+ mimeTypes["tiff"] = "image/tiff";
+ }
+
+ if (mimeTypes.find(extension) != mimeTypes.end()) {
+ return mimeTypes[extension];
+ }
+ return "application/octet-stream";
+}
+
// Version for MacOSX in URL.mm
#if (!defined APPLE && !defined IOS)
std::string URL::getResourceDir() {
diff --git a/src/uscxml/util/URL.h b/src/uscxml/util/URL.h
index 9ad2f8e..f9e7ed5 100644
--- a/src/uscxml/util/URL.h
+++ b/src/uscxml/util/URL.h
@@ -149,6 +149,8 @@ public:
*/
static std::string getTempDir(bool shared = true);
+ static std::string getMimeType(const std::string extension, std::string magic = "");
+
bool isAbsolute() {
return _impl->isAbsolute();
}
@@ -253,6 +255,7 @@ public:
protected:
std::shared_ptr<URLImpl> _impl;
+ static std::map<std::string, std::string> mimeTypes;
friend class URLFetcher;
static std::string currTmpDir;