Fix: WebUI port switch reconnect

The WebUI will get now the new port for next reconnect
It was necessary to add the Access-Control-Allow-Origin header with a wildcard for file serving
This commit is contained in:
brindosch
2019-07-18 22:32:06 +02:00
parent fcd11176f8
commit 7e324bb1d3
6 changed files with 26 additions and 15 deletions

View File

@@ -30,6 +30,7 @@ const QByteArray & QtHttpHeader::Location = QByteArrayLiteral ("Loca
const QByteArray & QtHttpHeader::SetCookie = QByteArrayLiteral ("Set-Cookie");
const QByteArray & QtHttpHeader::TransferEncoding = QByteArrayLiteral ("Transfer-Encoding");
const QByteArray & QtHttpHeader::ContentDisposition = QByteArrayLiteral ("Content-Disposition");
const QByteArray & QtHttpHeader::AccessControlAllow = QByteArrayLiteral ("Access-Control-Allow-Origin");
const QByteArray & QtHttpHeader::Upgrade = QByteArrayLiteral ("Upgrade");
const QByteArray & QtHttpHeader::SecWebSocketKey = QByteArrayLiteral ("Sec-WebSocket-Key");
const QByteArray & QtHttpHeader::SecWebSocketProtocol = QByteArrayLiteral ("Sec-WebSocket-Protocol");

View File

@@ -32,6 +32,7 @@ public:
static const QByteArray & SetCookie;
static const QByteArray & TransferEncoding;
static const QByteArray & ContentDisposition;
static const QByteArray & AccessControlAllow;
// Websocket specific headers
static const QByteArray & Upgrade;
static const QByteArray & SecWebSocketKey;

View File

@@ -135,6 +135,7 @@ void StaticFileServing::onRequestNeedsReply (QtHttpRequest * request, QtHttpRepl
if (file.open (QFile::ReadOnly)) {
QByteArray data = file.readAll ();
reply->addHeader ("Content-Type", mime.name ().toLocal8Bit ());
reply->addHeader(QtHttpHeader::AccessControlAllow, "*" );
reply->appendRawData (data);
file.close ();
}