v1.10.0 to fix bug and clean-up

### Releases v1.10.0

1. Fix bug.
2. Clean up
This commit is contained in:
Khoi Hoang
2022-10-20 16:54:51 -04:00
committed by GitHub
parent 89079c915e
commit 89d10346df
20 changed files with 359 additions and 358 deletions

View File

@ -12,6 +12,7 @@
## Table of Contents ## Table of Contents
* [Changelog](#changelog) * [Changelog](#changelog)
* [Releases v1.10.0](#releases-v1100)
* [Releases v1.9.2](#releases-v192) * [Releases v1.9.2](#releases-v192)
* [Releases v1.9.1](#releases-v191) * [Releases v1.9.1](#releases-v191)
* [Releases v1.9.0](#releases-v190) * [Releases v1.9.0](#releases-v190)
@ -42,6 +43,11 @@
## Changelog ## Changelog
### Releases v1.10.0
1. Fix bug.
2. Clean up
### Releases v1.9.2 ### Releases v1.9.2
1. Not try to reconnect to the same host:port after connected. Check [setReuse feature #12](https://github.com/khoih-prog/AsyncHTTPSRequest_Generic/issues/12) 1. Not try to reconnect to the same host:port after connected. Check [setReuse feature #12](https://github.com/khoih-prog/AsyncHTTPSRequest_Generic/issues/12)

View File

@ -24,8 +24,8 @@
//char GET_ServerAddress[] = "192.168.2.110/"; //char GET_ServerAddress[] = "192.168.2.110/";
char GET_ServerAddress[] = "http://worldtimeapi.org/api/timezone/America/Toronto.txt"; char GET_ServerAddress[] = "http://worldtimeapi.org/api/timezone/America/Toronto.txt";
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.9.2" #define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.10.0"
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1009002 #define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1010000
// 600s = 10 minutes to not flooding, 60s in testing // 600s = 10 minutes to not flooding, 60s in testing
#define HTTP_REQUEST_INTERVAL_MS 60000 //600000 #define HTTP_REQUEST_INTERVAL_MS 60000 //600000

View File

@ -35,8 +35,8 @@ const char GET_ServerAddress[] = "dweet.io";
// use your own thing name here // use your own thing name here
String dweetName = "/dweet/for/currentSecond?second="; String dweetName = "/dweet/for/currentSecond?second=";
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.9.2" #define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.10.0"
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1009002 #define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1010000
// 600s = 10 minutes to not flooding, 60s in testing // 600s = 10 minutes to not flooding, 60s in testing
#define HTTP_REQUEST_INTERVAL_MS 60000 //600000 #define HTTP_REQUEST_INTERVAL_MS 60000 //600000

View File

@ -29,8 +29,8 @@ const char POST_ServerAddress[] = "dweet.io";
// use your own thing name here // use your own thing name here
String dweetName = "/dweet/for/pinA0-Read?"; String dweetName = "/dweet/for/pinA0-Read?";
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.9.2" #define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.10.0"
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1009002 #define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1010000
// 600s = 10 minutes to not flooding, 60s in testing // 600s = 10 minutes to not flooding, 60s in testing
#define HTTP_REQUEST_INTERVAL_MS 60000 //600000 #define HTTP_REQUEST_INTERVAL_MS 60000 //600000

View File

@ -44,8 +44,8 @@
#error This code is intended to run on the ESP8266 or ESP32 platform! Please check your Tools->Board setting. #error This code is intended to run on the ESP8266 or ESP32 platform! Please check your Tools->Board setting.
#endif #endif
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.9.2" #define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.10.0"
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1009002 #define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1010000
// Level from 0-4 // Level from 0-4
#define ASYNC_HTTP_DEBUG_PORT Serial #define ASYNC_HTTP_DEBUG_PORT Serial

View File

@ -46,7 +46,7 @@
// Level from 0-4 // Level from 0-4
#define ASYNC_HTTP_DEBUG_PORT Serial #define ASYNC_HTTP_DEBUG_PORT Serial
#define _ASYNC_HTTP_LOGLEVEL_ 3 #define _ASYNC_HTTP_LOGLEVEL_ 4
// 300s = 5 minutes to not flooding // 300s = 5 minutes to not flooding
#define HTTP_REQUEST_INTERVAL 60 //300 #define HTTP_REQUEST_INTERVAL 60 //300
@ -65,8 +65,8 @@ const char* password = "your_pass";
#include <WiFi.h> #include <WiFi.h>
#endif #endif
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.9.2" #define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.10.0"
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1009002 #define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1010000
// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error // To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error
#include <AsyncHTTPRequest_Generic.h> // https://github.com/khoih-prog/AsyncHTTPRequest_Generic #include <AsyncHTTPRequest_Generic.h> // https://github.com/khoih-prog/AsyncHTTPRequest_Generic

View File

@ -95,8 +95,8 @@ using TCPClient = WiFiClient;
////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.9.2" #define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.10.0"
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1009002 #define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1010000
// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error // To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error
#include <AsyncHTTPRequest_Generic.h> // https://github.com/khoih-prog/AsyncHTTPRequest_Generic #include <AsyncHTTPRequest_Generic.h> // https://github.com/khoih-prog/AsyncHTTPRequest_Generic

View File

@ -49,8 +49,8 @@
#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN_TARGET "ESPAsync_WiFiManager v1.15.0" #define ESP_ASYNC_WIFIMANAGER_VERSION_MIN_TARGET "ESPAsync_WiFiManager v1.15.0"
#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN 1015000 #define ESP_ASYNC_WIFIMANAGER_VERSION_MIN 1015000
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.9.2" #define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.10.0"
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1009002 #define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1010000
// Level from 0-4 // Level from 0-4
#define ASYNC_HTTP_DEBUG_PORT Serial #define ASYNC_HTTP_DEBUG_PORT Serial

View File

@ -42,8 +42,8 @@
#include "defines.h" #include "defines.h"
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.9.2" #define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.10.0"
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1009002 #define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1010000
// 600s = 10 minutes to not flooding, 60s in testing // 600s = 10 minutes to not flooding, 60s in testing
#define HTTP_REQUEST_INTERVAL_MS 60000 //600000 #define HTTP_REQUEST_INTERVAL_MS 60000 //600000

View File

@ -24,8 +24,8 @@
//char GET_ServerAddress[] = "ipv4bot.whatismyipaddress.com/"; //char GET_ServerAddress[] = "ipv4bot.whatismyipaddress.com/";
char GET_ServerAddress[] = "http://worldtimeapi.org/api/timezone/America/Toronto.txt"; char GET_ServerAddress[] = "http://worldtimeapi.org/api/timezone/America/Toronto.txt";
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.9.2" #define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.10.0"
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1009002 #define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1010000
// 600s = 10 minutes to not flooding, 60s in testing // 600s = 10 minutes to not flooding, 60s in testing
#define HTTP_REQUEST_INTERVAL_MS 60000 //600000 #define HTTP_REQUEST_INTERVAL_MS 60000 //600000

View File

@ -26,8 +26,8 @@ const char GET_ServerAddress[] = "arduino.tips";
// GET location // GET location
String GET_Location = "/asciilogo.txt"; String GET_Location = "/asciilogo.txt";
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.9.2" #define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.10.0"
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1009002 #define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1010000
// 600s = 10 minutes to not flooding, 60s in testing // 600s = 10 minutes to not flooding, 60s in testing
#define HTTP_REQUEST_INTERVAL_MS 60000 //600000 #define HTTP_REQUEST_INTERVAL_MS 60000 //600000

View File

@ -57,8 +57,8 @@
#include <WebServer_WT32_ETH01.h> // https://github.com/khoih-prog/WebServer_WT32_ETH01 #include <WebServer_WT32_ETH01.h> // https://github.com/khoih-prog/WebServer_WT32_ETH01
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.9.2" #define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.10.0"
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1009002 #define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1010000
// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error // To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error
#include <AsyncHTTPRequest_Generic.h> // https://github.com/khoih-prog/AsyncHTTPRequest_Generic #include <AsyncHTTPRequest_Generic.h> // https://github.com/khoih-prog/AsyncHTTPRequest_Generic

View File

@ -57,9 +57,8 @@
#include <WebServer_WT32_ETH01.h> // https://github.com/khoih-prog/WebServer_WT32_ETH01 #include <WebServer_WT32_ETH01.h> // https://github.com/khoih-prog/WebServer_WT32_ETH01
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.9.2" #define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.10.0"
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1009002 #define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1010000
// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error // To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error
#include <AsyncHTTPRequest_Generic.h> // https://github.com/khoih-prog/AsyncHTTPRequest_Generic #include <AsyncHTTPRequest_Generic.h> // https://github.com/khoih-prog/AsyncHTTPRequest_Generic

View File

@ -19,8 +19,8 @@
#error This code is intended to run on the ESP8266, ESP32 or STM32 platform! Please check your Tools->Board setting. #error This code is intended to run on the ESP8266, ESP32 or STM32 platform! Please check your Tools->Board setting.
#endif #endif
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.9.2" #define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.10.0"
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1009002 #define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1010000
#include "multiFileProject.h" #include "multiFileProject.h"

View File

@ -1,6 +1,6 @@
{ {
"name":"AsyncHTTPRequest_Generic", "name":"AsyncHTTPRequest_Generic",
"version": "1.9.2", "version": "1.10.0",
"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.", "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", "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": [ "authors": [

View File

@ -1,5 +1,5 @@
name=AsyncHTTPRequest_Generic name=AsyncHTTPRequest_Generic
version=1.9.2 version=1.10.0
author=Bob Lemaire,Khoi Hoang <khoih.prog@gmail.com> author=Bob Lemaire,Khoi Hoang <khoih.prog@gmail.com>
maintainer=Khoi Hoang <khoih.prog@gmail.com> maintainer=Khoi Hoang <khoih.prog@gmail.com>
license=GPLv3 license=GPLv3

View File

@ -18,7 +18,7 @@
You should have received a copy of the GNU General Public License along with this program. You should have received a copy of the GNU General Public License along with this program.
If not, see <https://www.gnu.org/licenses/>. If not, see <https://www.gnu.org/licenses/>.
Version: 1.9.2 Version: 1.10.0
Version Modified By Date Comments Version Modified By Date Comments
------- ----------- ---------- ----------- ------- ----------- ---------- -----------
@ -32,6 +32,7 @@
1.9.0 K Hoang 30/08/2022 Fix bug. Improve debug messages. Optimize code 1.9.0 K Hoang 30/08/2022 Fix bug. Improve debug messages. Optimize code
1.9.1 K Hoang 09/09/2022 Fix ESP32 chipID for example `AsyncHTTPRequest_ESP_WiFiManager` 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.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
*****************************************************************************************************************************/ *****************************************************************************************************************************/
#pragma once #pragma once

View File

@ -18,7 +18,7 @@
You should have received a copy of the GNU General Public License along with this program. You should have received a copy of the GNU General Public License along with this program.
If not, see <https://www.gnu.org/licenses/>. If not, see <https://www.gnu.org/licenses/>.
Version: 1.9.2 Version: 1.10.0
Version Modified By Date Comments Version Modified By Date Comments
------- ----------- ---------- ----------- ------- ----------- ---------- -----------
@ -32,6 +32,7 @@
1.9.0 K Hoang 30/08/2022 Fix bug. Improve debug messages. Optimize code 1.9.0 K Hoang 30/08/2022 Fix bug. Improve debug messages. Optimize code
1.9.1 K Hoang 09/09/2022 Fix ESP32 chipID for example `AsyncHTTPRequest_ESP_WiFiManager` 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.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
*****************************************************************************************************************************/ *****************************************************************************************************************************/
#pragma once #pragma once

View File

@ -18,7 +18,7 @@
You should have received a copy of the GNU General Public License along with this program. You should have received a copy of the GNU General Public License along with this program.
If not, see <https://www.gnu.org/licenses/>. If not, see <https://www.gnu.org/licenses/>.
Version: 1.9.2 Version: 1.10.0
Version Modified By Date Comments Version Modified By Date Comments
------- ----------- ---------- ----------- ------- ----------- ---------- -----------
@ -32,6 +32,7 @@
1.9.0 K Hoang 30/08/2022 Fix bug. Improve debug messages. Optimize code 1.9.0 K Hoang 30/08/2022 Fix bug. Improve debug messages. Optimize code
1.9.1 K Hoang 09/09/2022 Fix ESP32 chipID for example `AsyncHTTPRequest_ESP_WiFiManager` 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.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
*****************************************************************************************************************************/ *****************************************************************************************************************************/
#pragma once #pragma once
@ -39,18 +40,24 @@
#ifndef ASYNC_HTTP_REQUEST_GENERIC_HPP #ifndef ASYNC_HTTP_REQUEST_GENERIC_HPP
#define ASYNC_HTTP_REQUEST_GENERIC_HPP #define ASYNC_HTTP_REQUEST_GENERIC_HPP
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION "AsyncHTTPRequest_Generic v1.9.2" ////////////////////////////////////////
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION "AsyncHTTPRequest_Generic v1.10.0"
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MAJOR 1 #define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MAJOR 1
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MINOR 9 #define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MINOR 10
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_PATCH 2 #define ASYNC_HTTP_REQUEST_GENERIC_VERSION_PATCH 0
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_INT 1009002 #define ASYNC_HTTP_REQUEST_GENERIC_VERSION_INT 1010000
////////////////////////////////////////
#include <Arduino.h> #include <Arduino.h>
#include "AsyncHTTPRequest_Debug_Generic.h" #include "AsyncHTTPRequest_Debug_Generic.h"
////////////////////////////////////////
#ifndef DEBUG_IOTA_PORT #ifndef DEBUG_IOTA_PORT
#define DEBUG_IOTA_PORT Serial #define DEBUG_IOTA_PORT Serial
#endif #endif
@ -61,11 +68,20 @@
#define DEBUG_IOTA_HTTP_SET false #define DEBUG_IOTA_HTTP_SET false
#endif #endif
////////////////////////////////////////
// KH add // KH add
#define SAFE_DELETE(object) if (object) { delete object;} #define SAFE_DELETE(object) if (object) { delete object;}
#define SAFE_DELETE_ARRAY(object) if (object) { delete[] object;} #define SAFE_DELETE_ARRAY(object) if (object) { delete[] object;}
#define ASYNC_HTTP_PREFIX "HTTP://"
#define ASYNC_HTTP_PORT 80
#define ASYNC_HTTPS_PREFIX "HTTPS://"
#define ASYNC_HTTPS_PORT 443
////////////////////////////////////////
#if ESP32 #if ESP32
#include <AsyncTCP.h> #include <AsyncTCP.h>
@ -87,9 +103,9 @@
#define _AHTTP_lock #define _AHTTP_lock
#define _AHTTP_unlock #define _AHTTP_unlock
#elif ( defined(STM32F0) || defined(STM32F1) || defined(STM32F2) || defined(STM32F3) ||defined(STM32F4) || defined(STM32F7) || \ #elif ( defined(STM32F0) || defined(STM32F1) || defined(STM32F2) || defined(STM32F3) ||defined(STM32F4) || \
defined(STM32L0) || defined(STM32L1) || defined(STM32L4) || defined(STM32H7) ||defined(STM32G0) || defined(STM32G4) || \ defined(STM32F7) || defined(STM32L0) || defined(STM32L1) || defined(STM32L4) || defined(STM32H7) || \
defined(STM32WB) || defined(STM32MP1) ) defined(STM32G0) || defined(STM32G4) || defined(STM32WB) || defined(STM32MP1) )
#include "STM32AsyncTCP.h" #include "STM32AsyncTCP.h"
@ -100,10 +116,12 @@
#endif #endif
////////////////////////////////////////
#include <pgmspace.h> #include <pgmspace.h>
// Merge xbuf // Merge xbuf
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////
struct xseg struct xseg
{ {
@ -111,6 +129,8 @@ struct xseg
uint8_t data[]; uint8_t data[];
}; };
////////////////////////////////////////
class xbuf: public Print class xbuf: public Print
{ {
public: public:
@ -204,7 +224,7 @@ class xbuf: public Print
}; };
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////
#define DEBUG_HTTP(format,...) if(_debug){\ #define DEBUG_HTTP(format,...) if(_debug){\
DEBUG_IOTA_PORT.printf("Debug(%3ld): ", millis()-_requestStartTime);\ DEBUG_IOTA_PORT.printf("Debug(%3ld): ", millis()-_requestStartTime);\
@ -212,6 +232,8 @@ class xbuf: public Print
#define DEFAULT_RX_TIMEOUT 3 // Seconds for timeout #define DEFAULT_RX_TIMEOUT 3 // Seconds for timeout
////////////////////////////////////////
#define HTTPCODE_CONNECTION_REFUSED (-1) #define HTTPCODE_CONNECTION_REFUSED (-1)
#define HTTPCODE_SEND_HEADER_FAILED (-2) #define HTTPCODE_SEND_HEADER_FAILED (-2)
#define HTTPCODE_SEND_PAYLOAD_FAILED (-3) #define HTTPCODE_SEND_PAYLOAD_FAILED (-3)
@ -224,6 +246,8 @@ class xbuf: public Print
#define HTTPCODE_STREAM_WRITE (-10) #define HTTPCODE_STREAM_WRITE (-10)
#define HTTPCODE_TIMEOUT (-11) #define HTTPCODE_TIMEOUT (-11)
////////////////////////////////////////
typedef enum typedef enum
{ {
readyStateUnsent = 0, // Client created, open not yet called readyStateUnsent = 0, // Client created, open not yet called
@ -232,62 +256,68 @@ typedef enum
readyStateLoading = 3, // receiving, partial data available readyStateLoading = 3, // receiving, partial data available
readyStateDone = 4 // Request complete, all data available. readyStateDone = 4 // Request complete, all data available.
} reqStates; } reqStates;
////////////////////////////////////////
class AsyncHTTPRequest class AsyncHTTPRequest
{ {
struct header struct header
{
header* next;
char* name;
char* value;
header(): next(nullptr), name(nullptr), value(nullptr)
{};
~header()
{ {
header* next; SAFE_DELETE_ARRAY(name)
char* name; SAFE_DELETE_ARRAY(value)
char* value; SAFE_DELETE(next)
//delete[] name;
header(): next(nullptr), name(nullptr), value(nullptr) //delete[] value;
{}; //delete next;
}
~header() };
{
SAFE_DELETE_ARRAY(name)
SAFE_DELETE_ARRAY(value)
SAFE_DELETE(next)
//delete[] name;
//delete[] value;
//delete next;
}
};
struct URL struct URL
{ {
char *buffer; char *buffer;
char *scheme; char *scheme;
char *host; char *host;
int port; int port;
char *path; char *path;
char *query; char *query;
URL(): buffer(nullptr), scheme(nullptr), host(nullptr),
port(80), path(nullptr), query(nullptr)
{};
URL(): buffer(nullptr), scheme(nullptr), host(nullptr), ~URL()
port(80), path(nullptr), query(nullptr) {
{}; SAFE_DELETE_ARRAY(buffer)
SAFE_DELETE_ARRAY(scheme)
~URL() SAFE_DELETE_ARRAY(host)
{ SAFE_DELETE_ARRAY(path)
SAFE_DELETE_ARRAY(buffer) SAFE_DELETE_ARRAY(query)
SAFE_DELETE_ARRAY(scheme) }
SAFE_DELETE_ARRAY(host) };
SAFE_DELETE_ARRAY(path)
SAFE_DELETE_ARRAY(query)
}
};
typedef std::function<void(void*, AsyncHTTPRequest*, int readyState)> readyStateChangeCB;
typedef std::function<void(void*, AsyncHTTPRequest*, size_t available)> onDataCB;
typedef std::function<void(void*, AsyncHTTPRequest*, int readyState)> readyStateChangeCB;
typedef std::function<void(void*, AsyncHTTPRequest*, size_t available)> onDataCB;
////////////////////////////////////////
public: public:
AsyncHTTPRequest(); AsyncHTTPRequest();
~AsyncHTTPRequest(); ~AsyncHTTPRequest();
//External functions in typical order of use: //External functions in typical order of use:
//__________________________________________________________________________________________________________*/
////////////////////////////////////////
void setDebug(bool); // Turn debug message on/off void setDebug(bool); // Turn debug message on/off
bool debug(); // is debug on or off? bool debug(); // is debug on or off?
@ -341,16 +371,23 @@ class AsyncHTTPRequest
size_t responseRead(uint8_t* buffer, size_t len); // Read response into buffer size_t responseRead(uint8_t* buffer, size_t len); // Read response into buffer
uint32_t elapsedTime(); // Elapsed time of in progress transaction or last completed (ms) uint32_t elapsedTime(); // Elapsed time of in progress transaction or last completed (ms)
String version(); // Version of AsyncHTTPRequest String version(); // Version of AsyncHTTPRequest
//___________________________________________________________________________________________________________________________________
////////////////////////////////////////
private: private:
// New in v1.1.1
bool _requestReadyToSend; bool _requestReadyToSend;
//////
typedef enum
// New in v1.1.0 {
typedef enum { HTTPmethodGET, HTTPmethodPOST, HTTPmethodPUT, HTTPmethodPATCH, HTTPmethodDELETE, HTTPmethodHEAD, HTTPmethodMAX } HTTPmethod; HTTPmethodGET,
HTTPmethodPOST,
HTTPmethodPUT,
HTTPmethodPATCH,
HTTPmethodDELETE,
HTTPmethodHEAD,
HTTPmethodMAX
} HTTPmethod;
HTTPmethod _HTTPmethod; HTTPmethod _HTTPmethod;
@ -415,4 +452,6 @@ class AsyncHTTPRequest
bool _collectHeaders(); bool _collectHeaders();
}; };
////////////////////////////////////////
#endif // ASYNC_HTTP_REQUEST_GENERIC_HPP #endif // ASYNC_HTTP_REQUEST_GENERIC_HPP

File diff suppressed because it is too large Load Diff