Reset connection when appropriate + some code cleanup - #180
Conversation
| if (_response == NULL) { | ||
| _client->close(true); | ||
| _onDisconnect(); | ||
| _sent = true; | ||
| return; | ||
| } |
There was a problem hiding this comment.
I've removed this weird use case where a user could just decide to close the connection by doing send(null). IMO this is wrong because once a correctly formed http request goes through, it should be handled as a http request and a response should be sent.
closing the connection eagerly would also break the middleware chain since middleware acting after the handler is executing won't have any effect.
There was a problem hiding this comment.
send(null) now has the same effect has an empty handler:
// curl -v -X GET http://192.168.4.1/handler-not-sending-response
server.on("/handler-not-sending-response", HTTP_GET, [](AsyncWebServerRequest* request) {
// handler forgot to send a response to the client => 501 Not Implemented
});
Wow! Looks like this thing could be hired instead of ppl like me :))) |
I also rarely use it, but only when I want to get a summary of something instead of searching on Internet. Which it id a great job here I think ;-) |
I went over the code base to do a little cleanup of the calls to close() which should instead be abort when related to connection problems or request parsing problems.
ChatGPT summarises the use cases pretty well: https://chatgpt.com/share/6763e68c-8900-8007-b540-16156d04d13c