mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-13 13:01:55 +03:00
WebServer: catch the case when request isn't handled
If RequestHandler::canHandle returns true, but subsequent RequestHandler::handle returns false, we should return some HTTP response instead of an empty one.
This commit is contained in:
@ -362,19 +362,28 @@ void ESP8266WebServer::onNotFound(THandlerFunction fn) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ESP8266WebServer::_handleRequest() {
|
void ESP8266WebServer::_handleRequest() {
|
||||||
|
bool handled = false;
|
||||||
if (!_currentHandler){
|
if (!_currentHandler){
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
DEBUG_OUTPUT.println("request handler not found");
|
DEBUG_OUTPUT.println("request handler not found");
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
handled = _currentHandler->handle(*this, _currentMethod, _currentUri);
|
||||||
|
#ifdef DEBUG
|
||||||
|
if (!handled) {
|
||||||
|
DEBUG_OUTPUT.println("request handler failed to handle request");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!handled) {
|
||||||
if(_notFoundHandler) {
|
if(_notFoundHandler) {
|
||||||
_notFoundHandler();
|
_notFoundHandler();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
send(404, "text/plain", String("Not found: ") + _currentUri);
|
send(404, "text/plain", String("Not found: ") + _currentUri);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
_currentHandler->handle(*this, _currentMethod, _currentUri);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t maxWait = HTTP_MAX_CLOSE_WAIT;
|
uint16_t maxWait = HTTP_MAX_CLOSE_WAIT;
|
||||||
|
Reference in New Issue
Block a user