v1.9.2 not to reconnect after connected

### 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)
2. Update `Packages' Patches`
This commit is contained in:
Khoi Hoang
2022-10-18 22:36:53 -04:00
committed by GitHub
parent dcdf3dc5f9
commit 79f62c3f4a
23 changed files with 150 additions and 90 deletions

View File

@ -15,7 +15,7 @@ If you don't find anything, please [open a new issue](https://github.com/khoih-p
Please ensure to specify the following:
* Arduino IDE version (e.g. 1.8.19) or Platform.io version
* `ESP8266`,`ESP32` or `STM32` Core Version (e.g. ESP8266 core v3.0.2, ESP32 v2.0.4 or STM32 v2.3.0)
* `ESP8266`,`ESP32` or `STM32` Core Version (e.g. ESP8266 core v3.0.2, ESP32 v2.0.5 or STM32 v2.3.0)
* Contextual information (e.g. what you were trying to achieve)
* Simplest possible steps to reproduce
* Anything that might be relevant in your opinion, such as:
@ -27,12 +27,12 @@ Please ensure to specify the following:
```
Arduino IDE version: 1.8.19
ESP32 Core Version 2.0.4
ESP32 Core Version 2.0.5
OS: Ubuntu 20.04 LTS
Linux xy-Inspiron-3593 5.15.0-46-generic #49~20.04.1-Ubuntu SMP Thu Aug 4 19:15:44 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
Linux xy-Inspiron-3593 5.15.0-50-generic #56~20.04.1-Ubuntu SMP Tue Sep 27 15:51:29 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
Context:
I encountered an endless loop while trying to connect to Local WiFi.
I encountered a crash when using this library
Steps to reproduce:
1. ...

View File

@ -12,6 +12,7 @@
## Table of Contents
* [Changelog](#changelog)
* [Releases v1.9.2](#releases-v192)
* [Releases v1.9.1](#releases-v191)
* [Releases v1.9.0](#releases-v190)
* [Releases v1.8.2](#releases-v182)
@ -41,6 +42,11 @@
## Changelog
### 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)
2. Update `Packages' Patches`
### Releases v1.9.1
1. Fix ESP32 chipID for example `AsyncHTTPRequest_ESP_WiFiManager`

View File

@ -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.9.1"
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1009001
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.9.2"
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1009002
// 600s = 10 minutes to not flooding, 60s in testing
#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
String dweetName = "/dweet/for/currentSecond?second=";
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.9.1"
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1009001
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.9.2"
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1009002
// 600s = 10 minutes to not flooding, 60s in testing
#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
String dweetName = "/dweet/for/pinA0-Read?";
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.9.1"
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1009001
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.9.2"
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1009002
// 600s = 10 minutes to not flooding, 60s in testing
#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.
#endif
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.9.1"
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1009001
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.9.2"
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1009002
// Level from 0-4
#define ASYNC_HTTP_DEBUG_PORT Serial

View File

@ -46,7 +46,7 @@
// Level from 0-4
#define ASYNC_HTTP_DEBUG_PORT Serial
#define _ASYNC_HTTP_LOGLEVEL_ 1
#define _ASYNC_HTTP_LOGLEVEL_ 3
// 300s = 5 minutes to not flooding
#define HTTP_REQUEST_INTERVAL 60 //300
@ -65,8 +65,8 @@ const char* password = "your_pass";
#include <WiFi.h>
#endif
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.9.1"
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1009001
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.9.2"
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1009002
// 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

View File

@ -95,8 +95,8 @@ using TCPClient = WiFiClient;
//////////////////////////////////////////////////////////
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.9.1"
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1009001
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.9.2"
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1009002
// 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

View File

@ -139,15 +139,14 @@ void sendRequests()
reqCount[1] = NUM_ENTRIES_SITE_1;
}
void requestCB0(void* optParm, AsyncHTTPRequest* thisRequest, int readyState)
{
(void) optParm;
if (readyState == readyStateDone)
{
AHTTP_LOGERROR(F("\n**************************************"));
AHTTP_LOGERROR1(F("Response Code = "), request->responseHTTPString());
AHTTP_LOGWARN(F("\n**************************************"));
AHTTP_LOGWARN1(F("Response Code = "), request->responseHTTPString());
if (request->responseHTTPcode() == 200)
{
@ -171,8 +170,8 @@ void requestCB1(void* optParm, AsyncHTTPRequest* thisRequest, int readyState)
if (readyState == readyStateDone)
{
AHTTP_LOGERROR(F("\n**************************************"));
AHTTP_LOGERROR1(F("Response Code = "), request->responseHTTPString());
AHTTP_LOGWARN(F("\n**************************************"));
AHTTP_LOGWARN1(F("Response Code = "), request->responseHTTPString());
if (request->responseHTTPcode() == 200)
{
@ -207,7 +206,7 @@ void setup()
while (WiFi.status() != WL_CONNECTED)
{
delay(500);
delay(1000);
Serial.print(".");
}
@ -231,12 +230,11 @@ void loop()
for (int index = 0; index < NUM_DIFFERENT_SITES; index++)
{
if ((reqCount[index] > 0) && readySend[index])
// OK but have to use delay(100)
//if ( reqCount[index] > 0 )
{
sendRequestCB[index]();
//delay(100);
// Don't send too fast
delay(1000);
}
}
}

View File

@ -46,11 +46,11 @@
#error This code is intended to run on the ESP8266 or ESP32 platform! Please check your Tools->Board setting.
#endif
#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN_TARGET "ESPAsync_WiFiManager v1.14.0"
#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN 1014000
#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.9.1"
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1009001
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.9.2"
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1009002
// Level from 0-4
#define ASYNC_HTTP_DEBUG_PORT Serial

View File

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

View File

@ -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.9.1"
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1009001
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.9.2"
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1009002
// 600s = 10 minutes to not flooding, 60s in testing
#define HTTP_REQUEST_INTERVAL_MS 60000 //600000

View File

@ -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.9.1"
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1009001
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.9.2"
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1009002
// 600s = 10 minutes to not flooding, 60s in testing
#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
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.9.1"
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1009001
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.9.2"
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1009002
// 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

View File

@ -57,8 +57,8 @@
#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.1"
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1009001
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.9.2"
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1009002
// 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

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.
#endif
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.9.1"
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1009001
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN_TARGET "AsyncHTTPRequest_Generic v1.9.2"
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MIN 1009002
#include "multiFileProject.h"

View File

@ -1,6 +1,6 @@
{
"name":"AsyncHTTPRequest_Generic",
"version": "1.9.1",
"version": "1.9.2",
"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": [
@ -45,7 +45,7 @@
{
"owner": "khoih-prog",
"name": "ESPAsync_WiFiManager",
"version": ">=1.14.0",
"version": ">=1.15.0",
"platforms": ["espressif8266", "espressif32"]
},
{
@ -63,12 +63,13 @@
{
"owner": "khoih-prog",
"name": "WebServer_WT32_ETH01",
"version": ">=1.5.0",
"version": ">=1.5.1",
"platforms": ["espressif32"]
},
{
"name": "STM32AsyncTCP",
"version": "https://github.com/khoih-prog/STM32AsyncTCP"
"version": "https://github.com/khoih-prog/STM32AsyncTCP",
"platforms": "ststm32"
}
],
"license": "LGPL-3.0",

View File

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

View File

@ -45,20 +45,20 @@ lib_deps =
; https://github.com/khoih-prog/STM32AsyncTCP.git
; STM32duino LwIP@>=2.1.2
; STM32duino STM32Ethernet@>=1.3.0
; ESPAsync_WiFiManager@>=1.14.0
; ESPAsync_WiFiManager@>=1.15.0
; LittleFS_esp32@>=1.0.6
; WebServer_WT32_ETH01@>=1.5.0
; WebServer_WT32_ETH01@>=1.5.1
;
; PlatformIO 5.x
me-no-dev/AsyncTCP@>=1.1.1
me-no-dev/ESPAsyncTCP@>=1.2.2
; me-no-dev/AsyncTCP@>=1.1.1
; me-no-dev/ESPAsyncTCP@>=1.2.2
; philbowles/STM32AsyncTCP
; https://github.com/khoih-prog/STM32AsyncTCP.git
; stm32duino/STM32duino LwIP@>=2.1.2
; stm32duino/STM32duino STM32Ethernet@>=1.3.0
khoih-prog/ESPAsync_WiFiManager@>=1.14.0
; khoih-prog/ESPAsync_WiFiManager@>=1.15.0
; lorol/LittleFS_esp32@>=1.0.6
; khoih-prog/WebServer_WT32_ETH01@>=1.5.0
; khoih-prog/WebServer_WT32_ETH01@>=1.5.1
build_flags =
; set your debug output (default=Serial)
@ -69,6 +69,16 @@ build_flags =
[env:ESP8266]
platform = espressif8266
framework = arduino
lib_deps =
; PlatformIO 4.x
; ESPAsyncTCP@>=1.2.2
; ESPAsync_WiFiManager@>=1.15.0
;
; PlatformIO 5.x
me-no-dev/ESPAsyncTCP@>=1.2.2
khoih-prog/ESPAsync_WiFiManager@>=1.15.0
; ============================================================
; Board configuration
; choose your board by uncommenting one of the following lines
@ -114,6 +124,20 @@ board = nodemcuv2
[env:ESP32]
platform = espressif32
framework = arduino
lib_deps =
; PlatformIO 4.x
; AsyncTCP@>=1.1.1
; ESPAsync_WiFiManager@>=1.15.0
; LittleFS_esp32@>=1.0.6
; WebServer_WT32_ETH01@>=1.5.1
;
; PlatformIO 5.x
me-no-dev/AsyncTCP@>=1.1.1
khoih-prog/ESPAsync_WiFiManager@>=1.15.0
; lorol/LittleFS_esp32@>=1.0.6
khoih-prog/WebServer_WT32_ETH01@>=1.5.1
; ============================================================
; Board configuration
; choose your board by uncommenting one of the following lines
@ -250,6 +274,18 @@ board = feather52840
platform = ststm32
framework = arduino
lib_deps =
; PlatformIO 4.x
; https://github.com/khoih-prog/STM32AsyncTCP.git
; STM32duino LwIP@>=2.1.2
; STM32duino STM32Ethernet@>=1.3.0
;
; PlatformIO 5.x
philbowles/STM32AsyncTCP
https://github.com/khoih-prog/STM32AsyncTCP.git
stm32duino/STM32duino LwIP@>=2.1.2
stm32duino/STM32duino STM32Ethernet@>=1.3.0
; ============================================================
; Choose your board by uncommenting one of the following lines
; ============================================================

View File

@ -18,7 +18,7 @@
You should have received a copy of the GNU General Public License along with this program.
If not, see <https://www.gnu.org/licenses/>.
Version: 1.9.1
Version: 1.9.2
Version Modified By Date Comments
------- ----------- ---------- -----------
@ -31,6 +31,7 @@
1.8.2 K Hoang 10/08/2022 Fix library.properties to remove unavailable items from depends
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.2 K Hoang 18/10/2022 Not try to reconnect to the same host:port after connected
*****************************************************************************************************************************/
#pragma once

View File

@ -18,7 +18,7 @@
You should have received a copy of the GNU General Public License along with this program.
If not, see <https://www.gnu.org/licenses/>.
Version: 1.9.1
Version: 1.9.2
Version Modified By Date Comments
------- ----------- ---------- -----------
@ -31,6 +31,7 @@
1.8.2 K Hoang 10/08/2022 Fix library.properties to remove unavailable items from depends
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.2 K Hoang 18/10/2022 Not try to reconnect to the same host:port after connected
*****************************************************************************************************************************/
#pragma once

View File

@ -18,7 +18,7 @@
You should have received a copy of the GNU General Public License along with this program.
If not, see <https://www.gnu.org/licenses/>.
Version: 1.9.1
Version: 1.9.2
Version Modified By Date Comments
------- ----------- ---------- -----------
@ -31,6 +31,7 @@
1.8.2 K Hoang 10/08/2022 Fix library.properties to remove unavailable items from depends
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.2 K Hoang 18/10/2022 Not try to reconnect to the same host:port after connected
*****************************************************************************************************************************/
#pragma once
@ -38,13 +39,13 @@
#ifndef ASYNC_HTTP_REQUEST_GENERIC_HPP
#define ASYNC_HTTP_REQUEST_GENERIC_HPP
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION "AsyncHTTPRequest_Generic v1.9.1"
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION "AsyncHTTPRequest_Generic v1.9.2"
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MAJOR 1
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_MINOR 9
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_PATCH 1
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_PATCH 2
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_INT 1009001
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION_INT 1009002
#include <Arduino.h>

View File

@ -18,7 +18,7 @@
You should have received a copy of the GNU General Public License along with this program.
If not, see <https://www.gnu.org/licenses/>.
Version: 1.9.1
Version: 1.9.2
Version Modified By Date Comments
------- ----------- ---------- -----------
@ -31,6 +31,7 @@
1.8.2 K Hoang 10/08/2022 Fix library.properties to remove unavailable items from depends
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.2 K Hoang 18/10/2022 Not try to reconnect to the same host:port after connected
*****************************************************************************************************************************/
#pragma once
@ -305,7 +306,7 @@ String xbuf::readString(int endPos)
if ( ! result.reserve(endPos + 1))
{
// KH, to remove
//AHTTP_LOGERROR1(F("xbuf::readString: can't reserve size ="), endPos + 1);
//AHTTP_LOGDEBUG1(F("xbuf::readString: can't reserve size ="), endPos + 1);
///////
return result;
@ -388,7 +389,7 @@ void xbuf::addSeg()
if (_tail->next == NULL)
{
AHTTP_LOGERROR(F("xbuf::addSeg: error new 1"));
AHTTP_LOGDEBUG(F("xbuf::addSeg: error new 1"));
}
else
{
@ -402,7 +403,7 @@ void xbuf::addSeg()
_tail = _head = (xseg*) new uint32_t[_segSize / 4 + 1];
if (_tail == NULL)
AHTTP_LOGERROR(F("xbuf::addSeg: error new 2"));
AHTTP_LOGDEBUG(F("xbuf::addSeg: error new 2"));
}
// KH, Must check NULL here
@ -493,7 +494,7 @@ bool AsyncHTTPRequest::open(const char* method, const char* URL)
if (_readyState != readyStateUnsent && _readyState != readyStateDone)
{
AHTTP_LOGERROR(F("open: not ready"));
AHTTP_LOGWARN(F("open: not ready"));
return false;
}
@ -559,12 +560,25 @@ bool AsyncHTTPRequest::open(const char* method, const char* URL)
return false;
}
if ( _client && _client->connected() && (strcmp(_URL->host, _connectedHost) != 0 || _URL->port != _connectedPort))
if ( _client && _client->connected() )
{
AHTTP_LOGERROR(F("open: not connected"));
if ( (strcmp(_URL->host, _connectedHost) == 0) && (_URL->port == _connectedPort) )
{
AHTTP_LOGINFO(F("open: already connected"));
_lastActivity = millis();
return false;
_requestReadyToSend = true;
return _connect();
}
else
{
AHTTP_LOGINFO(F("open: not connected: different host or port"));
return false;
}
}
char* hostName = new char[strlen(_URL->host) + 10];
@ -609,7 +623,7 @@ void AsyncHTTPRequest::setTimeout(int seconds)
}
//**************************************************************************************************************
bool AsyncHTTPRequest::send()
bool AsyncHTTPRequest::send()
{
// New in v1.1.1
if (_requestReadyToSend)
@ -618,7 +632,8 @@ bool AsyncHTTPRequest::send()
}
else
{
AHTTP_LOGERROR(CANT_SEND_BAD_REQUEST);
AHTTP_LOGWARN(CANT_SEND_BAD_REQUEST);
return false;
}
//////
@ -645,16 +660,17 @@ bool AsyncHTTPRequest::send(const String& body)
}
else
{
AHTTP_LOGERROR(CANT_SEND_BAD_REQUEST);
AHTTP_LOGWARN(CANT_SEND_BAD_REQUEST);
return false;
}
//////
AHTTP_LOGERROR1(F("01) send String body ="), body);
AHTTP_LOGDEBUG1(F("01) send String body ="), body);
MUTEX_LOCK(false)
AHTTP_LOGERROR1(F("02) send String body ="), body);
AHTTP_LOGDEBUG1(F("02) send String body ="), body);
_addHeader("Content-Length", String(body.length()).c_str());
@ -665,14 +681,14 @@ bool AsyncHTTPRequest::send(const String& body)
return false;
}
AHTTP_LOGERROR1(F("1) send String body ="), body);
AHTTP_LOGDEBUG1(F("1) send String body ="), body);
_request->write(body);
AHTTP_LOGERROR1(F("2) send String body ="), body);
AHTTP_LOGDEBUG1(F("2) send String body ="), body);
_send();
AHTTP_LOGERROR1(F("3) send String body ="), body);
AHTTP_LOGDEBUG1(F("3) send String body ="), body);
_AHTTP_unlock;
@ -689,7 +705,7 @@ bool AsyncHTTPRequest::send(const char* body)
}
else
{
AHTTP_LOGERROR(CANT_SEND_BAD_REQUEST);
AHTTP_LOGWARN(CANT_SEND_BAD_REQUEST);
return false;
}
//////
@ -723,7 +739,7 @@ bool AsyncHTTPRequest::send(const uint8_t* body, size_t len)
}
else
{
AHTTP_LOGERROR(CANT_SEND_BAD_REQUEST);
AHTTP_LOGWARN(CANT_SEND_BAD_REQUEST);
return false;
}
//////
@ -757,7 +773,8 @@ bool AsyncHTTPRequest::send(xbuf* body, size_t len)
}
else
{
AHTTP_LOGERROR(CANT_SEND_BAD_REQUEST);
AHTTP_LOGWARN(CANT_SEND_BAD_REQUEST);
return false;
}
//////
@ -893,7 +910,7 @@ String AsyncHTTPRequest::responseText()
if ( ! _response || _readyState < readyStateLoading || ! available())
{
AHTTP_LOGERROR(F("responseText() no data"));
AHTTP_LOGWARN(F("responseText() no data"));
_AHTTP_unlock;
@ -906,7 +923,7 @@ String AsyncHTTPRequest::responseText()
if (localString.length() < avail)
{
AHTTP_LOGERROR(F("!responseText() no buffer"))
AHTTP_LOGWARN(F("!responseText() no buffer"))
_HTTPcode = HTTPCODE_TOO_LESS_RAM;
_client->abort();
_AHTTP_unlock;
@ -943,7 +960,7 @@ char* AsyncHTTPRequest::responseLongText()
if ( ! _response || _readyState < readyStateLoading || ! available())
{
AHTTP_LOGERROR(F("responseText() no data"));
AHTTP_LOGWARN(F("responseText() no data"));
_AHTTP_unlock;
@ -972,7 +989,7 @@ size_t AsyncHTTPRequest::responseRead(uint8_t* buf, size_t len)
{
if ( ! _response || _readyState < readyStateLoading || ! available())
{
AHTTP_LOGERROR(F("responseRead() no data"));
AHTTP_LOGWARN(F("responseRead() no data"));
return 0;
}
@ -1179,7 +1196,7 @@ bool AsyncHTTPRequest::_connect()
if ( ! _client->connected())
{
AHTTP_LOGDEBUG3(F("_client->connecting to"), _URL->host, F(","), _URL->port);
AHTTP_LOGINFO3(F("_client->connecting to"), _URL->host, F(","), _URL->port);
if ( ! _client->connect(_URL->host, _URL->port))
{
@ -1192,7 +1209,7 @@ bool AsyncHTTPRequest::_connect()
}
else
{
AHTTP_LOGDEBUG3(F("client.connect OK to"), _URL->host, F(","), _URL->port);
AHTTP_LOGINFO3(F("client.connect OK to"), _URL->host, F(","), _URL->port);
}
}
else
@ -1418,7 +1435,7 @@ void AsyncHTTPRequest::_onConnect(AsyncClient* client)
_AHTTP_unlock;
// KH, to remove
//AHTTP_LOGERROR(F("_onConnect: Can't new _response"));
//AHTTP_LOGWARN(F("_onConnect: Can't new _response"));
///////
return;
@ -1482,7 +1499,6 @@ void AsyncHTTPRequest::_onError(AsyncClient* client, int8_t error)
{
(void) client;
//AHTTP_LOGERROR1(F("_onError handler error ="), error);
AHTTP_LOGERROR1(F("_onError handler error ="), client->errorToString(error));
_HTTPcode = error;
@ -1558,7 +1574,7 @@ void AsyncHTTPRequest::_onData(void* Vbuf, size_t len)
_AHTTP_unlock;
// KH, to remove
//AHTTP_LOGERROR(F("_onData: headers not complete"));
//AHTTP_LOGWARN(F("_onData: headers not complete"));
///////
return;