force temp domain reset on 404 too (401 already)

This commit is contained in:
Zach Pomerantz 2016-06-17 19:26:22 -07:00
parent a6115cba6e
commit 4a30d549ad

View file

@ -1121,8 +1121,10 @@ void DomainServer::handleMetaverseHeartbeatError(QNetworkReply& requestReply) {
return;
}
// if we have a temporary domain with a bad token, we will get a 401
if (requestReply.error() == QNetworkReply::NetworkError::AuthenticationRequiredError) {
// check if we need to force a new temporary domain name
switch (requestReply.error()) {
// if we have a temporary domain with a bad token, we get a 401
case QNetworkReply::NetworkError::AuthenticationRequiredError: {
static const QString DATA_KEY = "data";
static const QString TOKEN_KEY = "api_key";
@ -1131,6 +1133,17 @@ void DomainServer::handleMetaverseHeartbeatError(QNetworkReply& requestReply) {
if (!tokenFailure.isNull()) {
qWarning() << "Temporary domain name lacks a valid API key, and is being reset.";
}
break;
}
// if the domain does not (or no longer) exists, we get a 404
case QNetworkReply::NetworkError::ContentNotFoundError:
qWarning() << "Domain not found, getting a new temporary domain.";
break;
// otherwise, we erred on something else, and should not force a temporary domain
default:
return;
}
// halt heartbeats until we have a token
_metaverseHeartbeatTimer->deleteLater();
@ -1142,8 +1155,8 @@ void DomainServer::handleMetaverseHeartbeatError(QNetworkReply& requestReply) {
if (++attempt < MAX_ATTEMPTS) {
// get a new temporary name and token
getTemporaryName(true);
}
}
} else {
qWarning() << "Already attempted too many temporary domain requests. Please set a domain ID manually or restart.";
}
}