From 17a8d442169f3ca8496b20ebd24bbc06f55d4a62 Mon Sep 17 00:00:00 2001 From: me-no-dev Date: Tue, 4 Jun 2024 13:50:37 +0300 Subject: [PATCH 1/4] Add support for Arduino 3.0.0 --- library.json | 2 +- library.properties | 2 +- src/AsyncEventSource.cpp | 5 +++++ src/AsyncWebSocket.cpp | 8 +++++++- src/WebAuthentication.cpp | 6 ++++++ 5 files changed, 20 insertions(+), 3 deletions(-) diff --git a/library.json b/library.json index 750ca28..7947a4d 100644 --- a/library.json +++ b/library.json @@ -12,7 +12,7 @@ "type": "git", "url": "https://github.com/me-no-dev/ESPAsyncWebServer.git" }, - "version": "1.2.3", + "version": "1.2.4", "license": "LGPL-3.0", "frameworks": "arduino", "platforms": ["espressif8266", "espressif32"], diff --git a/library.properties b/library.properties index 401b041..fb650fa 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=ESP Async WebServer -version=1.2.3 +version=1.2.4 author=Me-No-Dev maintainer=Me-No-Dev sentence=Async Web Server for ESP8266 and ESP31B diff --git a/src/AsyncEventSource.cpp b/src/AsyncEventSource.cpp index f2914df..3b82575 100644 --- a/src/AsyncEventSource.cpp +++ b/src/AsyncEventSource.cpp @@ -19,6 +19,11 @@ */ #include "Arduino.h" #include "AsyncEventSource.h" +#ifdef ESP32 +#if ESP_IDF_VERSION_MAJOR >= 5 +#include "rom/ets_sys.h" +#endif +#endif static String generateEventMessage(const char *message, const char *event, uint32_t id, uint32_t reconnect){ String ev = ""; diff --git a/src/AsyncWebSocket.cpp b/src/AsyncWebSocket.cpp index f76f2fc..11a7ff8 100644 --- a/src/AsyncWebSocket.cpp +++ b/src/AsyncWebSocket.cpp @@ -829,7 +829,7 @@ void AsyncWebSocketClient::binary(AsyncWebSocketMessageBuffer * buffer) IPAddress AsyncWebSocketClient::remoteIP() { if(!_client) { - return IPAddress(0U); + return IPAddress((uint32_t)0U); } return _client->remoteIP(); } @@ -1259,9 +1259,15 @@ AsyncWebSocketResponse::AsyncWebSocketResponse(const String& key, AsyncWebSocket (String&)key += WS_STR_UUID; mbedtls_sha1_context ctx; mbedtls_sha1_init(&ctx); +#if ESP_IDF_VERSION_MAJOR < 5 mbedtls_sha1_starts_ret(&ctx); mbedtls_sha1_update_ret(&ctx, (const unsigned char*)key.c_str(), key.length()); mbedtls_sha1_finish_ret(&ctx, hash); +#else + mbedtls_sha1_starts(&ctx); + mbedtls_sha1_update(&ctx, (const unsigned char*)key.c_str(), key.length()); + mbedtls_sha1_finish(&ctx, hash); +#endif mbedtls_sha1_free(&ctx); #endif base64_encodestate _state; diff --git a/src/WebAuthentication.cpp b/src/WebAuthentication.cpp index 45246a1..38b20f3 100644 --- a/src/WebAuthentication.cpp +++ b/src/WebAuthentication.cpp @@ -71,9 +71,15 @@ static bool getMD5(uint8_t * data, uint16_t len, char * output){//33 bytes or mo memset(_buf, 0x00, 16); #ifdef ESP32 mbedtls_md5_init(&_ctx); +#if ESP_IDF_VERSION_MAJOR < 5 mbedtls_md5_starts_ret(&_ctx); mbedtls_md5_update_ret(&_ctx, data, len); mbedtls_md5_finish_ret(&_ctx, _buf); +#else + mbedtls_md5_starts(&_ctx); + mbedtls_md5_update(&_ctx, data, len); + mbedtls_md5_finish(&_ctx, _buf); +#endif #else MD5Init(&_ctx); MD5Update(&_ctx, data, len); From 9d315521eb2ead26f6755a9783b2e5d263da8517 Mon Sep 17 00:00:00 2001 From: me-no-dev Date: Tue, 4 Jun 2024 14:52:27 +0300 Subject: [PATCH 2/4] Add missing include for Arduino 3.0.0 --- src/AsyncWebSocket.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/AsyncWebSocket.cpp b/src/AsyncWebSocket.cpp index 11a7ff8..bdfa197 100644 --- a/src/AsyncWebSocket.cpp +++ b/src/AsyncWebSocket.cpp @@ -28,6 +28,11 @@ #else #include #endif +#ifdef ESP32 +#if ESP_IDF_VERSION_MAJOR >= 5 +#include "rom/ets_sys.h" +#endif +#endif #define MAX_PRINTF_LEN 64 From 7f3753454b1f176c4b6d6bcd1587a135d95ca63c Mon Sep 17 00:00:00 2001 From: me-no-dev Date: Tue, 4 Jun 2024 15:01:45 +0300 Subject: [PATCH 3/4] Add example build flag --- examples/regex_patterns/build_opt.h | 1 + 1 file changed, 1 insertion(+) create mode 100644 examples/regex_patterns/build_opt.h diff --git a/examples/regex_patterns/build_opt.h b/examples/regex_patterns/build_opt.h new file mode 100644 index 0000000..f597851 --- /dev/null +++ b/examples/regex_patterns/build_opt.h @@ -0,0 +1 @@ +-DASYNCWEBSERVER_REGEX=1 \ No newline at end of file From 67de9cddbbf0d024c61a314bacd204ba6101fac8 Mon Sep 17 00:00:00 2001 From: dl9rdz Date: Fri, 25 Oct 2024 07:46:40 +0000 Subject: [PATCH 4/4] tentative fix (#1436) Co-authored-by: Hans P. Reiser --- src/WebResponses.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/WebResponses.cpp b/src/WebResponses.cpp index a22e991..3000c72 100644 --- a/src/WebResponses.cpp +++ b/src/WebResponses.cpp @@ -312,13 +312,14 @@ size_t AsyncAbstractResponse::_ack(AsyncWebServerRequest *request, size_t len, u if(_chunked){ // HTTP 1.1 allows leading zeros in chunk length. Or spaces may be added. // See RFC2616 sections 2, 3.6.1. + // -- OR NOT: There is nothing about spaces there, and it breaks Webkit browsers on iOS! readLen = _fillBufferAndProcessTemplates(buf+headLen+6, outLen - 8); if(readLen == RESPONSE_TRY_AGAIN){ free(buf); return 0; } - outLen = sprintf((char*)buf+headLen, "%x", readLen) + headLen; - while(outLen < headLen + 4) buf[outLen++] = ' '; + outLen = sprintf((char*)buf+headLen, "%04x", readLen) + headLen; + // while(outLen < headLen + 4) buf[outLen++] = ' '; buf[outLen++] = '\r'; buf[outLen++] = '\n'; outLen += readLen;