Added onDisconnect#173
Conversation
|
maybe implement this in the base web handler class? |
|
Actually wait... you should be allocating those resources in the Response classes and not in the Handler classes. Basically you will get the disconnect while you are responding, request disconnects are handled already. |
|
@faceless2 @me-no-dev Instead of adding a new parameter in request creation, the call is defined in request itself to make it as flexible as possible: in ESPAsyncWebServer.h in WebRequest.cpp So in any handler that need a disconnect call, the customized function can be added (or not): What do you think ? I know the style is little bit raw, any chance to get such thing implemented ? |
I've added an "onDisconnect" handler to the AsyncCallbackWebHandler class. The reasoning behind this is when uploading content as part of the request body, resources may need to be allocated to handle this. But if the upload terminates early there was no way to free those resources (well, none that I could idenitfy).
With this patch I can now do this:
and know that the "onDisconnect" method will always be called, even on error.