mirror of
				https://github.com/hyperion-project/hyperion.ng.git
				synced 2025-03-01 10:33:28 +00:00 
			
		
		
		
	webserver fix (#181)
fix default index.html in subfolders fix \r\n appended to data
This commit is contained in:
		| @@ -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) | ||||||
| @@ -74,13 +75,24 @@ void StaticFileServing::onRequestNeedsReply (QtHttpRequest * request, QtHttpRepl | |||||||
| 			} | 			} | ||||||
| 			return; | 			return; | ||||||
| 		} | 		} | ||||||
| 		 |  | ||||||
| 		// get static files |  | ||||||
| 		if ( path == "/" || path.isEmpty() || ! QFile::exists(_baseUrl % "/" % path) ) |  | ||||||
| 			path = "index.html"; |  | ||||||
|  |  | ||||||
| 		QFile file (_baseUrl % "/" % path); | 		QFileInfo info(_baseUrl % "/" % path); | ||||||
| 		if (file.exists ()) | 		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 ()); | 			QMimeType mime = _mimeDb->mimeTypeForFile (file.fileName ()); | ||||||
| 			if (file.open (QFile::ReadOnly)) { | 			if (file.open (QFile::ReadOnly)) { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user