Changed a declaration of emptyString

pull/126/head
Hieromon Ikasamo 5 years ago
parent 29e876fbf6
commit f14e507a81
  1. 9
      examples/WebUpdate/HTTPUpdateServer.cpp
  2. 5
      examples/WebUpdate/HTTPUpdateServer.h

@ -47,7 +47,7 @@ void HTTPUpdateServer::setup(WebServer* server, const String& path, const String
// handler for the /update form page
_server->on(path.c_str(), HTTP_GET, [&] () {
if (_username != emptyString && _password != emptyString && !_server->authenticate(_username.c_str(), _password.c_str()))
if (_username != _emptyString && _password != _emptyString && !_server->authenticate(_username.c_str(), _password.c_str()))
return _server->requestAuthentication();
_server->send_P(200, PSTR("text/html"), serverIndex);
});
@ -76,7 +76,7 @@ void HTTPUpdateServer::setup(WebServer* server, const String& path, const String
if (_serial_output)
Serial.setDebugOutput(true);
_authenticated = (_username == emptyString || _password == emptyString || _server->authenticate(_username.c_str(), _password.c_str()));
_authenticated = (_username == _emptyString || _password == _emptyString || _server->authenticate(_username.c_str(), _password.c_str()));
if (!_authenticated) {
if (_serial_output)
Serial.println("Unauthenticated Update");
@ -127,4 +127,9 @@ void HTTPUpdateServer::_setUpdaterError() {
_updaterError = str.c_str();
}
/**
* Shared empty String instance
*/
const String HTTPUpdateServer::_emptyString;
#endif // !ARDUINO_ARCH_ESP32

@ -20,8 +20,8 @@ class HTTPUpdateServer {
public:
explicit HTTPUpdateServer(bool serial_debug = false) : _serial_output(serial_debug), _server(nullptr), _username(emptyString), _password(emptyString), _authenticated(false) {}
~HTTPUpdateServer() {}
void setup(WebServer* server) { setup(server, emptyString, emptyString); }
void setup(WebServer* server, const String& path) { setup(server, path, emptyString, emptyString); }
void setup(WebServer* server) { setup(server, _emptyString, _emptyString); }
void setup(WebServer* server, const String& path) { setup(server, path, _emptyString, _emptyString); }
void setup(WebServer* server, const String& username, const String& password) { setup(server, "/update", username, password); }
void setup(WebServer* server, const String& path, const String& username, const String& password);
void updateCredentials(const String& username, const String& password) { _username = username; _password = password; }
@ -36,6 +36,7 @@ class HTTPUpdateServer {
String _password;
bool _authenticated;
String _updaterError;
static const String _emptyString;
};
#endif // !ARDUINO_ARCH_ESP32

Loading…
Cancel
Save