check if client is still connected fpr async replies

This commit is contained in:
Simon Stürz 2015-09-22 09:44:08 +02:00 committed by Michael Zanetti
parent 10b5d77ef6
commit 0e3ddf724b
2 changed files with 9 additions and 4 deletions

View File

@ -50,7 +50,7 @@
"idName": "updateTime",
"name": "last update",
"unit": "UnixTime",
"type": "uint",
"type": "int",
"defaultValue": 0
},
{

View File

@ -142,16 +142,21 @@ void RestServer::asyncReplyFinished()
m_asyncReplies.remove(clientId);
qCDebug(dcWebServer) << "Async reply finished";
reply->setClientId(clientId);
// check if the reply timeouted
if (reply->timedOut()) {
reply->clear();
reply->setHttpStatusCode(HttpReply::GatewayTimeout);
}
m_webserver->sendHttpReply(reply);
// check if client is still connected
if (!m_clientList.contains(clientId)) {
qCWarning(dcWebServer) << "Client for async reply not longer connected.";
} else {
reply->setClientId(clientId);
m_webserver->sendHttpReply(reply);
}
reply->deleteLater();
}
}