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) {
|
QtHttpClientWrapper::ParsingStatus QtHttpClientWrapper::sendReplyToClient (QtHttpReply * reply) {
|
||||||
if (reply != Q_NULLPTR) {
|
if (reply != Q_NULLPTR) {
|
||||||
if (!reply->useChunked ()) {
|
if (!reply->useChunked ()) {
|
||||||
reply->appendRawData (CRLF);
|
//reply->appendRawData (CRLF);
|
||||||
// send all headers and all data in one shot
|
// send all headers and all data in one shot
|
||||||
reply->requestSendHeaders ();
|
reply->requestSendHeaders ();
|
||||||
reply->requestSendData ();
|
reply->requestSendData ();
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QPair>
|
#include <QPair>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
|
#include <QFileInfo>
|
||||||
|
|
||||||
StaticFileServing::StaticFileServing (Hyperion *hyperion, QString baseUrl, quint16 port, QObject * parent)
|
StaticFileServing::StaticFileServing (Hyperion *hyperion, QString baseUrl, quint16 port, QObject * parent)
|
||||||
: QObject (parent)
|
: QObject (parent)
|
||||||
@ -75,12 +76,23 @@ void StaticFileServing::onRequestNeedsReply (QtHttpRequest * request, QtHttpRepl
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// get static files
|
QFileInfo info(_baseUrl % "/" % path);
|
||||||
if ( path == "/" || path.isEmpty() || ! QFile::exists(_baseUrl % "/" % path) )
|
if ( path == "/" || path.isEmpty() || ! info.exists() )
|
||||||
|
{
|
||||||
path = "index.html";
|
path = "index.html";
|
||||||
|
}
|
||||||
|
else if (info.isDir() && path.endsWith("/") )
|
||||||
|
{
|
||||||
|
path += "index.html";
|
||||||
|
}
|
||||||
|
else if (info.isDir() && ! path.endsWith("/") )
|
||||||
|
{
|
||||||
|
path += "/index.html";
|
||||||
|
}
|
||||||
|
|
||||||
QFile file (_baseUrl % "/" % path);
|
// get static files
|
||||||
if (file.exists ())
|
QFile file(_baseUrl % "/" % path);
|
||||||
|
if (file.exists())
|
||||||
{
|
{
|
||||||
QMimeType mime = _mimeDb->mimeTypeForFile (file.fileName ());
|
QMimeType mime = _mimeDb->mimeTypeForFile (file.fileName ());
|
||||||
if (file.open (QFile::ReadOnly)) {
|
if (file.open (QFile::ReadOnly)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user