mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 07:49:52 +03:00
close only on 406
This commit is contained in:
@@ -43,7 +43,6 @@ void UploadFileService::handleUpload(AsyncWebServerRequest * request, const Stri
|
|||||||
} else {
|
} else {
|
||||||
md5[0] = '\0';
|
md5[0] = '\0';
|
||||||
handleError(request, 406); // Not Acceptable - unsupported file type
|
handleError(request, 406); // Not Acceptable - unsupported file type
|
||||||
request->client()->abort();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -134,7 +133,7 @@ void UploadFileService::uploadComplete(AsyncWebServerRequest * request) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
handleError(request, 406); // send the forbidden response
|
handleError(request, 500);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UploadFileService::handleError(AsyncWebServerRequest * request, int code) {
|
void UploadFileService::handleError(AsyncWebServerRequest * request, int code) {
|
||||||
@@ -146,8 +145,14 @@ void UploadFileService::handleError(AsyncWebServerRequest * request, int code) {
|
|||||||
// send the error code to the client and record the error code in the temp object
|
// send the error code to the client and record the error code in the temp object
|
||||||
AsyncWebServerResponse * response = request->beginResponse(code);
|
AsyncWebServerResponse * response = request->beginResponse(code);
|
||||||
request->send(response);
|
request->send(response);
|
||||||
|
|
||||||
|
// check for invalid extension and immediately kill the connection, which will through an error
|
||||||
|
// that is caught by the web code. Unfortunately the http error code is not sent to the client on fast network connections
|
||||||
|
if (code == 406) {
|
||||||
|
request->client()->close(true);
|
||||||
handleEarlyDisconnect();
|
handleEarlyDisconnect();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void UploadFileService::handleEarlyDisconnect() {
|
void UploadFileService::handleEarlyDisconnect() {
|
||||||
is_firmware = false;
|
is_firmware = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user