Typo fixes for webcode error type

Add ping function to check status
This commit is contained in:
Luc 2020-10-07 16:17:28 +02:00
parent f3f44786c0
commit 4124fa9148
3 changed files with 10 additions and 3 deletions

View File

@ -34,6 +34,10 @@
void HTTP_Server::handle_web_command ()
{
level_authenticate_type auth_level = AuthenticationService::authenticated_level();
if (auth_level == LEVEL_GUEST) {
_webserver->send (401, "text/plain", "Wrong authentication!");
return;
}
//log_esp3d("Authentication = %d", auth_level);
String cmd = "";
if (_webserver->hasArg ("cmd")) {
@ -43,7 +47,10 @@ void HTTP_Server::handle_web_command ()
cmd+="\n"; //need to validate command
}
esp3d_commands.process((uint8_t*)cmd.c_str(), cmd.length(), &output, auth_level);
} else {
} else if (_webserver->hasArg ("ping")) {
_webserver->send (200);
}
else {
_webserver->send (400, "text/plain", "Invalid command");
}
return;

View File

@ -146,7 +146,7 @@ bool HTTP_Server::StreamSDFile(const char* filename, const char * contentType)
}
#endif //SD_DEVICE
void HTTP_Server::pushError(int code, const char * st, bool web_error, uint16_t timeout)
void HTTP_Server::pushError(int code, const char * st, uint8_t web_error, uint16_t timeout)
{
if (websocket_terminal_server.started() && st) {
String s = "ERROR:" + String(code) + ":";

View File

@ -57,7 +57,7 @@ public:
return _port;
}
private:
static void pushError(int code, const char * st, bool web_error = 500, uint16_t timeout = 1000);
static void pushError(int code, const char * st, uint8_t web_error = 500, uint16_t timeout = 1000);
static void cancelUpload();
static bool _started;
static WEBSERVER * _webserver;