diff --git a/README.md b/README.md index a329f2b..10da7f6 100644 --- a/README.md +++ b/README.md @@ -43,16 +43,19 @@ First attempt at a library. Lots more changes and fixes to do. Contributions are   ## Wishlist -- ~~remove dependency on EEPROM library~~ -- ~~move HTML Strings to PROGMEM~~ -- ~~cleanup and streamline code~~ (although this is ongoing) -- if timeout is set, extend it when a page is fetched in AP mode -- ~~add ability to configure more parameters than ssid/password~~ -- ~~maybe allow setting ip of ESP after reboot~~ -- ~~add to Arduino Library Manager~~ -- ~~add to PlatformIO~~ -- add multiple sets of network credentials -- ~~allow users to customize CSS~~ +- [x] remove dependency on EEPROM library +- [x] move HTML Strings to PROGMEM +- [x] cleanup and streamline code (although this is ongoing) +- [x] if timeout is set, extend it when a page is fetched in AP mode +- [x] add ability to configure more parameters than ssid/password +- [x] maybe allow setting ip of ESP after reboot +- [x] add to Arduino Library Manager +- [x] add to PlatformIO +- [ ] add multiple sets of network credentials +- [x] allow users to customize CSS +- [ ] ESP32 support or instructions +- [ ] rewrite documentation for simplicity, based on scenarios/goals +- [ ] rely on the SDK's built in auto connect more than forcing a connect ## Quick Start diff --git a/WiFiManager.cpp b/WiFiManager.cpp index 57c4dc5..a0428e8 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -5,7 +5,7 @@ inspired by: http://www.esp8266.com/viewtopic.php?f=29&t=2520 https://github.com/chriscook8/esp-arduino-apboot - https://github.com/esp8266/Arduino/tree/esp8266/hardware/esp8266com/esp8266/libraries/DNSServer/examples/CaptivePortalAdvanced + https://github.com/esp8266/Arduino/tree/master/libraries/DNSServer/examples/CaptivePortalAdvanced Built by AlexT https://github.com/tzapu Licensed under MIT license **************************************************************/ @@ -480,6 +480,7 @@ void WiFiManager::handleRoot() { page += FPSTR(HTTP_PORTAL_OPTIONS); page += FPSTR(HTTP_END); + server->sendHeader("Content-Length", String(page.length())); server->send(200, "text/html", page); } @@ -572,7 +573,7 @@ void WiFiManager::handleWifi(boolean scan) { } page += FPSTR(HTTP_FORM_START); - char parLength[2]; + char parLength[5]; // add the extra parameters to the form for (int i = 0; i < _paramsCount; i++) { if (_params[i] == NULL) { @@ -599,7 +600,7 @@ void WiFiManager::handleWifi(boolean scan) { pitem.replace("{i}", _params[i]->getID()); pitem.replace("{n}", _params[i]->getID()); pitem.replace("{p}", _params[i]->getPlaceholder()); - snprintf(parLength, 2, "%d", _params[i]->getValueLength()); + snprintf(parLength, 5, "%d", _params[i]->getValueLength()); pitem.replace("{l}", parLength); pitem.replace("{v}", _params[i]->getValue()); pitem.replace("{c}", _params[i]->getCustomHTML()); @@ -650,6 +651,7 @@ void WiFiManager::handleWifi(boolean scan) { page += FPSTR(HTTP_END); + server->sendHeader("Content-Length", String(page.length())); server->send(200, "text/html", page); @@ -709,6 +711,7 @@ void WiFiManager::handleWifiSave() { page += FPSTR(HTTP_SAVED); page += FPSTR(HTTP_END); + server->sendHeader("Content-Length", String(page.length())); server->send(200, "text/html", page); DEBUG_WM(F("Sent wifi save page")); @@ -753,6 +756,7 @@ void WiFiManager::handleInfo() { page += F(""); page += FPSTR(HTTP_END); + server->sendHeader("Content-Length", String(page.length())); server->send(200, "text/html", page); DEBUG_WM(F("Sent info page")); @@ -772,6 +776,8 @@ void WiFiManager::handleReset() { page += FPSTR(HTTP_HEAD_END); page += F("Module will reset in a few seconds."); page += FPSTR(HTTP_END); + + server->sendHeader("Content-Length", String(page.length())); server->send(200, "text/html", page); DEBUG_WM(F("Sent reset page")); @@ -780,23 +786,6 @@ void WiFiManager::handleReset() { delay(2000); } -/** - * HTTPD CALLBACK 204 - * @note removed as mentioned here https://github.com/tzapu/WiFiManager/issues/114 - */ -/* -void WiFiManager::handle204() { - DEBUG_WM(F("204 No Response")); - server->sendHeader("Cache-Control", "no-cache, no-store, must-revalidate"); - server->sendHeader("Pragma", "no-cache"); - server->sendHeader("Expires", "-1"); - server->send ( 204, "text/plain", ""); -} -*/ - -/** - * HTTPD CALLBACK 404 - */ void WiFiManager::handleNotFound() { if (captivePortal()) { // If captive portal redirect instead of displaying the error page. return; @@ -816,6 +805,7 @@ void WiFiManager::handleNotFound() { server->sendHeader("Cache-Control", "no-cache, no-store, must-revalidate"); server->sendHeader("Pragma", "no-cache"); server->sendHeader("Expires", "-1"); + server->sendHeader("Content-Length", String(message.length())); server->send ( 404, "text/plain", message ); } diff --git a/WiFiManager.h b/WiFiManager.h index c466c9c..52b74fe 100644 --- a/WiFiManager.h +++ b/WiFiManager.h @@ -5,7 +5,7 @@ inspired by: http://www.esp8266.com/viewtopic.php?f=29&t=2520 https://github.com/chriscook8/esp-arduino-apboot - https://github.com/esp8266/Arduino/tree/esp8266/hardware/esp8266com/esp8266/libraries/DNSServer/examples/CaptivePortalAdvanced + https://github.com/esp8266/Arduino/tree/master/libraries/DNSServer/examples/CaptivePortalAdvanced Built by AlexT https://github.com/tzapu Licensed under MIT license **************************************************************/ @@ -30,7 +30,7 @@ const char HTTP_PORTAL_OPTIONS[] PROGMEM = "
"; const char HTTP_SCAN_LINK[] PROGMEM = "