Check just for http availability

This commit is contained in:
Leonardo Murillo 2015-01-26 13:45:14 -06:00
parent 18e0a91ea8
commit d26804e68c

View file

@ -173,23 +173,12 @@ void IceServer::clearInactivePeers() {
bool IceServer::handleHTTPRequest(HTTPConnection* connection, const QUrl& url, bool skipSubHandler) { bool IceServer::handleHTTPRequest(HTTPConnection* connection, const QUrl& url, bool skipSubHandler) {
// //
// We need an HTTP handler in order to monitor the health of the ice server // We need an HTTP handler in order to monitor the health of the ice server
// The correct functioning of the ICE server will first be determined by its HTTP availability, // The correct functioning of the ICE server will be determined by its HTTP availability,
// and then by the existence of a minimum number of peers in the list, matching the minimum number of
// domains in production by High Fidelity.
// //
int MINIMUM_PEERS = 3;
bool IS_HEALTHY = false;
IS_HEALTHY = _activePeers.size() >= MINIMUM_PEERS ? true : false;
if (connection->requestOperation() == QNetworkAccessManager::GetOperation) { if (connection->requestOperation() == QNetworkAccessManager::GetOperation) {
if (url.path() == "/status") { if (url.path() == "/status") {
if (IS_HEALTHY) { connection->respond(HTTPConnection::StatusCode200, QByteArray::number(_activePeers.size()));
connection->respond(HTTPConnection::StatusCode200, QByteArray::number(_activePeers.size()));
} else {
connection->respond(HTTPConnection::StatusCode404, QByteArray::number(_activePeers.size()));
}
} }
} }
return true; return true;