-
+
diff --git a/domain-server/resources/web/footer.shtml b/domain-server/resources/web/footer.html
similarity index 100%
rename from domain-server/resources/web/footer.shtml
rename to domain-server/resources/web/footer.html
diff --git a/domain-server/resources/web/header.shtml b/domain-server/resources/web/header.html
similarity index 100%
rename from domain-server/resources/web/header.shtml
rename to domain-server/resources/web/header.html
diff --git a/domain-server/resources/web/index.shtml b/domain-server/resources/web/index.shtml
index 2b64dad530..29c39f6c02 100644
--- a/domain-server/resources/web/index.shtml
+++ b/domain-server/resources/web/index.shtml
@@ -1,4 +1,4 @@
-
+
Nodes
@@ -27,6 +27,6 @@
-
+
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/domain-server/resources/web/page-end.shtml b/domain-server/resources/web/page-end.html
similarity index 100%
rename from domain-server/resources/web/page-end.shtml
rename to domain-server/resources/web/page-end.html
diff --git a/libraries/embedded-webserver/src/HttpConnection.cpp b/libraries/embedded-webserver/src/HttpConnection.cpp
index ffb763cee3..82660c8473 100755
--- a/libraries/embedded-webserver/src/HttpConnection.cpp
+++ b/libraries/embedded-webserver/src/HttpConnection.cpp
@@ -123,7 +123,6 @@ void HttpConnection::respond(const char* code, const QByteArray& content, const
_socket->write("Connection: close\r\n\r\n");
if (csize > 0) {
- qDebug() << "Writing" << QString(content) << "\n";
_socket->write(content);
}
diff --git a/libraries/embedded-webserver/src/HttpManager.cpp b/libraries/embedded-webserver/src/HttpManager.cpp
index 0d7f4b3286..07dd376c8a 100755
--- a/libraries/embedded-webserver/src/HttpManager.cpp
+++ b/libraries/embedded-webserver/src/HttpManager.cpp
@@ -42,16 +42,58 @@ bool HttpManager::handleRequest(HttpConnection* connection, const QString& path)
} else if (QFileInfo(_documentRoot + subPath).isFile()) {
filePath = _documentRoot + subPath;
}
+
if (!filePath.isEmpty()) {
static QMimeDatabase mimeDatabase;
- qDebug() << "Serving file at" << filePath;
-
QFile localFile(filePath);
localFile.open(QIODevice::ReadOnly);
+ QString localFileString(localFile.readAll());
- connection->respond("200 OK", localFile.readAll(), qPrintable(mimeDatabase.mimeTypeForFile(filePath).name()));
+ QFileInfo localFileInfo(filePath);
+
+ if (localFileInfo.completeSuffix() == "shtml") {
+ // this is a file that may have some SSI statements
+ // the only thing we support is the include directive, but check the contents for that
+
+ // setup our static QRegExp that will catch and directives
+ const QString includeRegExpString = "";
+ QRegExp includeRegExp(includeRegExpString);
+
+ int matchPosition = 0;
+
+
+ while ((matchPosition = includeRegExp.indexIn(localFileString, matchPosition)) != -1) {
+ // check if this is a file or vitual include
+ bool isFileInclude = includeRegExp.cap(1) == "file";
+
+ // setup the correct file path for the included file
+ QString includeFilePath = isFileInclude
+ ? localFileInfo.canonicalPath() + "/" + includeRegExp.cap(2)
+ : _documentRoot + includeRegExp.cap(2);
+
+ QString replacementString;
+
+ if (QFileInfo(includeFilePath).isFile()) {
+
+ QFile includedFile(includeFilePath);
+ includedFile.open(QIODevice::ReadOnly);
+
+ replacementString = QString(includedFile.readAll());
+ } else {
+ qDebug() << "SSI include directive referenced a missing file:" << includeFilePath;
+ }
+
+ // replace the match with the contents of the file, or an empty string if the file was not found
+ localFileString.replace(matchPosition, includeRegExp.matchedLength(), replacementString);
+
+ // push the match position forward so we can check the next match
+ matchPosition += includeRegExp.matchedLength();
+ }
+ }
+
+ connection->respond("200 OK", localFileString.toLocal8Bit(), qPrintable(mimeDatabase.mimeTypeForFile(filePath).name()));
} else {
// respond with a 404
connection->respond("404 Not Found", "Resource not found.");