mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
Merge remote-tracking branch 'refs/remotes/hyperion-project/master' into weba
This commit is contained in:
@@ -73,6 +73,13 @@ static inline void printErrorToReply (QtHttpReply * reply, QString errorMessage)
|
||||
reply->appendRawData (errorMessage.toLocal8Bit ());
|
||||
}
|
||||
|
||||
static inline void printError404ToReply (QtHttpReply * reply, QString errorMessage)
|
||||
{
|
||||
reply->setStatusCode(QtHttpReply::NotFound);
|
||||
reply->addHeader ("Content-Type", QByteArrayLiteral ("text/plain"));
|
||||
reply->appendRawData (errorMessage.toLocal8Bit ());
|
||||
}
|
||||
|
||||
void StaticFileServing::onRequestNeedsReply (QtHttpRequest * request, QtHttpReply * reply)
|
||||
{
|
||||
QString command = request->getCommand ();
|
||||
@@ -103,7 +110,7 @@ void StaticFileServing::onRequestNeedsReply (QtHttpRequest * request, QtHttpRepl
|
||||
Q_INIT_RESOURCE(WebConfig);
|
||||
|
||||
QFileInfo info(_baseUrl % "/" % path);
|
||||
if ( path == "/" || path.isEmpty() || ! info.exists() )
|
||||
if ( path == "/" || path.isEmpty() )
|
||||
{
|
||||
path = "index.html";
|
||||
}
|
||||
@@ -134,7 +141,7 @@ void StaticFileServing::onRequestNeedsReply (QtHttpRequest * request, QtHttpRepl
|
||||
}
|
||||
else
|
||||
{
|
||||
printErrorToReply (reply, "Requested file " % path % " couldn't be found !");
|
||||
printError404ToReply (reply, "404 Not Found\n" % path % " couldn't be found !");
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@@ -23,7 +23,7 @@ WebConfig::WebConfig(QObject * parent)
|
||||
_baseUrl = webconfigConfig["document_root"].toString(_baseUrl);
|
||||
}
|
||||
|
||||
if (_baseUrl != ":/webconfig")
|
||||
if ( (_baseUrl != ":/webconfig") && !_baseUrl.trimmed().isEmpty())
|
||||
{
|
||||
QFileInfo info(_baseUrl);
|
||||
if (!info.exists() || !info.isDir())
|
||||
@@ -32,6 +32,8 @@ WebConfig::WebConfig(QObject * parent)
|
||||
_baseUrl = WEBCONFIG_DEFAULT_PATH;
|
||||
}
|
||||
}
|
||||
else
|
||||
_baseUrl = WEBCONFIG_DEFAULT_PATH;
|
||||
|
||||
Debug(log, "WebUI initialized, document root: %s", _baseUrl.toUtf8().constData());
|
||||
if ( webconfigEnable )
|
||||
|
Reference in New Issue
Block a user