diff --git a/changelog.md b/changelog.md index 499f14e..b502168 100644 --- a/changelog.md +++ b/changelog.md @@ -11,6 +11,7 @@ ## Table of contents * [Changelog](#changelog) + * [Releases v1.6.1](#releases-v161) * [Releases v1.6.0](#releases-v160) * [Releases v1.5.0](#releases-v150) * [Releases v1.4.1](#releases-v141) @@ -26,6 +27,10 @@ ## Changelog +#### Releases v1.6.1 + +1. Don't need `memmove()`, CString no longer destroyed. Check [All memmove() removed - string no longer destroyed #11](https://github.com/khoih-prog/Portenta_H7_AsyncWebServer/pull/11) + #### Releases v1.6.0 1. Support using `CString` to save heap to send `very large data`. Check [request->send(200, textPlainStr, jsonChartDataCharStr); - Without using String Class - to save heap #8](https://github.com/khoih-prog/Portenta_H7_AsyncWebServer/pull/8) diff --git a/library.json b/library.json index 5a70f51..18c5115 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name":"AsyncWebServer_WT32_ETH01", - "version": "1.6.0", + "version": "1.6.1", "description":"Asynchronous HTTP and WebSocket Server Library for WT32_ETH01 (ESP32 + LAN8720). Now supporting using CString to save heap to send very large data", "keywords":"http, async, async-webserver, websocket, webserver, esp32, wt32-eth01, lan8720, lan8720a", "authors": diff --git a/library.properties b/library.properties index 0ab5ae5..e1b5825 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=AsyncWebServer_WT32_ETH01 -version=1.6.0 +version=1.6.1 author=Hristo Gochkov,Khoi Hoang maintainer=Khoi Hoang license=GPLv3 diff --git a/src/AsyncEventSource.cpp b/src/AsyncEventSource.cpp index 540e00f..98305d5 100644 --- a/src/AsyncEventSource.cpp +++ b/src/AsyncEventSource.cpp @@ -22,7 +22,7 @@ You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - Version: 1.6.0 + Version: 1.6.1 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -34,6 +34,7 @@ 1.4.1 K Hoang 29/11/2021 Fix bug in examples to reduce connection time 1.5.0 K Hoang 01/10/2022 Fix AsyncWebSocket bug 1.6.0 K Hoang 04/10/2022 Option to use cString instead of String to save Heap + 1.6.1 K Hoang 05/10/2022 Don't need memmove(), String no longer destroyed *****************************************************************************************************************************/ #include "Arduino.h" diff --git a/src/AsyncEventSource.h b/src/AsyncEventSource.h index 49b2ea3..ab8d434 100644 --- a/src/AsyncEventSource.h +++ b/src/AsyncEventSource.h @@ -22,7 +22,7 @@ You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - Version: 1.6.0 + Version: 1.6.1 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -34,6 +34,7 @@ 1.4.1 K Hoang 29/11/2021 Fix bug in examples to reduce connection time 1.5.0 K Hoang 01/10/2022 Fix AsyncWebSocket bug 1.6.0 K Hoang 04/10/2022 Option to use cString instead of String to save Heap + 1.6.1 K Hoang 05/10/2022 Don't need memmove(), String no longer destroyed *****************************************************************************************************************************/ #ifndef ASYNCEVENTSOURCE_H_ diff --git a/src/AsyncJson.h b/src/AsyncJson.h index 7413334..8877588 100644 --- a/src/AsyncJson.h +++ b/src/AsyncJson.h @@ -22,7 +22,7 @@ You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - Version: 1.6.0 + Version: 1.6.1 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -34,6 +34,7 @@ 1.4.1 K Hoang 29/11/2021 Fix bug in examples to reduce connection time 1.5.0 K Hoang 01/10/2022 Fix AsyncWebSocket bug 1.6.0 K Hoang 04/10/2022 Option to use cString instead of String to save Heap + 1.6.1 K Hoang 05/10/2022 Don't need memmove(), String no longer destroyed *****************************************************************************************************************************/ /* Async Response to use with ArduinoJson and AsyncWebServer diff --git a/src/AsyncWebServer_WT32_ETH01.cpp b/src/AsyncWebServer_WT32_ETH01.cpp index d220ca7..55c6efb 100644 --- a/src/AsyncWebServer_WT32_ETH01.cpp +++ b/src/AsyncWebServer_WT32_ETH01.cpp @@ -22,7 +22,7 @@ You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - Version: 1.6.0 + Version: 1.6.1 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -34,6 +34,7 @@ 1.4.1 K Hoang 29/11/2021 Fix bug in examples to reduce connection time 1.5.0 K Hoang 01/10/2022 Fix AsyncWebSocket bug 1.6.0 K Hoang 04/10/2022 Option to use cString instead of String to save Heap + 1.6.1 K Hoang 05/10/2022 Don't need memmove(), String no longer destroyed *****************************************************************************************************************************/ #include "AsyncWebServer_WT32_ETH01.h" diff --git a/src/AsyncWebServer_WT32_ETH01.h b/src/AsyncWebServer_WT32_ETH01.h index 5829c1a..cbe105a 100644 --- a/src/AsyncWebServer_WT32_ETH01.h +++ b/src/AsyncWebServer_WT32_ETH01.h @@ -22,7 +22,7 @@ You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - Version: 1.6.0 + Version: 1.6.1 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -34,6 +34,7 @@ 1.4.1 K Hoang 29/11/2021 Fix bug in examples to reduce connection time 1.5.0 K Hoang 01/10/2022 Fix AsyncWebSocket bug 1.6.0 K Hoang 04/10/2022 Option to use cString instead of String to save Heap + 1.6.1 K Hoang 05/10/2022 Don't need memmove(), String no longer destroyed *****************************************************************************************************************************/ #ifndef _AsyncWebServer_WT32_ETH01_H_ @@ -61,16 +62,22 @@ #warning Using code for ESP32 core v2.0.0+ in AsyncWebServer_WT32_ETH01.h #endif - #define ASYNC_WEBSERVER_WT32_ETH01_VERSION "AsyncWebServer_WT32_ETH01 v1.6.0 for core v2.0.0+" + #define ASYNC_WEBSERVER_WT32_ETH01_VERSION "AsyncWebServer_WT32_ETH01 v1.6.1 for core v2.0.0+" #else #if (_ASYNC_WEBSERVER_LOGLEVEL_ > 2 ) #warning Using code for ESP32 core v1.0.6- in AsyncWebServer_WT32_ETH01.h #endif - #define ASYNC_WEBSERVER_WT32_ETH01_VERSION "AsyncWebServer_WT32_ETH01 v1.6.0 for core v1.0.6-" + #define ASYNC_WEBSERVER_WT32_ETH01_VERSION "AsyncWebServer_WT32_ETH01 v1.6.1 for core v1.0.6-" #endif +#define ASYNC_WEBSERVER_WT32_ETH01_VERSION_MAJOR 1 +#define ASYNC_WEBSERVER_WT32_ETH01_VERSION_MINOR 6 +#define ASYNC_WEBSERVER_WT32_ETH01_VERSION_PATCH 1 + +#define ASYNC_WEBSERVER_WT32_ETH01_VERSION_INT 1006001 + ///////////////////////////////////////////////// #ifndef WT32_ETH01_AWS_UNUSED diff --git a/src/AsyncWebServer_WT32_ETH01_Debug.h b/src/AsyncWebServer_WT32_ETH01_Debug.h index 86a41d8..708bd77 100644 --- a/src/AsyncWebServer_WT32_ETH01_Debug.h +++ b/src/AsyncWebServer_WT32_ETH01_Debug.h @@ -22,7 +22,7 @@ You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - Version: 1.6.0 + Version: 1.6.1 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -34,6 +34,7 @@ 1.4.1 K Hoang 29/11/2021 Fix bug in examples to reduce connection time 1.5.0 K Hoang 01/10/2022 Fix AsyncWebSocket bug 1.6.0 K Hoang 04/10/2022 Option to use cString instead of String to save Heap + 1.6.1 K Hoang 05/10/2022 Don't need memmove(), String no longer destroyed *****************************************************************************************************************************/ #pragma once diff --git a/src/AsyncWebSocket.cpp b/src/AsyncWebSocket.cpp index c65a462..9ff3705 100644 --- a/src/AsyncWebSocket.cpp +++ b/src/AsyncWebSocket.cpp @@ -22,7 +22,7 @@ You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - Version: 1.6.0 + Version: 1.6.1 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -34,6 +34,7 @@ 1.4.1 K Hoang 29/11/2021 Fix bug in examples to reduce connection time 1.5.0 K Hoang 01/10/2022 Fix AsyncWebSocket bug 1.6.0 K Hoang 04/10/2022 Option to use cString instead of String to save Heap + 1.6.1 K Hoang 05/10/2022 Don't need memmove(), String no longer destroyed *****************************************************************************************************************************/ #include "Arduino.h" diff --git a/src/AsyncWebSocket.h b/src/AsyncWebSocket.h index 4205818..906cf67 100644 --- a/src/AsyncWebSocket.h +++ b/src/AsyncWebSocket.h @@ -22,7 +22,7 @@ You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - Version: 1.6.0 + Version: 1.6.1 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -34,6 +34,7 @@ 1.4.1 K Hoang 29/11/2021 Fix bug in examples to reduce connection time 1.5.0 K Hoang 01/10/2022 Fix AsyncWebSocket bug 1.6.0 K Hoang 04/10/2022 Option to use cString instead of String to save Heap + 1.6.1 K Hoang 05/10/2022 Don't need memmove(), String no longer destroyed *****************************************************************************************************************************/ #ifndef ASYNCWEBSOCKET_H_ diff --git a/src/AsyncWebSynchronization.h b/src/AsyncWebSynchronization.h index edb6741..5bb405a 100644 --- a/src/AsyncWebSynchronization.h +++ b/src/AsyncWebSynchronization.h @@ -22,7 +22,7 @@ You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - Version: 1.6.0 + Version: 1.6.1 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -34,6 +34,7 @@ 1.4.1 K Hoang 29/11/2021 Fix bug in examples to reduce connection time 1.5.0 K Hoang 01/10/2022 Fix AsyncWebSocket bug 1.6.0 K Hoang 04/10/2022 Option to use cString instead of String to save Heap + 1.6.1 K Hoang 05/10/2022 Don't need memmove(), String no longer destroyed *****************************************************************************************************************************/ #ifndef ASYNCWEBSYNCHRONIZATION_H_ diff --git a/src/StringArray.h b/src/StringArray.h index 8b4c15f..b67106b 100644 --- a/src/StringArray.h +++ b/src/StringArray.h @@ -22,7 +22,7 @@ You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - Version: 1.6.0 + Version: 1.6.1 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -34,6 +34,7 @@ 1.4.1 K Hoang 29/11/2021 Fix bug in examples to reduce connection time 1.5.0 K Hoang 01/10/2022 Fix AsyncWebSocket bug 1.6.0 K Hoang 04/10/2022 Option to use cString instead of String to save Heap + 1.6.1 K Hoang 05/10/2022 Don't need memmove(), String no longer destroyed *****************************************************************************************************************************/ #ifndef STRINGARRAY_H_ diff --git a/src/WT32_ETH01_SPIFFSEditor.cpp b/src/WT32_ETH01_SPIFFSEditor.cpp index 15e2d7e..461c681 100644 --- a/src/WT32_ETH01_SPIFFSEditor.cpp +++ b/src/WT32_ETH01_SPIFFSEditor.cpp @@ -22,7 +22,7 @@ You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - Version: 1.6.0 + Version: 1.6.1 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -34,6 +34,7 @@ 1.4.1 K Hoang 29/11/2021 Fix bug in examples to reduce connection time 1.5.0 K Hoang 01/10/2022 Fix AsyncWebSocket bug 1.6.0 K Hoang 04/10/2022 Option to use cString instead of String to save Heap + 1.6.1 K Hoang 05/10/2022 Don't need memmove(), String no longer destroyed *****************************************************************************************************************************/ #include "WT32_ETH01_SPIFFSEditor.h" diff --git a/src/WT32_ETH01_SPIFFSEditor.h b/src/WT32_ETH01_SPIFFSEditor.h index 1c2e719..52540fc 100644 --- a/src/WT32_ETH01_SPIFFSEditor.h +++ b/src/WT32_ETH01_SPIFFSEditor.h @@ -22,7 +22,7 @@ You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - Version: 1.6.0 + Version: 1.6.1 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -34,6 +34,7 @@ 1.4.1 K Hoang 29/11/2021 Fix bug in examples to reduce connection time 1.5.0 K Hoang 01/10/2022 Fix AsyncWebSocket bug 1.6.0 K Hoang 04/10/2022 Option to use cString instead of String to save Heap + 1.6.1 K Hoang 05/10/2022 Don't need memmove(), String no longer destroyed *****************************************************************************************************************************/ #ifndef WT32_ETH01_SPIFFSEditor_H_ diff --git a/src/WebAuthentication.cpp b/src/WebAuthentication.cpp index 5199736..f53aeb2 100644 --- a/src/WebAuthentication.cpp +++ b/src/WebAuthentication.cpp @@ -22,7 +22,7 @@ You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - Version: 1.6.0 + Version: 1.6.1 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -34,6 +34,7 @@ 1.4.1 K Hoang 29/11/2021 Fix bug in examples to reduce connection time 1.5.0 K Hoang 01/10/2022 Fix AsyncWebSocket bug 1.6.0 K Hoang 04/10/2022 Option to use cString instead of String to save Heap + 1.6.1 K Hoang 05/10/2022 Don't need memmove(), String no longer destroyed *****************************************************************************************************************************/ #include "WebAuthentication.h" diff --git a/src/WebAuthentication.h b/src/WebAuthentication.h index cb740fa..f6e924f 100644 --- a/src/WebAuthentication.h +++ b/src/WebAuthentication.h @@ -22,7 +22,7 @@ You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - Version: 1.6.0 + Version: 1.6.1 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -34,6 +34,7 @@ 1.4.1 K Hoang 29/11/2021 Fix bug in examples to reduce connection time 1.5.0 K Hoang 01/10/2022 Fix AsyncWebSocket bug 1.6.0 K Hoang 04/10/2022 Option to use cString instead of String to save Heap + 1.6.1 K Hoang 05/10/2022 Don't need memmove(), String no longer destroyed *****************************************************************************************************************************/ #ifndef WEB_AUTHENTICATION_H_ diff --git a/src/WebHandlerImpl.h b/src/WebHandlerImpl.h index 93437e5..000f828 100644 --- a/src/WebHandlerImpl.h +++ b/src/WebHandlerImpl.h @@ -22,7 +22,7 @@ You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - Version: 1.6.0 + Version: 1.6.1 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -34,6 +34,7 @@ 1.4.1 K Hoang 29/11/2021 Fix bug in examples to reduce connection time 1.5.0 K Hoang 01/10/2022 Fix AsyncWebSocket bug 1.6.0 K Hoang 04/10/2022 Option to use cString instead of String to save Heap + 1.6.1 K Hoang 05/10/2022 Don't need memmove(), String no longer destroyed *****************************************************************************************************************************/ #ifndef ASYNCWEBSERVERHANDLERIMPL_H_ diff --git a/src/WebRequest.cpp b/src/WebRequest.cpp index dd84ef6..80b6aab 100644 --- a/src/WebRequest.cpp +++ b/src/WebRequest.cpp @@ -22,7 +22,7 @@ You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - Version: 1.6.0 + Version: 1.6.1 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -34,6 +34,7 @@ 1.4.1 K Hoang 29/11/2021 Fix bug in examples to reduce connection time 1.5.0 K Hoang 01/10/2022 Fix AsyncWebSocket bug 1.6.0 K Hoang 04/10/2022 Option to use cString instead of String to save Heap + 1.6.1 K Hoang 05/10/2022 Don't need memmove(), String no longer destroyed *****************************************************************************************************************************/ //#include "ESPAsyncWebServer.h" diff --git a/src/WebResponseImpl.h b/src/WebResponseImpl.h index c12f1ef..b75de1d 100644 --- a/src/WebResponseImpl.h +++ b/src/WebResponseImpl.h @@ -22,7 +22,7 @@ You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - Version: 1.6.0 + Version: 1.6.1 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -34,6 +34,7 @@ 1.4.1 K Hoang 29/11/2021 Fix bug in examples to reduce connection time 1.5.0 K Hoang 01/10/2022 Fix AsyncWebSocket bug 1.6.0 K Hoang 04/10/2022 Option to use cString instead of String to save Heap + 1.6.1 K Hoang 05/10/2022 Don't need memmove(), String no longer destroyed *****************************************************************************************************************************/ #ifndef ASYNCWEBSERVERRESPONSEIMPL_H_ @@ -57,6 +58,7 @@ class AsyncBasicResponse: public AsyncWebServerResponse String _content; char *_contentCstr; // RSMOD + String _partialHeader; public: AsyncBasicResponse(int code, const String& contentType = String(), const String& content = String()); diff --git a/src/WebResponses.cpp b/src/WebResponses.cpp index d1fee5f..0357908 100644 --- a/src/WebResponses.cpp +++ b/src/WebResponses.cpp @@ -22,7 +22,7 @@ You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - Version: 1.6.0 + Version: 1.6.1 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -34,6 +34,7 @@ 1.4.1 K Hoang 29/11/2021 Fix bug in examples to reduce connection time 1.5.0 K Hoang 01/10/2022 Fix AsyncWebSocket bug 1.6.0 K Hoang 04/10/2022 Option to use cString instead of String to save Heap + 1.6.1 K Hoang 05/10/2022 Don't need memmove(), String no longer destroyed *****************************************************************************************************************************/ #include "AsyncWebServer_WT32_ETH01.h" @@ -270,6 +271,7 @@ AsyncBasicResponse::AsyncBasicResponse(int code, const String& contentType, cons _content = String(""); _contentCstr = (char *)content; // RSMOD _contentType = contentType; + _partialHeader = String(); int iLen; @@ -297,6 +299,7 @@ AsyncBasicResponse::AsyncBasicResponse(int code, const String& contentType, cons _contentCstr = nullptr; // RSMOD _contentType = contentType; + _partialHeader = String(); if (_content.length()) { @@ -334,21 +337,13 @@ void AsyncBasicResponse::_respond(AsyncWebServerRequest *request) if (_contentCstr) { - memmove(&_contentCstr[outLen], _contentCstr, _contentLength); - memcpy(_contentCstr, out.c_str(), outLen); - outLen += _contentLength; - - AWS_LOGDEBUG1("_contentCstr =", _contentCstr); - - _writtenLength += request->client()->write(_contentCstr, outLen); - } - else - { - out += _content; - outLen += _contentLength; - _writtenLength += request->client()->write(out.c_str(), outLen); + _content = String(_contentCstr); // short _contentCstr - so just send as Arduino String - not much of a penalty - fall into below } + out += _content; + outLen += _contentLength; + _writtenLength += request->client()->write(out.c_str(), outLen); + _state = RESPONSE_WAIT_ACK; } else if (space && space < outLen) @@ -359,21 +354,18 @@ void AsyncBasicResponse::_respond(AsyncWebServerRequest *request) if (_contentCstr) { - int deltaLen = out.length() - partial.length(); - - memmove(&_contentCstr[deltaLen], _contentCstr, deltaLen); - memcpy(_contentCstr, out.substring(space).c_str(), deltaLen); + _partialHeader = out.substring(space); } else { _content = out.substring(space) + _content; + _contentLength += outLen - space; } - _contentLength += outLen - space; - AWS_LOGDEBUG1("partial =", partial); _writtenLength += request->client()->write(partial.c_str(), partial.length()); + _state = RESPONSE_CONTENT; } else if (space > outLen && space < (outLen + _contentLength)) @@ -389,12 +381,21 @@ void AsyncBasicResponse::_respond(AsyncWebServerRequest *request) { char *s = (char *)malloc(shift + 1); - strncpy(s, _contentCstr, shift); - s[shift] = '\0'; - out += String(s); - _contentCstr += shift; + if (s != nullptr) + { + strncpy(s, _contentCstr, shift); + s[shift] = '\0'; + out += String(s); + _contentCstr += shift; - free(s); + free(s); + } + else + { + AWS_LOGERROR("AsyncBasicResponse::_respond: Out of heap"); + + return; + } } else { @@ -413,15 +414,14 @@ void AsyncBasicResponse::_respond(AsyncWebServerRequest *request) if (_contentCstr) { - memmove(&_contentCstr[outLen], _contentCstr, _contentLength); - memcpy(_contentCstr, out.c_str(), outLen); + _partialHeader = out; } else { _content = out + _content; + _contentLength += outLen; } - - _contentLength += outLen; + _state = RESPONSE_CONTENT; } @@ -445,12 +445,40 @@ size_t AsyncBasicResponse::_ack(AsyncWebServerRequest *request, size_t len, uint size_t available = _contentLength - _sentLength; size_t space = request->client()->space(); + if (_partialHeader.length() > 0) + { + if (_partialHeader.length() > space) + { + // Header longer than space - send a piece of it, and make the _partialHeader = to what remains + String _subHeader; + String tmpString; + + _subHeader = _partialHeader.substring(0, space); + tmpString = _partialHeader.substring(space); + _partialHeader = tmpString; + + _writtenLength += request->client()->write(_subHeader.c_str(), space); + + return (_partialHeader.length()); + } + else + { + // _partialHeader is <= space length - therefore send the whole thing, and make the remaining length = to the _contrentLength + _writtenLength += request->client()->write(_partialHeader.c_str(), _partialHeader.length()); + + _partialHeader = String(); + + return (_contentLength); + } + } + + // if we are here - there is no _partialHJeader to send + AWS_LOGDEBUG3("AsyncBasicResponse::_ack : available =", available, ", space =", space ); //we can fit in this packet if (space > available) { - // Serial.println("In space>available"); AWS_LOGDEBUG1("AsyncBasicResponse::_ack : Pre_ack, _contentLength =", _contentLength); if (_contentCstr) @@ -465,7 +493,7 @@ size_t AsyncBasicResponse::_ack(AsyncWebServerRequest *request, size_t len, uint _writtenLength += request->client()->write(_content.c_str(), available); _content = String(); } - + _state = RESPONSE_WAIT_ACK; return available; @@ -475,11 +503,22 @@ size_t AsyncBasicResponse::_ack(AsyncWebServerRequest *request, size_t len, uint if (_contentCstr) { char *s = (char *)malloc(space + 1); - strncpy(s, _contentCstr, space); - s[space] = '\0'; - out = String(s); - _contentCstr += space; - free(s); + + if (s != nullptr) + { + strncpy(s, _contentCstr, space); + s[space] = '\0'; + out = String(s); + _contentCstr += space; + + free(s); + } + else + { + AWS_LOGERROR("AsyncBasicResponse::_ack: Out of heap"); + + return 0; + } } else { diff --git a/src/WebServer.cpp b/src/WebServer.cpp index b70516e..0c93f72 100644 --- a/src/WebServer.cpp +++ b/src/WebServer.cpp @@ -22,7 +22,7 @@ You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - Version: 1.6.0 + Version: 1.6.1 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -34,6 +34,7 @@ 1.4.1 K Hoang 29/11/2021 Fix bug in examples to reduce connection time 1.5.0 K Hoang 01/10/2022 Fix AsyncWebSocket bug 1.6.0 K Hoang 04/10/2022 Option to use cString instead of String to save Heap + 1.6.1 K Hoang 05/10/2022 Don't need memmove(), String no longer destroyed *****************************************************************************************************************************/ #include "AsyncWebServer_WT32_ETH01.h" diff --git a/src/libb64/cdecode.c b/src/libb64/cdecode.c index 8924669..55ed5d4 100644 --- a/src/libb64/cdecode.c +++ b/src/libb64/cdecode.c @@ -11,19 +11,6 @@ Based on and modified from ESPAsyncWebServer (https://github.com/me-no-dev/ESPAsyncWebServer) Built by Khoi Hoang https://github.com/khoih-prog/AsyncWebServer_WT32_ETH01 Licensed under GPLv3 license - - Version: 1.6.0 - - Version Modified By Date Comments - ------- ----------- ---------- ----------- - 1.2.3 K Hoang 17/07/2021 Initial porting for WT32_ETH01 (ESP32 + LAN8720). Sync with ESPAsyncWebServer v1.2.3 - 1.2.4 K Hoang 02/08/2021 Fix Mbed TLS compile error with ESP32 core v2.0.0-rc1+ - 1.2.5 K Hoang 09/10/2021 Update `platform.ini` and `library.json`Working only with core v1.0.6- - 1.3.0 K Hoang 23/10/2021 Making compatible with breaking core v2.0.0+ - 1.4.0 K Hoang 27/11/2021 Auto detect ESP32 core version - 1.4.1 K Hoang 29/11/2021 Fix bug in examples to reduce connection time - 1.5.0 K Hoang 01/10/2022 Fix AsyncWebSocket bug - 1.6.0 K Hoang 04/10/2022 Option to use cString instead of String to save Heap *****************************************************************************************************************************/ #include "cdecode.h" diff --git a/src/libb64/cdecode.h b/src/libb64/cdecode.h index 150ad71..4c4e59d 100644 --- a/src/libb64/cdecode.h +++ b/src/libb64/cdecode.h @@ -11,19 +11,6 @@ Based on and modified from ESPAsyncWebServer (https://github.com/me-no-dev/ESPAsyncWebServer) Built by Khoi Hoang https://github.com/khoih-prog/AsyncWebServer_WT32_ETH01 Licensed under GPLv3 license - - Version: 1.6.0 - - Version Modified By Date Comments - ------- ----------- ---------- ----------- - 1.2.3 K Hoang 17/07/2021 Initial porting for WT32_ETH01 (ESP32 + LAN8720). Sync with ESPAsyncWebServer v1.2.3 - 1.2.4 K Hoang 02/08/2021 Fix Mbed TLS compile error with ESP32 core v2.0.0-rc1+ - 1.2.5 K Hoang 09/10/2021 Update `platform.ini` and `library.json`Working only with core v1.0.6- - 1.3.0 K Hoang 23/10/2021 Making compatible with breaking core v2.0.0+ - 1.4.0 K Hoang 27/11/2021 Auto detect ESP32 core version - 1.4.1 K Hoang 29/11/2021 Fix bug in examples to reduce connection time - 1.5.0 K Hoang 01/10/2022 Fix AsyncWebSocket bug - 1.6.0 K Hoang 04/10/2022 Option to use cString instead of String to save Heap *****************************************************************************************************************************/ #pragma once diff --git a/src/libb64/cencode.c b/src/libb64/cencode.c index 681ccfe..6a9da3f 100644 --- a/src/libb64/cencode.c +++ b/src/libb64/cencode.c @@ -11,19 +11,6 @@ Based on and modified from ESPAsyncWebServer (https://github.com/me-no-dev/ESPAsyncWebServer) Built by Khoi Hoang https://github.com/khoih-prog/AsyncWebServer_WT32_ETH01 Licensed under GPLv3 license - - Version: 1.6.0 - - Version Modified By Date Comments - ------- ----------- ---------- ----------- - 1.2.3 K Hoang 17/07/2021 Initial porting for WT32_ETH01 (ESP32 + LAN8720). Sync with ESPAsyncWebServer v1.2.3 - 1.2.4 K Hoang 02/08/2021 Fix Mbed TLS compile error with ESP32 core v2.0.0-rc1+ - 1.2.5 K Hoang 09/10/2021 Update `platform.ini` and `library.json`Working only with core v1.0.6- - 1.3.0 K Hoang 23/10/2021 Making compatible with breaking core v2.0.0+ - 1.4.0 K Hoang 27/11/2021 Auto detect ESP32 core version - 1.4.1 K Hoang 29/11/2021 Fix bug in examples to reduce connection time - 1.5.0 K Hoang 01/10/2022 Fix AsyncWebSocket bug - 1.6.0 K Hoang 04/10/2022 Option to use cString instead of String to save Heap *****************************************************************************************************************************/ #include "cencode.h" diff --git a/src/libb64/cencode.h b/src/libb64/cencode.h index db5b701..396f42d 100644 --- a/src/libb64/cencode.h +++ b/src/libb64/cencode.h @@ -11,19 +11,6 @@ Based on and modified from ESPAsyncWebServer (https://github.com/me-no-dev/ESPAsyncWebServer) Built by Khoi Hoang https://github.com/khoih-prog/AsyncWebServer_WT32_ETH01 Licensed under GPLv3 license - - Version: 1.6.0 - - Version Modified By Date Comments - ------- ----------- ---------- ----------- - 1.2.3 K Hoang 17/07/2021 Initial porting for WT32_ETH01 (ESP32 + LAN8720). Sync with ESPAsyncWebServer v1.2.3 - 1.2.4 K Hoang 02/08/2021 Fix Mbed TLS compile error with ESP32 core v2.0.0-rc1+ - 1.2.5 K Hoang 09/10/2021 Update `platform.ini` and `library.json`Working only with core v1.0.6- - 1.3.0 K Hoang 23/10/2021 Making compatible with breaking core v2.0.0+ - 1.4.0 K Hoang 27/11/2021 Auto detect ESP32 core version - 1.4.1 K Hoang 29/11/2021 Fix bug in examples to reduce connection time - 1.5.0 K Hoang 01/10/2022 Fix AsyncWebSocket bug - 1.6.0 K Hoang 04/10/2022 Option to use cString instead of String to save Heap *****************************************************************************************************************************/ #pragma once