mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
webserver fix (#181)
fix default index.html in subfolders fix \r\n appended to data
This commit is contained in:
parent
c00edfb658
commit
26a70170fb
@ -187,7 +187,7 @@ void QtHttpClientWrapper::onReplySendDataRequested (void) {
|
||||
QtHttpClientWrapper::ParsingStatus QtHttpClientWrapper::sendReplyToClient (QtHttpReply * reply) {
|
||||
if (reply != Q_NULLPTR) {
|
||||
if (!reply->useChunked ()) {
|
||||
reply->appendRawData (CRLF);
|
||||
//reply->appendRawData (CRLF);
|
||||
// send all headers and all data in one shot
|
||||
reply->requestSendHeaders ();
|
||||
reply->requestSendData ();
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include <QList>
|
||||
#include <QPair>
|
||||
#include <QFile>
|
||||
#include <QFileInfo>
|
||||
|
||||
StaticFileServing::StaticFileServing (Hyperion *hyperion, QString baseUrl, quint16 port, QObject * parent)
|
||||
: QObject (parent)
|
||||
@ -74,13 +75,24 @@ void StaticFileServing::onRequestNeedsReply (QtHttpRequest * request, QtHttpRepl
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// get static files
|
||||
if ( path == "/" || path.isEmpty() || ! QFile::exists(_baseUrl % "/" % path) )
|
||||
path = "index.html";
|
||||
|
||||
QFile file (_baseUrl % "/" % path);
|
||||
if (file.exists ())
|
||||
QFileInfo info(_baseUrl % "/" % path);
|
||||
if ( path == "/" || path.isEmpty() || ! info.exists() )
|
||||
{
|
||||
path = "index.html";
|
||||
}
|
||||
else if (info.isDir() && path.endsWith("/") )
|
||||
{
|
||||
path += "index.html";
|
||||
}
|
||||
else if (info.isDir() && ! path.endsWith("/") )
|
||||
{
|
||||
path += "/index.html";
|
||||
}
|
||||
|
||||
// get static files
|
||||
QFile file(_baseUrl % "/" % path);
|
||||
if (file.exists())
|
||||
{
|
||||
QMimeType mime = _mimeDb->mimeTypeForFile (file.fileName ());
|
||||
if (file.open (QFile::ReadOnly)) {
|
||||
|
Loading…
Reference in New Issue
Block a user