mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-26 16:55:06 +02:00
allow calls to HTTPManager to skip the subHandler and ask for direct processing
This commit is contained in:
parent
157fdf6afa
commit
4749fdb0ba
6 changed files with 18 additions and 20 deletions
|
@ -1053,10 +1053,11 @@ QString pathForAssignmentScript(const QUuid& assignmentUUID) {
|
||||||
return newPath;
|
return newPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DomainServer::handleHTTPRequest(HTTPConnection* connection, const QUrl& url) {
|
bool DomainServer::handleHTTPRequest(HTTPConnection* connection, const QUrl& url, bool skipSubHandler) {
|
||||||
const QString JSON_MIME_TYPE = "application/json";
|
const QString JSON_MIME_TYPE = "application/json";
|
||||||
|
|
||||||
const QString URI_ASSIGNMENT = "/assignment";
|
const QString URI_ASSIGNMENT = "/assignment";
|
||||||
|
const QString URI_ASSIGNMENT_SCRIPTS = URI_ASSIGNMENT + "/scripts";
|
||||||
const QString URI_NODES = "/nodes";
|
const QString URI_NODES = "/nodes";
|
||||||
|
|
||||||
const QString UUID_REGEX_STRING = "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}";
|
const QString UUID_REGEX_STRING = "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}";
|
||||||
|
@ -1089,11 +1090,8 @@ bool DomainServer::handleHTTPRequest(HTTPConnection* connection, const QUrl& url
|
||||||
scriptURL.setPath(URI_ASSIGNMENT + "/scripts/"
|
scriptURL.setPath(URI_ASSIGNMENT + "/scripts/"
|
||||||
+ uuidStringWithoutCurlyBraces(pendingData->getAssignmentUUID()));
|
+ uuidStringWithoutCurlyBraces(pendingData->getAssignmentUUID()));
|
||||||
|
|
||||||
qDebug() << "Serving" << scriptURL.toString() << "for assignment with ID"
|
|
||||||
<< uuidStringWithoutCurlyBraces(matchingUUID);
|
|
||||||
|
|
||||||
// have the HTTPManager serve the appropriate script file
|
// have the HTTPManager serve the appropriate script file
|
||||||
return _httpManager.handleHTTPRequest(connection, scriptURL);
|
return _httpManager.handleHTTPRequest(connection, scriptURL, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1327,7 +1325,7 @@ bool DomainServer::handleHTTPRequest(HTTPConnection* connection, const QUrl& url
|
||||||
|
|
||||||
const QString HIFI_SESSION_COOKIE_KEY = "DS_WEB_SESSION_UUID";
|
const QString HIFI_SESSION_COOKIE_KEY = "DS_WEB_SESSION_UUID";
|
||||||
|
|
||||||
bool DomainServer::handleHTTPSRequest(HTTPSConnection* connection, const QUrl &url) {
|
bool DomainServer::handleHTTPSRequest(HTTPSConnection* connection, const QUrl &url, bool skipSubHandler) {
|
||||||
const QString URI_OAUTH = "/oauth";
|
const QString URI_OAUTH = "/oauth";
|
||||||
qDebug() << "HTTPS request received at" << url.toString();
|
qDebug() << "HTTPS request received at" << url.toString();
|
||||||
if (url.path() == URI_OAUTH) {
|
if (url.path() == URI_OAUTH) {
|
||||||
|
|
|
@ -43,8 +43,8 @@ public:
|
||||||
|
|
||||||
static int const EXIT_CODE_REBOOT;
|
static int const EXIT_CODE_REBOOT;
|
||||||
|
|
||||||
bool handleHTTPRequest(HTTPConnection* connection, const QUrl& url);
|
bool handleHTTPRequest(HTTPConnection* connection, const QUrl& url, bool skipSubHandler = false);
|
||||||
bool handleHTTPSRequest(HTTPSConnection* connection, const QUrl& url);
|
bool handleHTTPSRequest(HTTPSConnection* connection, const QUrl& url, bool skipSubHandler = false);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
/// Called by NodeList to inform us a node has been added
|
/// Called by NodeList to inform us a node has been added
|
||||||
|
|
|
@ -40,8 +40,8 @@ void HTTPManager::incomingConnection(qintptr socketDescriptor) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HTTPManager::handleHTTPRequest(HTTPConnection* connection, const QUrl& url) {
|
bool HTTPManager::handleHTTPRequest(HTTPConnection* connection, const QUrl& url, bool skipSubHandler) {
|
||||||
if (requestHandledByRequestHandler(connection, url)) {
|
if (!skipSubHandler && requestHandledByRequestHandler(connection, url)) {
|
||||||
// this request was handled by our request handler object
|
// this request was handled by our request handler object
|
||||||
// so we don't need to attempt to do so in the document root
|
// so we don't need to attempt to do so in the document root
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -24,7 +24,7 @@ class HTTPSConnection;
|
||||||
class HTTPRequestHandler {
|
class HTTPRequestHandler {
|
||||||
public:
|
public:
|
||||||
/// Handles an HTTP request.
|
/// Handles an HTTP request.
|
||||||
virtual bool handleHTTPRequest(HTTPConnection* connection, const QUrl& url) = 0;
|
virtual bool handleHTTPRequest(HTTPConnection* connection, const QUrl& url, bool skipSubHandler = false) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Handles HTTP connections
|
/// Handles HTTP connections
|
||||||
|
@ -34,7 +34,7 @@ public:
|
||||||
/// Initializes the manager.
|
/// Initializes the manager.
|
||||||
HTTPManager(quint16 port, const QString& documentRoot, HTTPRequestHandler* requestHandler = NULL, QObject* parent = 0);
|
HTTPManager(quint16 port, const QString& documentRoot, HTTPRequestHandler* requestHandler = NULL, QObject* parent = 0);
|
||||||
|
|
||||||
bool handleHTTPRequest(HTTPConnection* connection, const QUrl& url);
|
bool handleHTTPRequest(HTTPConnection* connection, const QUrl& url, bool skipSubHandler = false);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/// Accepts all pending connections
|
/// Accepts all pending connections
|
||||||
|
|
|
@ -38,12 +38,12 @@ void HTTPSManager::incomingConnection(qintptr socketDescriptor) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HTTPSManager::handleHTTPRequest(HTTPConnection* connection, const QUrl &url) {
|
bool HTTPSManager::handleHTTPRequest(HTTPConnection* connection, const QUrl &url, bool skipSubHandler) {
|
||||||
return handleHTTPSRequest(reinterpret_cast<HTTPSConnection*>(connection), url);
|
return handleHTTPSRequest(reinterpret_cast<HTTPSConnection*>(connection), url, skipSubHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HTTPSManager::handleHTTPSRequest(HTTPSConnection* connection, const QUrl& url) {
|
bool HTTPSManager::handleHTTPSRequest(HTTPSConnection* connection, const QUrl& url, bool skipSubHandler) {
|
||||||
return HTTPManager::handleHTTPRequest(connection, url);
|
return HTTPManager::handleHTTPRequest(connection, url, skipSubHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HTTPSManager::requestHandledByRequestHandler(HTTPConnection* connection, const QUrl& url) {
|
bool HTTPSManager::requestHandledByRequestHandler(HTTPConnection* connection, const QUrl& url) {
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
class HTTPSRequestHandler : public HTTPRequestHandler {
|
class HTTPSRequestHandler : public HTTPRequestHandler {
|
||||||
public:
|
public:
|
||||||
/// Handles an HTTPS request
|
/// Handles an HTTPS request
|
||||||
virtual bool handleHTTPSRequest(HTTPSConnection* connection, const QUrl& url) = 0;
|
virtual bool handleHTTPSRequest(HTTPSConnection* connection, const QUrl& url, bool skipSubHandler = false) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class HTTPSManager : public HTTPManager, public HTTPSRequestHandler {
|
class HTTPSManager : public HTTPManager, public HTTPSRequestHandler {
|
||||||
|
@ -35,8 +35,8 @@ public:
|
||||||
void setCertificate(const QSslCertificate& certificate) { _certificate = certificate; }
|
void setCertificate(const QSslCertificate& certificate) { _certificate = certificate; }
|
||||||
void setPrivateKey(const QSslKey& privateKey) { _privateKey = privateKey; }
|
void setPrivateKey(const QSslKey& privateKey) { _privateKey = privateKey; }
|
||||||
|
|
||||||
bool handleHTTPRequest(HTTPConnection* connection, const QUrl& url);
|
bool handleHTTPRequest(HTTPConnection* connection, const QUrl& url, bool skipSubHandler = false);
|
||||||
bool handleHTTPSRequest(HTTPSConnection* connection, const QUrl& url);
|
bool handleHTTPSRequest(HTTPSConnection* connection, const QUrl& url, bool skipSubHandler = false);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void incomingConnection(qintptr socketDescriptor);
|
void incomingConnection(qintptr socketDescriptor);
|
||||||
|
|
Loading…
Reference in a new issue