From 40e15e30f934e4b269b16a8ab8727558f0ab7b03 Mon Sep 17 00:00:00 2001 From: Khoi Hoang <57012152+khoih-prog@users.noreply.github.com> Date: Fri, 21 Oct 2022 15:09:41 -0400 Subject: [PATCH] v1.10.1 to fix bug of wrong `reqStates` ### Releases v1.10.1 1. Fix bug of wrong `reqStates` 2. Optional larger `DEFAULT_RX_TIMEOUT` from default 3s, for slower networks --- changelog.md | 6 ++ .../AsyncCustomHeader_STM32.ino | 4 +- .../AsyncDweetGet_STM32.ino | 4 +- .../AsyncDweetPost_STM32.ino | 4 +- .../AsyncHTTPMultiRequests_ESP.ino | 7 +- .../AsyncHTTPRequest_ESP.ino | 7 +- .../AsyncHTTPRequest_ESP8266_Ethernet.ino | 7 +- .../AsyncHTTPRequest_ESP_Multi.ino | 3 + .../AsyncHTTPRequest_ESP_WiFiManager.ino | 4 +- .../AsyncHTTPRequest_STM32.ino | 4 +- .../AsyncSimpleGET_STM32.ino | 4 +- .../AsyncWebClientRepeating_STM32.ino | 4 +- .../AsyncHTTPMultiRequests_WT32_ETH01.ino | 4 +- .../AsyncHTTPRequest_WT32_ETH01.ino | 5 +- .../multiFileProject/multiFileProject.ino | 4 +- library.json | 2 +- library.properties | 2 +- src/AsyncHTTPRequest_Debug_Generic.h | 3 +- src/AsyncHTTPRequest_Generic.h | 3 +- src/AsyncHTTPRequest_Generic.hpp | 40 +++++---- src/AsyncHTTPRequest_Impl_Generic.h | 83 +++++++++---------- 21 files changed, 110 insertions(+), 94 deletions(-) diff --git a/changelog.md b/changelog.md index c3e5f1d..3f65143 100644 --- a/changelog.md +++ b/changelog.md @@ -12,6 +12,7 @@ ## Table of Contents * [Changelog](#changelog) + * [Releases v1.10.1](#releases-v1101) * [Releases v1.10.0](#releases-v1100) * [Releases v1.9.2](#releases-v192) * [Releases v1.9.1](#releases-v191) @@ -43,6 +44,11 @@ ## Changelog +### Releases v1.10.1 + +1. Fix bug of wrong `reqStates` +2. Optional larger `DEFAULT_RX_TIMEOUT` from default 3s, for slower networks + ### Releases v1.10.0 1. Fix bug. diff --git a/examples/AsyncCustomHeader_STM32/AsyncCustomHeader_STM32.ino b/examples/AsyncCustomHeader_STM32/AsyncCustomHeader_STM32.ino index c32fece..e880e09 100644 --- a/examples/AsyncCustomHeader_STM32/AsyncCustomHeader_STM32.ino +++ b/examples/AsyncCustomHeader_STM32/AsyncCustomHeader_STM32.ino @@ -24,8 +24,8 @@ //char GET_ServerAddress[] = "192.168.2.110/"; char GET_ServerAddress[] = "http://worldtimeapi.org/api/timezone/America/Toronto.txt"; -#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.10.0" -#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1010000 +#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.10.1" +#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1010001 // 600s = 10 minutes to not flooding, 60s in testing #define HTTP_REQUEST_INTERVAL_MS 60000 //600000 diff --git a/examples/AsyncDweetGet_STM32/AsyncDweetGet_STM32.ino b/examples/AsyncDweetGet_STM32/AsyncDweetGet_STM32.ino index 6618e18..1260f2f 100644 --- a/examples/AsyncDweetGet_STM32/AsyncDweetGet_STM32.ino +++ b/examples/AsyncDweetGet_STM32/AsyncDweetGet_STM32.ino @@ -35,8 +35,8 @@ const char GET_ServerAddress[] = "dweet.io"; // use your own thing name here String dweetName = "/dweet/for/currentSecond?second="; -#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.10.0" -#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1010000 +#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.10.1" +#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1010001 // 600s = 10 minutes to not flooding, 60s in testing #define HTTP_REQUEST_INTERVAL_MS 60000 //600000 diff --git a/examples/AsyncDweetPost_STM32/AsyncDweetPost_STM32.ino b/examples/AsyncDweetPost_STM32/AsyncDweetPost_STM32.ino index f804bd1..deb189a 100644 --- a/examples/AsyncDweetPost_STM32/AsyncDweetPost_STM32.ino +++ b/examples/AsyncDweetPost_STM32/AsyncDweetPost_STM32.ino @@ -29,8 +29,8 @@ const char POST_ServerAddress[] = "dweet.io"; // use your own thing name here String dweetName = "/dweet/for/pinA0-Read?"; -#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.10.0" -#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1010000 +#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.10.1" +#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1010001 // 600s = 10 minutes to not flooding, 60s in testing #define HTTP_REQUEST_INTERVAL_MS 60000 //600000 diff --git a/examples/AsyncHTTPMultiRequests_ESP/AsyncHTTPMultiRequests_ESP.ino b/examples/AsyncHTTPMultiRequests_ESP/AsyncHTTPMultiRequests_ESP.ino index d0c25ff..3d91d82 100644 --- a/examples/AsyncHTTPMultiRequests_ESP/AsyncHTTPMultiRequests_ESP.ino +++ b/examples/AsyncHTTPMultiRequests_ESP/AsyncHTTPMultiRequests_ESP.ino @@ -44,8 +44,8 @@ #error This code is intended to run on the ESP8266 or ESP32 platform! Please check your Tools->Board setting. #endif -#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.10.0" -#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1010000 +#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.10.1" +#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1010001 // Level from 0-4 #define ASYNC_HTTP_DEBUG_PORT Serial @@ -68,6 +68,9 @@ const char* password = "your_pass"; #include #endif +// Seconds for timeout, default is 3s +#define DEFAULT_RX_TIMEOUT 10 + // To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error #include // https://github.com/khoih-prog/AsyncHTTPRequest_Generic diff --git a/examples/AsyncHTTPRequest_ESP/AsyncHTTPRequest_ESP.ino b/examples/AsyncHTTPRequest_ESP/AsyncHTTPRequest_ESP.ino index cb1eb67..4e9e277 100644 --- a/examples/AsyncHTTPRequest_ESP/AsyncHTTPRequest_ESP.ino +++ b/examples/AsyncHTTPRequest_ESP/AsyncHTTPRequest_ESP.ino @@ -65,8 +65,11 @@ const char* password = "your_pass"; #include #endif -#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.10.0" -#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1010000 +#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.10.1" +#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1010001 + +// Seconds for timeout, default is 3s +#define DEFAULT_RX_TIMEOUT 10 // To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error #include // https://github.com/khoih-prog/AsyncHTTPRequest_Generic diff --git a/examples/AsyncHTTPRequest_ESP8266_Ethernet/AsyncHTTPRequest_ESP8266_Ethernet.ino b/examples/AsyncHTTPRequest_ESP8266_Ethernet/AsyncHTTPRequest_ESP8266_Ethernet.ino index f4330f1..fca3818 100644 --- a/examples/AsyncHTTPRequest_ESP8266_Ethernet/AsyncHTTPRequest_ESP8266_Ethernet.ino +++ b/examples/AsyncHTTPRequest_ESP8266_Ethernet/AsyncHTTPRequest_ESP8266_Ethernet.ino @@ -95,8 +95,11 @@ using TCPClient = WiFiClient; ////////////////////////////////////////////////////////// -#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.10.0" -#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1010000 +#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.10.1" +#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1010001 + +// Seconds for timeout, default is 3s +#define DEFAULT_RX_TIMEOUT 10 // To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error #include // https://github.com/khoih-prog/AsyncHTTPRequest_Generic diff --git a/examples/AsyncHTTPRequest_ESP_Multi/AsyncHTTPRequest_ESP_Multi.ino b/examples/AsyncHTTPRequest_ESP_Multi/AsyncHTTPRequest_ESP_Multi.ino index 815d9b3..9e102e6 100644 --- a/examples/AsyncHTTPRequest_ESP_Multi/AsyncHTTPRequest_ESP_Multi.ino +++ b/examples/AsyncHTTPRequest_ESP_Multi/AsyncHTTPRequest_ESP_Multi.ino @@ -44,6 +44,9 @@ const char* password = "your_pass"; #include #endif +// Seconds for timeout, default is 3s +#define DEFAULT_RX_TIMEOUT 10 + // To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error #include // http://github.com/khoih-prog/AsyncHTTPRequest_Generic diff --git a/examples/AsyncHTTPRequest_ESP_WiFiManager/AsyncHTTPRequest_ESP_WiFiManager.ino b/examples/AsyncHTTPRequest_ESP_WiFiManager/AsyncHTTPRequest_ESP_WiFiManager.ino index f34712b..4f7eafa 100644 --- a/examples/AsyncHTTPRequest_ESP_WiFiManager/AsyncHTTPRequest_ESP_WiFiManager.ino +++ b/examples/AsyncHTTPRequest_ESP_WiFiManager/AsyncHTTPRequest_ESP_WiFiManager.ino @@ -49,8 +49,8 @@ #define ESP_ASYNC_WIFIMANAGER_VERSION_MIN_TARGET "ESPAsync_WiFiManager v1.15.0" #define ESP_ASYNC_WIFIMANAGER_VERSION_MIN 1015000 -#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.10.0" -#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1010000 +#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.10.1" +#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1010001 // Level from 0-4 #define ASYNC_HTTP_DEBUG_PORT Serial diff --git a/examples/AsyncHTTPRequest_STM32/AsyncHTTPRequest_STM32.ino b/examples/AsyncHTTPRequest_STM32/AsyncHTTPRequest_STM32.ino index 593aa1d..b9bf2c3 100644 --- a/examples/AsyncHTTPRequest_STM32/AsyncHTTPRequest_STM32.ino +++ b/examples/AsyncHTTPRequest_STM32/AsyncHTTPRequest_STM32.ino @@ -42,8 +42,8 @@ #include "defines.h" -#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.10.0" -#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1010000 +#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.10.1" +#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1010001 // 600s = 10 minutes to not flooding, 60s in testing #define HTTP_REQUEST_INTERVAL_MS 60000 //600000 diff --git a/examples/AsyncSimpleGET_STM32/AsyncSimpleGET_STM32.ino b/examples/AsyncSimpleGET_STM32/AsyncSimpleGET_STM32.ino index f035d6d..90f401f 100644 --- a/examples/AsyncSimpleGET_STM32/AsyncSimpleGET_STM32.ino +++ b/examples/AsyncSimpleGET_STM32/AsyncSimpleGET_STM32.ino @@ -24,8 +24,8 @@ //char GET_ServerAddress[] = "ipv4bot.whatismyipaddress.com/"; char GET_ServerAddress[] = "http://worldtimeapi.org/api/timezone/America/Toronto.txt"; -#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.10.0" -#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1010000 +#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.10.1" +#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1010001 // 600s = 10 minutes to not flooding, 60s in testing #define HTTP_REQUEST_INTERVAL_MS 60000 //600000 diff --git a/examples/AsyncWebClientRepeating_STM32/AsyncWebClientRepeating_STM32.ino b/examples/AsyncWebClientRepeating_STM32/AsyncWebClientRepeating_STM32.ino index 33eb434..9f88de3 100644 --- a/examples/AsyncWebClientRepeating_STM32/AsyncWebClientRepeating_STM32.ino +++ b/examples/AsyncWebClientRepeating_STM32/AsyncWebClientRepeating_STM32.ino @@ -26,8 +26,8 @@ const char GET_ServerAddress[] = "arduino.tips"; // GET location String GET_Location = "/asciilogo.txt"; -#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.10.0" -#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1010000 +#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.10.1" +#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1010001 // 600s = 10 minutes to not flooding, 60s in testing #define HTTP_REQUEST_INTERVAL_MS 60000 //600000 diff --git a/examples/WT32_ETH01/AsyncHTTPMultiRequests_WT32_ETH01/AsyncHTTPMultiRequests_WT32_ETH01.ino b/examples/WT32_ETH01/AsyncHTTPMultiRequests_WT32_ETH01/AsyncHTTPMultiRequests_WT32_ETH01.ino index 78216ef..0f5f37c 100644 --- a/examples/WT32_ETH01/AsyncHTTPMultiRequests_WT32_ETH01/AsyncHTTPMultiRequests_WT32_ETH01.ino +++ b/examples/WT32_ETH01/AsyncHTTPMultiRequests_WT32_ETH01/AsyncHTTPMultiRequests_WT32_ETH01.ino @@ -57,8 +57,8 @@ #include // https://github.com/khoih-prog/WebServer_WT32_ETH01 -#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.10.0" -#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1010000 +#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.10.1" +#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1010001 // To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error #include // https://github.com/khoih-prog/AsyncHTTPRequest_Generic diff --git a/examples/WT32_ETH01/AsyncHTTPRequest_WT32_ETH01/AsyncHTTPRequest_WT32_ETH01.ino b/examples/WT32_ETH01/AsyncHTTPRequest_WT32_ETH01/AsyncHTTPRequest_WT32_ETH01.ino index 44cd9b4..703c0fa 100644 --- a/examples/WT32_ETH01/AsyncHTTPRequest_WT32_ETH01/AsyncHTTPRequest_WT32_ETH01.ino +++ b/examples/WT32_ETH01/AsyncHTTPRequest_WT32_ETH01/AsyncHTTPRequest_WT32_ETH01.ino @@ -57,8 +57,9 @@ #include // https://github.com/khoih-prog/WebServer_WT32_ETH01 -#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.10.0" -#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1010000 +#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.10.1" +#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1010001 + // To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error #include // https://github.com/khoih-prog/AsyncHTTPRequest_Generic diff --git a/examples/multiFileProject/multiFileProject.ino b/examples/multiFileProject/multiFileProject.ino index e2a2156..59576b2 100644 --- a/examples/multiFileProject/multiFileProject.ino +++ b/examples/multiFileProject/multiFileProject.ino @@ -19,8 +19,8 @@ #error This code is intended to run on the ESP8266, ESP32 or STM32 platform! Please check your Tools->Board setting. #endif -#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.10.0" -#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1010000 +#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.10.1" +#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1010001 #include "multiFileProject.h" diff --git a/library.json b/library.json index 6878a91..d8600d5 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name":"AsyncHTTPRequest_Generic", - "version": "1.10.0", + "version": "1.10.1", "description":"Simple Async HTTP Request library, supporting GET, POST, PUT, PATCH, DELETE and HEAD, on top of AsyncTCP libraries, such as AsyncTCP, ESPAsyncTCP, AsyncTCP_STM32, etc.. for ESP32 (including ESP32_S2, ESP32_S3 and ESP32_C3), WT32_ETH01 (ESP32 + LAN8720), ESP8266 (WiFi, W5x00 or ENC28J60) and currently STM32 with built-in LAN8742A Ethernet.", "keywords":"communication, async, tcp, http, ESP8266, ESP32, ESP32-S2, ESP32-S3, ESP32-C3, wt32-eth01, stm32, ethernet, wifi, lan8742a, nucleo-144, stm32f7, W5x00, ENC28J60", "authors": [ diff --git a/library.properties b/library.properties index 450ff5e..36de569 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=AsyncHTTPRequest_Generic -version=1.10.0 +version=1.10.1 author=Bob Lemaire,Khoi Hoang maintainer=Khoi Hoang license=GPLv3 diff --git a/src/AsyncHTTPRequest_Debug_Generic.h b/src/AsyncHTTPRequest_Debug_Generic.h index 6f5fbf6..ae6ddd7 100644 --- a/src/AsyncHTTPRequest_Debug_Generic.h +++ b/src/AsyncHTTPRequest_Debug_Generic.h @@ -18,7 +18,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . - Version: 1.10.0 + Version: 1.10.1 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -33,6 +33,7 @@ 1.9.1 K Hoang 09/09/2022 Fix ESP32 chipID for example `AsyncHTTPRequest_ESP_WiFiManager` 1.9.2 K Hoang 18/10/2022 Not try to reconnect to the same host:port after connected 1.10.0 K Hoang 20/10/2022 Fix bug. Clean up + 1.10.1 K Hoang 21/10/2022 Fix bug of wrong reqStates *****************************************************************************************************************************/ #pragma once diff --git a/src/AsyncHTTPRequest_Generic.h b/src/AsyncHTTPRequest_Generic.h index a47d3ec..4d5286c 100644 --- a/src/AsyncHTTPRequest_Generic.h +++ b/src/AsyncHTTPRequest_Generic.h @@ -18,7 +18,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . - Version: 1.10.0 + Version: 1.10.1 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -33,6 +33,7 @@ 1.9.1 K Hoang 09/09/2022 Fix ESP32 chipID for example `AsyncHTTPRequest_ESP_WiFiManager` 1.9.2 K Hoang 18/10/2022 Not try to reconnect to the same host:port after connected 1.10.0 K Hoang 20/10/2022 Fix bug. Clean up + 1.10.1 K Hoang 21/10/2022 Fix bug of wrong reqStates *****************************************************************************************************************************/ #pragma once diff --git a/src/AsyncHTTPRequest_Generic.hpp b/src/AsyncHTTPRequest_Generic.hpp index 53fe091..78d7380 100644 --- a/src/AsyncHTTPRequest_Generic.hpp +++ b/src/AsyncHTTPRequest_Generic.hpp @@ -18,7 +18,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . - Version: 1.10.0 + Version: 1.10.1 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -33,6 +33,7 @@ 1.9.1 K Hoang 09/09/2022 Fix ESP32 chipID for example `AsyncHTTPRequest_ESP_WiFiManager` 1.9.2 K Hoang 18/10/2022 Not try to reconnect to the same host:port after connected 1.10.0 K Hoang 20/10/2022 Fix bug. Clean up + 1.10.1 K Hoang 21/10/2022 Fix bug of wrong reqStates *****************************************************************************************************************************/ #pragma once @@ -42,13 +43,13 @@ //////////////////////////////////////// -#define ASYNC_HTTP_REQUEST_GENERIC_VERSION "AsyncHTTPRequest_Generic v1.10.0" +#define ASYNC_HTTP_REQUEST_GENERIC_VERSION "AsyncHTTPRequest_Generic v1.10.1" #define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MAJOR 1 #define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MINOR 10 -#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_PATCH 0 +#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_PATCH 1 -#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_INT 1010000 +#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_INT 1010001 //////////////////////////////////////// @@ -179,8 +180,7 @@ class xbuf: public Print String peekString(int); - /* In addition to the above functions, - the following inherited functions from the Print class are available. + /* In addition to the above functions, the following inherited functions from the Print class are available. size_t printf(const char * format, ...) __attribute__ ((format (printf, 2, 3))); size_t printf_P(PGM_P format, ...) __attribute__((format(printf, 2, 3))); @@ -230,7 +230,9 @@ class xbuf: public Print DEBUG_IOTA_PORT.printf("Debug(%3ld): ", millis()-_requestStartTime);\ DEBUG_IOTA_PORT.printf_P(PSTR(format),##__VA_ARGS__);} -#define DEFAULT_RX_TIMEOUT 3 // Seconds for timeout +#if !defined(DEFAULT_RX_TIMEOUT) + #define DEFAULT_RX_TIMEOUT 3 // Seconds for timeout +#endif //////////////////////////////////////// @@ -275,23 +277,20 @@ class AsyncHTTPRequest SAFE_DELETE_ARRAY(name) SAFE_DELETE_ARRAY(value) SAFE_DELETE(next) - //delete[] name; - //delete[] value; - //delete next; } }; struct URL { - char *buffer; - char *scheme; - char *host; - int port; - char *path; - char *query; + char *buffer; + char *scheme; + char *host; + int port; + char *path; + char *query; - URL(): buffer(nullptr), scheme(nullptr), host(nullptr), - port(80), path(nullptr), query(nullptr) + URL(): buffer(nullptr), scheme(nullptr), host(nullptr), + port(80), path(nullptr), query(nullptr) {}; ~URL() @@ -322,8 +321,7 @@ class AsyncHTTPRequest bool debug(); // is debug on or off? bool open(const char* /*GET/POST*/, const char* URL); // Initiate a request - void onReadyStateChange(readyStateChangeCB, void* arg = 0); // Optional event handler for ready state change - // or you can simply poll readyState() + void onReadyStateChange(readyStateChangeCB, void* arg = 0); // Optional event handler for ready state change or you can simply poll readyState() void setTimeout(int); // overide default timeout (seconds) void setReqHeader(const char* name, const char* value); // add a request header @@ -337,7 +335,7 @@ class AsyncHTTPRequest #endif bool send(); // Send the request (GET) - bool send(const String& body); // Send the request (POST) + bool send(const String& body); // Send the request (POST) bool send(const char* body); // Send the request (POST) bool send(const uint8_t* buffer, size_t len); // Send the request (POST) (binary data?) bool send(xbuf* body, size_t len); // Send the request (POST) data in an xbuf diff --git a/src/AsyncHTTPRequest_Impl_Generic.h b/src/AsyncHTTPRequest_Impl_Generic.h index 0357671..9500305 100644 --- a/src/AsyncHTTPRequest_Impl_Generic.h +++ b/src/AsyncHTTPRequest_Impl_Generic.h @@ -18,7 +18,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . - Version: 1.10.0 + Version: 1.10.1 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -33,6 +33,7 @@ 1.9.1 K Hoang 09/09/2022 Fix ESP32 chipID for example `AsyncHTTPRequest_ESP_WiFiManager` 1.9.2 K Hoang 18/10/2022 Not try to reconnect to the same host:port after connected 1.10.0 K Hoang 20/10/2022 Fix bug. Clean up + 1.10.1 K Hoang 21/10/2022 Fix bug of wrong reqStates *****************************************************************************************************************************/ #pragma once @@ -162,6 +163,7 @@ size_t xbuf::read(uint8_t* buf, const size_t len) size_t supply = (_offset + _used) > _segSize ? _segSize - _offset : _used; size_t demand = len - read; size_t chunk = supply < demand ? supply : demand; + memcpy(buf + read, _head->data + _offset, chunk); _offset += chunk; _used -= chunk; @@ -405,20 +407,17 @@ void xbuf::addSeg() } else { - // KH, Must check NULL here _tail = _tail->next; } } else { - // KH, Must check NULL here _tail = _head = (xseg*) new uint32_t[_segSize / 4 + 1]; if (_tail == NULL) AHTTP_LOGERROR(F("xbuf::addSeg: error new 2")); } - // KH, Must check NULL here if (_tail) _tail->next = nullptr; @@ -811,35 +810,35 @@ int AsyncHTTPRequest::responseHTTPcode() String AsyncHTTPRequest::responseHTTPString() { - switch(_HTTPcode) - { - case 0: - return F("OK"); - case HTTPCODE_CONNECTION_REFUSED: - return F("CONNECTION_REFUSED"); - case HTTPCODE_SEND_HEADER_FAILED: - return F("SEND_HEADER_FAILED"); - case HTTPCODE_SEND_PAYLOAD_FAILED: - return F("SEND_PAYLOAD_FAILED"); - case HTTPCODE_NOT_CONNECTED: - return F("NOT_CONNECTED"); - case HTTPCODE_CONNECTION_LOST: - return F("CONNECTION_LOST"); - case HTTPCODE_NO_STREAM: - return F("NO_STREAM"); - case HTTPCODE_NO_HTTP_SERVER: - return F("NO_HTTP_SERVER"); - case HTTPCODE_TOO_LESS_RAM: - return F("TOO_LESS_RAM"); - case HTTPCODE_ENCODING: - return F("ENCODING"); - case HTTPCODE_STREAM_WRITE: - return F("STREAM_WRITE"); - case HTTPCODE_TIMEOUT: - return F("TIMEOUT"); - - // HTTP positive code - case 100: return F("Continue"); + switch(_HTTPcode) + { + case 0: + return F("OK"); + case HTTPCODE_CONNECTION_REFUSED: + return F("CONNECTION_REFUSED"); + case HTTPCODE_SEND_HEADER_FAILED: + return F("SEND_HEADER_FAILED"); + case HTTPCODE_SEND_PAYLOAD_FAILED: + return F("SEND_PAYLOAD_FAILED"); + case HTTPCODE_NOT_CONNECTED: + return F("NOT_CONNECTED"); + case HTTPCODE_CONNECTION_LOST: + return F("CONNECTION_LOST"); + case HTTPCODE_NO_STREAM: + return F("NO_STREAM"); + case HTTPCODE_NO_HTTP_SERVER: + return F("NO_HTTP_SERVER"); + case HTTPCODE_TOO_LESS_RAM: + return F("TOO_LESS_RAM"); + case HTTPCODE_ENCODING: + return F("ENCODING"); + case HTTPCODE_STREAM_WRITE: + return F("STREAM_WRITE"); + case HTTPCODE_TIMEOUT: + return F("TIMEOUT"); + + // HTTP positive code + case 100: return F("Continue"); case 101: return F("Switching Protocols"); case 200: return F("HTTP OK"); case 201: return F("Created"); @@ -879,8 +878,8 @@ String AsyncHTTPRequest::responseHTTPString() case 503: return F("Service Unavailable"); case 504: return F("Gateway Time-out"); case 505: return F("HTTP Version not supported"); - default: return "UNKNOWN"; - } + default: return "UNKNOWN"; + } } //////////////////////////////////////// @@ -898,13 +897,14 @@ String AsyncHTTPRequest::responseText() return String(); } - size_t avail = available(); - + size_t avail = available(); + String localString = _response->readString(avail); if (localString.length() < avail) { AHTTP_LOGWARN(F("!responseText() no buffer")) + _HTTPcode = HTTPCODE_TOO_LESS_RAM; _client->abort(); _AHTTP_unlock; @@ -1248,13 +1248,10 @@ size_t AsyncHTTPRequest::_send() if ( ! _request) return 0; - if ( ! _client->connected()) + if ( ! _client->connected()) { // KH fix bug https://github.com/khoih-prog/AsyncHTTPRequest_Generic/issues/38 - _HTTPcode = HTTPCODE_NOT_CONNECTED; - _setReadyState(readyStateDone); - - /////////////////////////// + _timeout = DEFAULT_RX_TIMEOUT; return 0; } @@ -1262,7 +1259,7 @@ size_t AsyncHTTPRequest::_send() { return 0; } - + size_t supply = _request->available(); size_t demand = _client->space();