Add checks for clean disconnect in HTTP/TCP/SSL.

Half-open TCP connection can, of course, only be detected by
writing the socket, or waiting for TCP timeout.
This commit is contained in:
Fabio Alessandrelli 2018-09-14 14:13:11 +02:00
parent 561a7772c6
commit 92de6df113
4 changed files with 66 additions and 3 deletions

View file

@ -375,6 +375,18 @@ Error HTTPClient::poll() {
}
} break;
case STATUS_CONNECTED: {
// Check if we are still connected
if (ssl) {
Ref<StreamPeerSSL> tmp = connection;
tmp->poll();
if (tmp->get_status() != StreamPeerSSL::STATUS_CONNECTED) {
status = STATUS_CONNECTION_ERROR;
return ERR_CONNECTION_ERROR;
}
} else if (tcp_connection->get_status() != StreamPeerTCP::STATUS_CONNECTED) {
status = STATUS_CONNECTION_ERROR;
return ERR_CONNECTION_ERROR;
}
// Connection established, requests can now be made
return OK;
} break;