mirror of
https://github.com/me-no-dev/ESPAsyncWebServer.git
synced 2025-09-27 14:50:56 +02:00
Explicitly close socket after response has entered finished state
In at least two places in the code, the response object is evaluated on whether it has finished sending data to the client. If the response has already finished, or enters the finished state after sending data, the underlying socket should not be left open. Failure to close the socket in these scenarios cause the remote client to timeout expecting more data unless it closes the connection on its own. Fixes: #802
This commit is contained in:
@@ -189,8 +189,16 @@ void AsyncWebServerRequest::_removeNotInterestingHeaders(){
|
|||||||
|
|
||||||
void AsyncWebServerRequest::_onPoll(){
|
void AsyncWebServerRequest::_onPoll(){
|
||||||
//os_printf("p\n");
|
//os_printf("p\n");
|
||||||
if(_response != NULL && _client != NULL && _client->canSend() && !_response->_finished()){
|
if(_response != NULL && _client != NULL && _client->canSend()){
|
||||||
|
if(!_response->_finished()){
|
||||||
_response->_ack(this, 0, 0);
|
_response->_ack(this, 0, 0);
|
||||||
|
} else {
|
||||||
|
AsyncWebServerResponse* r = _response;
|
||||||
|
_response = NULL;
|
||||||
|
delete r;
|
||||||
|
|
||||||
|
_client->close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -199,10 +207,13 @@ void AsyncWebServerRequest::_onAck(size_t len, uint32_t time){
|
|||||||
if(_response != NULL){
|
if(_response != NULL){
|
||||||
if(!_response->_finished()){
|
if(!_response->_finished()){
|
||||||
_response->_ack(this, len, time);
|
_response->_ack(this, len, time);
|
||||||
} else {
|
}
|
||||||
|
if(_response->_finished()){
|
||||||
AsyncWebServerResponse* r = _response;
|
AsyncWebServerResponse* r = _response;
|
||||||
_response = NULL;
|
_response = NULL;
|
||||||
delete r;
|
delete r;
|
||||||
|
|
||||||
|
_client->close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user