mirror of
https://github.com/khoih-prog/AsyncHTTPRequest_Generic.git
synced 2025-07-30 02:17:14 +02:00
v1.1.2
### Releases v1.1.2 1. Rename _lock and _unlock to avoid conflict with [**ESP32/ESP8266 AsyncWebServer**](https://github.com/me-no-dev/ESPAsyncWebServer) library. Check [**compatibility with ESPAsyncWebServer #11**](https://github.com/khoih-prog/AsyncHTTPRequest_Generic/issues/11) 2. Fix compiler warnings.
This commit is contained in:
136
README.md
136
README.md
@ -17,6 +17,7 @@
|
|||||||
* [Supports](#supports)
|
* [Supports](#supports)
|
||||||
* [Principles of operation](#principles-of-operation)
|
* [Principles of operation](#principles-of-operation)
|
||||||
* [Changelog](#changelog)
|
* [Changelog](#changelog)
|
||||||
|
* [Releases v1.1.2](#releases-v112)
|
||||||
* [Releases v1.1.1](#releases-v111)
|
* [Releases v1.1.1](#releases-v111)
|
||||||
* [Releases v1.1.0](#releases-v110)
|
* [Releases v1.1.0](#releases-v110)
|
||||||
* [Releases v1.0.2](#releases-v102)
|
* [Releases v1.0.2](#releases-v102)
|
||||||
@ -29,7 +30,17 @@
|
|||||||
* [Manual Install](#manual-install)
|
* [Manual Install](#manual-install)
|
||||||
* [VS Code & PlatformIO](#vs-code--platformio)
|
* [VS Code & PlatformIO](#vs-code--platformio)
|
||||||
* [Packages' Patches](#packages-patches)
|
* [Packages' Patches](#packages-patches)
|
||||||
|
* [1. For Adafruit nRF52840 and nRF52832 boards](#1-for-adafruit-nRF52840-and-nRF52832-boards)
|
||||||
|
* [2. For Teensy boards](#2-for-teensy-boards)
|
||||||
|
* [3. For Arduino SAM DUE boards](#3-for-arduino-sam-due-boards)
|
||||||
|
* [4. For Arduino SAMD boards](#4-for-arduino-samd-boards)
|
||||||
|
* [For core version v1.8.10+](#for-core-version-v1810)
|
||||||
|
* [For core version v1.8.9-](#for-core-version-v189-)
|
||||||
|
* [5. For Adafruit SAMD boards](#5-for-adafruit-samd-boards)
|
||||||
|
* [6. For Seeeduino SAMD boards](#6-for-seeeduino-samd-boards)
|
||||||
|
* [7. For STM32 boards](#7-for-stm32-boards)
|
||||||
* [HOWTO Fix `Multiple Definitions` Linker Error](#howto-fix-multiple-definitions-linker-error)
|
* [HOWTO Fix `Multiple Definitions` Linker Error](#howto-fix-multiple-definitions-linker-error)
|
||||||
|
* [Note for Platform IO using ESP32 LittleFS](#note-for-platform-io-using-esp32-littlefs)
|
||||||
* [HOWTO Use analogRead() with ESP32 running WiFi and/or BlueTooth (BT/BLE)](#howto-use-analogread-with-esp32-running-wifi-andor-bluetooth-btble)
|
* [HOWTO Use analogRead() with ESP32 running WiFi and/or BlueTooth (BT/BLE)](#howto-use-analogread-with-esp32-running-wifi-andor-bluetooth-btble)
|
||||||
* [1. ESP32 has 2 ADCs, named ADC1 and ADC2](#1--esp32-has-2-adcs-named-adc1-and-adc2)
|
* [1. ESP32 has 2 ADCs, named ADC1 and ADC2](#1--esp32-has-2-adcs-named-adc1-and-adc2)
|
||||||
* [2. ESP32 ADCs functions](#2-esp32-adcs-functions)
|
* [2. ESP32 ADCs functions](#2-esp32-adcs-functions)
|
||||||
@ -105,6 +116,11 @@ Chunked responses are recognized and handled transparently.
|
|||||||
|
|
||||||
## Changelog
|
## Changelog
|
||||||
|
|
||||||
|
### Releases v1.1.2
|
||||||
|
|
||||||
|
1. Rename _lock and _unlock to avoid conflict with [**ESP32/ESP8266 AsyncWebServer**](https://github.com/me-no-dev/ESPAsyncWebServer) library. Check [**compatibility with ESPAsyncWebServer #11**](https://github.com/khoih-prog/AsyncHTTPRequest_Generic/issues/11)
|
||||||
|
2. Fix compiler warnings.
|
||||||
|
|
||||||
### Releases v1.1.1
|
### Releases v1.1.1
|
||||||
|
|
||||||
1. Prevent crash if request and/or method not correct.
|
1. Prevent crash if request and/or method not correct.
|
||||||
@ -155,13 +171,13 @@ This library is based on, modified from:
|
|||||||
## Prerequisites
|
## Prerequisites
|
||||||
|
|
||||||
1. [`Arduino IDE 1.8.13+` for Arduino](https://www.arduino.cc/en/Main/Software)
|
1. [`Arduino IDE 1.8.13+` for Arduino](https://www.arduino.cc/en/Main/Software)
|
||||||
2. [`ESP8266 Core 2.7.4+`](https://github.com/esp8266/Arduino) for ESP8266-based boards.
|
2. [`ESP8266 Core 2.7.4+`](https://github.com/esp8266/Arduino) for ESP8266-based boards. [](https://github.com/esp8266/Arduino/releases/latest/)
|
||||||
3. [`ESP32 Core 1.0.4+`](https://github.com/espressif/arduino-esp32) for ESP32-based boards
|
3. [`ESP32 Core 1.0.4+`](https://github.com/espressif/arduino-esp32) for ESP32-based boards. [Latest stable release 
|
||||||
4. [`Arduino Core for STM32 1.9.0+`](https://github.com/stm32duino/Arduino_Core_STM32) for for STM32 using built-in Ethernet LAN8742A.
|
4. [`Arduino Core for STM32 1.9.0+`](https://github.com/stm32duino/Arduino_Core_STM32) for for STM32 using built-in Ethernet LAN8742A. [](https://github.com/stm32duino/Arduino_Core_STM32/releases/latest)
|
||||||
5. [`ESPAsyncTCP v1.2.2+`](https://github.com/me-no-dev/ESPAsyncTCP) for ESP8266.
|
5. [`ESPAsyncTCP v1.2.2+`](https://github.com/me-no-dev/ESPAsyncTCP) for ESP8266.
|
||||||
6. [`AsyncTCP v1.1.1+`](https://github.com/me-no-dev/AsyncTCP) for ESP32.
|
6. [`AsyncTCP v1.1.1+`](https://github.com/me-no-dev/AsyncTCP) for ESP32.
|
||||||
7. [`STM32Ethernet library v1.2.0+`](https://github.com/stm32duino/STM32Ethernet) for STM32 using built-in Ethernet LAN8742A on (Nucleo-144, Discovery).
|
7. [`STM32Ethernet library v1.2.0+`](https://github.com/stm32duino/STM32Ethernet) for STM32 using built-in Ethernet LAN8742A on (Nucleo-144, Discovery). [](https://github.com/stm32duino/STM32Ethernet/releases/latest)
|
||||||
8. [`LwIP library v2.1.2+`](https://github.com/stm32duino/LwIP) for STM32 using built-in Ethernet LAN8742A on (Nucleo-144, Discovery).
|
8. [`LwIP library v2.1.2+`](https://github.com/stm32duino/LwIP) for STM32 using built-in Ethernet LAN8742A on (Nucleo-144, Discovery). [](https://github.com/stm32duino/LwIP/releases/latest)
|
||||||
9. [`STM32AsyncTCP library`](https://github.com/philbowles/STM32AsyncTCP) for STM32 using built-in Ethernet LAN8742A on (Nucleo-144, Discovery).
|
9. [`STM32AsyncTCP library`](https://github.com/philbowles/STM32AsyncTCP) for STM32 using built-in Ethernet LAN8742A on (Nucleo-144, Discovery).
|
||||||
|
|
||||||
---
|
---
|
||||||
@ -190,7 +206,9 @@ The best and easiest way is to use `Arduino Library Manager`. Search for `AsyncH
|
|||||||
|
|
||||||
### Packages' Patches
|
### Packages' Patches
|
||||||
|
|
||||||
1. ***To be able to compile, run and automatically detect and display BOARD_NAME on nRF52840/nRF52832 boards***, you have to copy the whole [nRF52 0.21.0](Packages_Patches/adafruit/hardware/nrf52/0.21.0) directory into Adafruit nRF52 directory (~/.arduino15/packages/adafruit/hardware/nrf52/0.21.0).
|
#### 1. For Adafruit nRF52840 and nRF52832 boards
|
||||||
|
|
||||||
|
**To be able to compile, run and automatically detect and display BOARD_NAME on nRF52840/nRF52832 boards**, you have to copy the whole [nRF52 0.21.0](Packages_Patches/adafruit/hardware/nrf52/0.21.0) directory into Adafruit nRF52 directory (~/.arduino15/packages/adafruit/hardware/nrf52/0.21.0).
|
||||||
|
|
||||||
Supposing the Adafruit nRF52 version is 0.21.0. These files must be copied into the directory:
|
Supposing the Adafruit nRF52 version is 0.21.0. These files must be copied into the directory:
|
||||||
- `~/.arduino15/packages/adafruit/hardware/nrf52/0.21.0/platform.txt`
|
- `~/.arduino15/packages/adafruit/hardware/nrf52/0.21.0/platform.txt`
|
||||||
@ -199,7 +217,7 @@ Supposing the Adafruit nRF52 version is 0.21.0. These files must be copied into
|
|||||||
- `~/.arduino15/packages/adafruit/hardware/nrf52/0.21.0/variants/NINA_B302_ublox/variant.cpp`
|
- `~/.arduino15/packages/adafruit/hardware/nrf52/0.21.0/variants/NINA_B302_ublox/variant.cpp`
|
||||||
- `~/.arduino15/packages/adafruit/hardware/nrf52/0.21.0/variants/NINA_B112_ublox/variant.h`
|
- `~/.arduino15/packages/adafruit/hardware/nrf52/0.21.0/variants/NINA_B112_ublox/variant.h`
|
||||||
- `~/.arduino15/packages/adafruit/hardware/nrf52/0.21.0/variants/NINA_B112_ublox/variant.cpp`
|
- `~/.arduino15/packages/adafruit/hardware/nrf52/0.21.0/variants/NINA_B112_ublox/variant.cpp`
|
||||||
- ***`~/.arduino15/packages/adafruit/hardware/nrf52/0.21.0/cores/nRF5/Udp.h`***
|
- **`~/.arduino15/packages/adafruit/hardware/nrf52/0.21.0/cores/nRF5/Udp.h`**
|
||||||
|
|
||||||
Whenever a new version is installed, remember to copy these files into the new version directory. For example, new version is x.yy.z
|
Whenever a new version is installed, remember to copy these files into the new version directory. For example, new version is x.yy.z
|
||||||
These files must be copied into the directory:
|
These files must be copied into the directory:
|
||||||
@ -210,20 +228,30 @@ These files must be copied into the directory:
|
|||||||
- `~/.arduino15/packages/adafruit/hardware/nrf52/x.yy.z/variants/NINA_B302_ublox/variant.cpp`
|
- `~/.arduino15/packages/adafruit/hardware/nrf52/x.yy.z/variants/NINA_B302_ublox/variant.cpp`
|
||||||
- `~/.arduino15/packages/adafruit/hardware/nrf52/x.yy.z/variants/NINA_B112_ublox/variant.h`
|
- `~/.arduino15/packages/adafruit/hardware/nrf52/x.yy.z/variants/NINA_B112_ublox/variant.h`
|
||||||
- `~/.arduino15/packages/adafruit/hardware/nrf52/x.yy.z/variants/NINA_B112_ublox/variant.cpp`
|
- `~/.arduino15/packages/adafruit/hardware/nrf52/x.yy.z/variants/NINA_B112_ublox/variant.cpp`
|
||||||
- ***`~/.arduino15/packages/adafruit/hardware/nrf52/x.yy.z/cores/nRF5/Udp.h`***
|
- **`~/.arduino15/packages/adafruit/hardware/nrf52/x.yy.z/cores/nRF5/Udp.h`**
|
||||||
|
|
||||||
2. ***To be able to compile and run on Teensy boards***, you have to copy the file [Teensy boards.txt](Packages_Patches/hardware/teensy/avr/boards.txt) into Teensy hardware directory (./arduino-1.8.12/hardware/teensy/avr/boards.txt).
|
#### 2. For Teensy boards
|
||||||
|
|
||||||
|
**To be able to compile and run on Teensy boards**, you have to copy the files in [**Packages_Patches for Teensy directory**](Packages_Patches/hardware/teensy/avr) into Teensy hardware directory (./arduino-1.8.13/hardware/teensy/avr/boards.txt).
|
||||||
|
|
||||||
Supposing the Arduino version is 1.8.12. This file must be copied into the directory:
|
Supposing the Arduino version is 1.8.13. These files must be copied into the directory:
|
||||||
|
|
||||||
- `./arduino-1.8.12/hardware/teensy/avr/boards.txt`
|
- `./arduino-1.8.13/hardware/teensy/avr/boards.txt`
|
||||||
|
- `./arduino-1.8.13/hardware/teensy/avr/cores/teensy/Stream.h`
|
||||||
|
- `./arduino-1.8.13/hardware/teensy/avr/cores/teensy3/Stream.h`
|
||||||
|
- `./arduino-1.8.13/hardware/teensy/avr/cores/teensy4/Stream.h`
|
||||||
|
|
||||||
Whenever a new version is installed, remember to copy this file into the new version directory. For example, new version is x.yy.zz
|
Whenever a new version is installed, remember to copy this file into the new version directory. For example, new version is x.yy.zz
|
||||||
This file must be copied into the directory:
|
These files must be copied into the directory:
|
||||||
|
|
||||||
- `./arduino-x.yy.zz/hardware/teensy/avr/boards.txt`
|
- `./arduino-x.yy.zz/hardware/teensy/avr/boards.txt`
|
||||||
|
- `./arduino-x.yy.zz/hardware/teensy/avr/cores/teensy/Stream.h`
|
||||||
|
- `./arduino-x.yy.zz/hardware/teensy/avr/cores/teensy3/Stream.h`
|
||||||
|
- `./arduino-x.yy.zz/hardware/teensy/avr/cores/teensy4/Stream.h`
|
||||||
|
|
||||||
3. ***To be able to compile and run on SAM DUE boards***, you have to copy the whole [SAM DUE](Packages_Patches/arduino/hardware/sam/1.6.12) directory into Arduino sam directory (~/.arduino15/packages/arduino/hardware/sam/1.6.12).
|
#### 3. For Arduino SAM DUE boards
|
||||||
|
|
||||||
|
**To be able to compile and run on SAM DUE boards**, you have to copy the whole [SAM DUE](Packages_Patches/arduino/hardware/sam/1.6.12) directory into Arduino sam directory (~/.arduino15/packages/arduino/hardware/sam/1.6.12).
|
||||||
|
|
||||||
Supposing the Arduino SAM core version is 1.6.12. This file must be copied into the directory:
|
Supposing the Arduino SAM core version is 1.6.12. This file must be copied into the directory:
|
||||||
|
|
||||||
@ -234,13 +262,15 @@ This file must be copied into the directory:
|
|||||||
|
|
||||||
- `~/.arduino15/packages/arduino/hardware/sam/x.yy.zz/platform.txt`
|
- `~/.arduino15/packages/arduino/hardware/sam/x.yy.zz/platform.txt`
|
||||||
|
|
||||||
4. ***To be able to compile without error and automatically detect and display BOARD_NAME on Arduino SAMD (Nano-33-IoT, etc) boards***, you have to copy the whole [Arduino SAMD cores 1.8.10](Packages_Patches/arduino/hardware/samd/1.8.10) directory into Arduino SAMD directory (~/.arduino15/packages/arduino/hardware/samd/1.8.10).
|
#### 4. For Arduino SAMD boards
|
||||||
|
|
||||||
|
***To be able to compile without error and automatically detect and display BOARD_NAME on Arduino SAMD (Nano-33-IoT, etc) boards***, you have to copy the whole [Arduino SAMD cores 1.8.10](Packages_Patches/arduino/hardware/samd/1.8.10) directory into Arduino SAMD directory (~/.arduino15/packages/arduino/hardware/samd/1.8.10).
|
||||||
|
|
||||||
#### For core version v1.8.10+
|
#### For core version v1.8.10+
|
||||||
|
|
||||||
Supposing the Arduino SAMD version is 1.8.10. Now only one file must be copied into the directory:
|
Supposing the Arduino SAMD version is 1.8.11. Now only one file must be copied into the directory:
|
||||||
|
|
||||||
- `~/.arduino15/packages/arduino/hardware/samd/1.8.10/platform.txt`
|
- `~/.arduino15/packages/arduino/hardware/samd/1.8.11/platform.txt`
|
||||||
|
|
||||||
Whenever a new version is installed, remember to copy this files into the new version directory. For example, new version is x.yy.zz
|
Whenever a new version is installed, remember to copy this files into the new version directory. For example, new version is x.yy.zz
|
||||||
|
|
||||||
@ -271,7 +301,9 @@ These files must be copied into the directory:
|
|||||||
|
|
||||||
Whenever the above-mentioned compiler error issue is fixed with the new Arduino SAMD release, you don't need to copy the `Arduino.h` file anymore.
|
Whenever the above-mentioned compiler error issue is fixed with the new Arduino SAMD release, you don't need to copy the `Arduino.h` file anymore.
|
||||||
|
|
||||||
5. ***To be able to automatically detect and display BOARD_NAME on Adafruit SAMD (Itsy-Bitsy M4, etc) boards***, you have to copy the file [Adafruit SAMD platform.txt](Packages_Patches/adafruit/hardware/samd/1.6.4) into Adafruit samd directory (~/.arduino15/packages/adafruit/hardware/samd/1.6.4).
|
#### 5. For Adafruit SAMD boards
|
||||||
|
|
||||||
|
***To be able to automatically detect and display BOARD_NAME on Adafruit SAMD (Itsy-Bitsy M4, etc) boards***, you have to copy the file [Adafruit SAMD platform.txt](Packages_Patches/adafruit/hardware/samd/1.6.4) into Adafruit samd directory (~/.arduino15/packages/adafruit/hardware/samd/1.6.4).
|
||||||
|
|
||||||
Supposing the Adafruit SAMD core version is 1.6.4. This file must be copied into the directory:
|
Supposing the Adafruit SAMD core version is 1.6.4. This file must be copied into the directory:
|
||||||
|
|
||||||
@ -282,7 +314,9 @@ This file must be copied into the directory:
|
|||||||
|
|
||||||
- `~/.arduino15/packages/adafruit/hardware/samd/x.yy.zz/platform.txt`
|
- `~/.arduino15/packages/adafruit/hardware/samd/x.yy.zz/platform.txt`
|
||||||
|
|
||||||
6. ***To be able to automatically detect and display BOARD_NAME on Seeeduino SAMD (XIAO M0, Wio Terminal, etc) boards***, you have to copy the file [Seeeduino SAMD platform.txt](Packages_Patches/Seeeduino/hardware/samd/1.8.1) into Adafruit samd directory (~/.arduino15/packages/Seeeduino/hardware/samd/1.8.1).
|
#### 6. For Seeeduino SAMD boards
|
||||||
|
|
||||||
|
***To be able to automatically detect and display BOARD_NAME on Seeeduino SAMD (XIAO M0, Wio Terminal, etc) boards***, you have to copy the file [Seeeduino SAMD platform.txt](Packages_Patches/Seeeduino/hardware/samd/1.8.1) into Adafruit samd directory (~/.arduino15/packages/Seeeduino/hardware/samd/1.8.1).
|
||||||
|
|
||||||
Supposing the Seeeduino SAMD core version is 1.8.1. This file must be copied into the directory:
|
Supposing the Seeeduino SAMD core version is 1.8.1. This file must be copied into the directory:
|
||||||
|
|
||||||
@ -293,7 +327,9 @@ This file must be copied into the directory:
|
|||||||
|
|
||||||
- `~/.arduino15/packages/Seeeduino/hardware/samd/x.yy.zz/platform.txt`
|
- `~/.arduino15/packages/Seeeduino/hardware/samd/x.yy.zz/platform.txt`
|
||||||
|
|
||||||
7. ***To use Serial1 on some STM32 boards without Serial1 definition (Nucleo-144 NUCLEO_F767ZI, Nucleo-64 NUCLEO_L053R8, etc.) boards***, you have to copy the files [STM32 variant.h](Packages_Patches/STM32/hardware/stm32/1.9.0) into STM32 stm32 directory (~/.arduino15/packages/STM32/hardware/stm32/1.9.0). You have to modify the files corresponding to your boards, this is just an illustration how to do.
|
#### 7. For STM32 boards
|
||||||
|
|
||||||
|
**To use Serial1 on some STM32 boards without Serial1 definition (Nucleo-144 NUCLEO_F767ZI, Nucleo-64 NUCLEO_L053R8, etc.) boards**, you have to copy the files [STM32 variant.h](Packages_Patches/STM32/hardware/stm32/1.9.0) into STM32 stm32 directory (~/.arduino15/packages/STM32/hardware/stm32/1.9.0). You have to modify the files corresponding to your boards, this is just an illustration how to do.
|
||||||
|
|
||||||
Supposing the STM32 stm32 core version is 1.9.0. These files must be copied into the directory:
|
Supposing the STM32 stm32 core version is 1.9.0. These files must be copied into the directory:
|
||||||
|
|
||||||
@ -322,6 +358,29 @@ To use the old standard cpp way, just
|
|||||||
---
|
---
|
||||||
---
|
---
|
||||||
|
|
||||||
|
### Note for Platform IO using ESP32 LittleFS
|
||||||
|
|
||||||
|
In Platform IO, to fix the error when using [`LittleFS_esp32 v1.0`](https://github.com/lorol/LITTLEFS) for ESP32-based boards with ESP32 core v1.0.4- (ESP-IDF v3.2-), uncomment the following line
|
||||||
|
|
||||||
|
from
|
||||||
|
|
||||||
|
```
|
||||||
|
//#define CONFIG_LITTLEFS_FOR_IDF_3_2 /* For old IDF - like in release 1.0.4 */
|
||||||
|
```
|
||||||
|
|
||||||
|
to
|
||||||
|
|
||||||
|
```
|
||||||
|
#define CONFIG_LITTLEFS_FOR_IDF_3_2 /* For old IDF - like in release 1.0.4 */
|
||||||
|
```
|
||||||
|
|
||||||
|
It's advisable to use the latest [`LittleFS_esp32 v1.0.5+`](https://github.com/lorol/LITTLEFS) to avoid the issue.
|
||||||
|
|
||||||
|
Thanks to [Roshan](https://github.com/solroshan) to report the issue in [Error esp_littlefs.c 'utime_p'](https://github.com/khoih-prog/ESPAsync_WiFiManager/issues/28)
|
||||||
|
|
||||||
|
---
|
||||||
|
---
|
||||||
|
|
||||||
### HOWTO Use analogRead() with ESP32 running WiFi and/or BlueTooth (BT/BLE)
|
### HOWTO Use analogRead() with ESP32 running WiFi and/or BlueTooth (BT/BLE)
|
||||||
|
|
||||||
Please have a look at [**ESP_WiFiManager Issue 39: Not able to read analog port when using the autoconnect example**](https://github.com/khoih-prog/ESP_WiFiManager/issues/39) to have more detailed description and solution of the issue.
|
Please have a look at [**ESP_WiFiManager Issue 39: Not able to read analog port when using the autoconnect example**](https://github.com/khoih-prog/ESP_WiFiManager/issues/39) to have more detailed description and solution of the issue.
|
||||||
@ -385,11 +444,11 @@ Please take a look at other examples, as well.
|
|||||||
#include "defines.h"
|
#include "defines.h"
|
||||||
|
|
||||||
// 600s = 10 minutes to not flooding, 10s in testing
|
// 600s = 10 minutes to not flooding, 10s in testing
|
||||||
#define HTTP_REQUEST_INTERVAL_MS 10000 // 600000
|
#define HTTP_REQUEST_INTERVAL_MS 10000 //600000
|
||||||
|
|
||||||
#include <AsyncHTTPRequest_Generic.h> // https://github.com/khoih-prog/AsyncHTTPRequest_Generic
|
#include <AsyncHTTPRequest_Generic.h> // https://github.com/khoih-prog/AsyncHTTPRequest_Generic
|
||||||
|
|
||||||
#include <Ticker.h> // https://github.com/sstaub/Ticker
|
#include <Ticker.h> // https://github.com/sstaub/Ticker
|
||||||
|
|
||||||
AsyncHTTPRequest request;
|
AsyncHTTPRequest request;
|
||||||
|
|
||||||
@ -425,6 +484,8 @@ void sendRequest(void)
|
|||||||
|
|
||||||
void requestCB(void* optParm, AsyncHTTPRequest* request, int readyState)
|
void requestCB(void* optParm, AsyncHTTPRequest* request, int readyState)
|
||||||
{
|
{
|
||||||
|
(void) optParm;
|
||||||
|
|
||||||
if (readyState == readyStateDone)
|
if (readyState == readyStateDone)
|
||||||
{
|
{
|
||||||
Serial.println("\n**************************************");
|
Serial.println("\n**************************************");
|
||||||
@ -441,6 +502,7 @@ void setup(void)
|
|||||||
while (!Serial);
|
while (!Serial);
|
||||||
|
|
||||||
Serial.println("\nStart AsyncHTTPRequest_STM32 on " + String(BOARD_NAME));
|
Serial.println("\nStart AsyncHTTPRequest_STM32 on " + String(BOARD_NAME));
|
||||||
|
Serial.println(ASYNC_HTTP_REQUEST_GENERIC_VERSION);
|
||||||
|
|
||||||
// start the ethernet connection and the server
|
// start the ethernet connection and the server
|
||||||
// Use random mac
|
// Use random mac
|
||||||
@ -469,7 +531,6 @@ void loop(void)
|
|||||||
{
|
{
|
||||||
sendHTTPRequest.update();
|
sendHTTPRequest.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
@ -478,17 +539,6 @@ void loop(void)
|
|||||||
|
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
/*
|
|
||||||
Currently support
|
|
||||||
1) STM32 boards with built-in Ethernet (to use USE_BUILTIN_ETHERNET = true) such as :
|
|
||||||
- Nucleo-144 (F429ZI, F767ZI)
|
|
||||||
- Discovery (STM32F746G-DISCOVERY)
|
|
||||||
- STM32 boards (STM32F/L/H/G/WB/MP1) with 32K+ Flash, with Built-in Ethernet,
|
|
||||||
- See How To Use Built-in Ethernet at (https://github.com/khoih-prog/EthernetWebServer_STM32/issues/1)
|
|
||||||
2) STM32F/L/H/G/WB/MP1 boards (with 32+K Flash) running ENC28J60 shields (to use USE_BUILTIN_ETHERNET = false)
|
|
||||||
3) STM32F/L/H/G/WB/MP1 boards (with 32+K Flash) running W5x00 shields
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef defines_h
|
#ifndef defines_h
|
||||||
#define defines_h
|
#define defines_h
|
||||||
|
|
||||||
@ -602,7 +652,7 @@ IPAddress ip(192, 168, 2, 232);
|
|||||||
|
|
||||||
```
|
```
|
||||||
Start AsyncHTTPRequest_STM32 on NUCLEO_F767ZI
|
Start AsyncHTTPRequest_STM32 on NUCLEO_F767ZI
|
||||||
AsyncHTTPRequest_Generic v1.1.1
|
AsyncHTTPRequest_Generic v1.1.2
|
||||||
AsyncHTTPRequest @ IP : 192.168.2.72
|
AsyncHTTPRequest @ IP : 192.168.2.72
|
||||||
|
|
||||||
**************************************
|
**************************************
|
||||||
@ -647,7 +697,7 @@ week_number: 37
|
|||||||
|
|
||||||
```
|
```
|
||||||
Starting AsyncHTTPRequest_ESP_WiFiManager using LittleFS on ESP8266_NODEMCU
|
Starting AsyncHTTPRequest_ESP_WiFiManager using LittleFS on ESP8266_NODEMCU
|
||||||
AsyncHTTPRequest_Generic v1.1.1
|
AsyncHTTPRequest_Generic v1.1.2
|
||||||
Stored: SSID = HueNet1, Pass = 12345678
|
Stored: SSID = HueNet1, Pass = 12345678
|
||||||
Got stored Credentials. Timeout 120s
|
Got stored Credentials. Timeout 120s
|
||||||
ConnectMultiWiFi in setup
|
ConnectMultiWiFi in setup
|
||||||
@ -680,7 +730,7 @@ HHHHHH
|
|||||||
|
|
||||||
```
|
```
|
||||||
Starting AsyncHTTPRequest_ESP_WiFiManager using SPIFFS on ESP32_DEV
|
Starting AsyncHTTPRequest_ESP_WiFiManager using SPIFFS on ESP32_DEV
|
||||||
AsyncHTTPRequest_Generic v1.1.1
|
AsyncHTTPRequest_Generic v1.1.2
|
||||||
Stored: SSID = HueNet1, Pass = 12345678
|
Stored: SSID = HueNet1, Pass = 12345678
|
||||||
Got stored Credentials. Timeout 120s
|
Got stored Credentials. Timeout 120s
|
||||||
ConnectMultiWiFi in setup
|
ConnectMultiWiFi in setup
|
||||||
@ -731,7 +781,7 @@ HHHHHHHHH HHHHHHHHHH HHHHHHHHHH
|
|||||||
|
|
||||||
```
|
```
|
||||||
Starting AsyncHTTPRequest_ESP using ESP8266_NODEMCU
|
Starting AsyncHTTPRequest_ESP using ESP8266_NODEMCU
|
||||||
AsyncHTTPRequest_Generic v1.1.1
|
AsyncHTTPRequest_Generic v1.1.2
|
||||||
Connecting to WiFi SSID: HueNet1
|
Connecting to WiFi SSID: HueNet1
|
||||||
...........
|
...........
|
||||||
HTTP WebServer is @ IP : 192.168.2.81
|
HTTP WebServer is @ IP : 192.168.2.81
|
||||||
@ -763,7 +813,7 @@ HHHHHHHHH HHHHHHHHHH HHHHHHHHHH H
|
|||||||
|
|
||||||
```
|
```
|
||||||
Start AsyncWebClientRepeating_STM32 on NUCLEO_F767ZI
|
Start AsyncWebClientRepeating_STM32 on NUCLEO_F767ZI
|
||||||
AsyncHTTPRequest_Generic v1.1.1
|
AsyncHTTPRequest_Generic v1.1.2
|
||||||
AsyncHTTPRequest @ IP : 192.168.2.72
|
AsyncHTTPRequest @ IP : 192.168.2.72
|
||||||
|
|
||||||
**************************************
|
**************************************
|
||||||
@ -862,6 +912,11 @@ Submit issues to: [AsyncHTTPRequest_Generic issues](https://github.com/khoih-pro
|
|||||||
|
|
||||||
## Releases
|
## Releases
|
||||||
|
|
||||||
|
### Releases v1.1.2
|
||||||
|
|
||||||
|
1. Rename _lock and _unlock to avoid conflict with [**ESP32/ESP8266 AsyncWebServer**](https://github.com/me-no-dev/ESPAsyncWebServer) library. Check [**compatibility with ESPAsyncWebServer #11**](https://github.com/khoih-prog/AsyncHTTPRequest_Generic/issues/11)
|
||||||
|
2. Fix compiler warnings.
|
||||||
|
|
||||||
### Releases v1.1.1
|
### Releases v1.1.1
|
||||||
|
|
||||||
1. Prevent crash if request and/or method not correct.
|
1. Prevent crash if request and/or method not correct.
|
||||||
@ -896,11 +951,14 @@ This library is based on, modified, bug-fixed and improved from:
|
|||||||
|
|
||||||
3. Thanks to [gleniat](https://github.com/gleniat) to make enhancement request in[Add support for sending PUT, PATCH, DELETE request](https://github.com/khoih-prog/AsyncHTTPRequest_Generic/issues/5) leading to v1.1.0.
|
3. Thanks to [gleniat](https://github.com/gleniat) to make enhancement request in[Add support for sending PUT, PATCH, DELETE request](https://github.com/khoih-prog/AsyncHTTPRequest_Generic/issues/5) leading to v1.1.0.
|
||||||
|
|
||||||
|
4. Thanks to [BadDwarf](https://github.com/baddwarf) to report [**compatibility with ESPAsyncWebServer #11**](https://github.com/khoih-prog/AsyncHTTPRequest_Generic/issues/11) leading to the enhancement in v1.1.2.
|
||||||
|
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<td align="center"><a href="https://github.com/boblemaire"><img src="https://github.com/boblemaire.png" width="100px;" alt="boblemaire"/><br /><sub><b>⭐️ Bob Lemaire</b></sub></a><br /></td>
|
<td align="center"><a href="https://github.com/boblemaire"><img src="https://github.com/boblemaire.png" width="100px;" alt="boblemaire"/><br /><sub><b>⭐️ Bob Lemaire</b></sub></a><br /></td>
|
||||||
<td align="center"><a href="https://github.com/0xFEEDC0DE64"><img src="https://github.com/0xFEEDC0DE64.png" width="100px;" alt="0xFEEDC0DE64"/><br /><sub><b>Daniel Brunner</b></sub></a><br /></td>
|
<td align="center"><a href="https://github.com/0xFEEDC0DE64"><img src="https://github.com/0xFEEDC0DE64.png" width="100px;" alt="0xFEEDC0DE64"/><br /><sub><b>Daniel Brunner</b></sub></a><br /></td>
|
||||||
<td align="center"><a href="https://github.com/gleniat"><img src="https://github.com/gleniat.png" width="100px;" alt="gleniat"/><br /><sub><b>gleniat</b></sub></a><br /></td>
|
<td align="center"><a href="https://github.com/gleniat"><img src="https://github.com/gleniat.png" width="100px;" alt="gleniat"/><br /><sub><b>gleniat</b></sub></a><br /></td>
|
||||||
|
<td align="center"><a href="https://github.com/baddwarf"><img src="https://github.com/baddwarf.png" width="100px;" alt="baddwarf"/><br /><sub><b>BadDwarf</b></sub></a><br /></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
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.1.1
|
Version: 1.1.2
|
||||||
|
|
||||||
Version Modified By Date Comments
|
Version Modified By Date Comments
|
||||||
------- ----------- ---------- -----------
|
------- ----------- ---------- -----------
|
||||||
@ -26,6 +26,7 @@
|
|||||||
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
|
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
|
||||||
1.1.0 K Hoang 23/12/2020 Add HTTP PUT, PATCH, DELETE and HEAD methods
|
1.1.0 K Hoang 23/12/2020 Add HTTP PUT, PATCH, DELETE and HEAD methods
|
||||||
1.1.1 K Hoang 24/12/2020 Prevent crash if request and/or method not correct.
|
1.1.1 K Hoang 24/12/2020 Prevent crash if request and/or method not correct.
|
||||||
|
1.1.2 K Hoang 11/02/2021 Rename _lock and _unlock to avoid conflict with AsyncWebServer library
|
||||||
*****************************************************************************************************************************/
|
*****************************************************************************************************************************/
|
||||||
|
|
||||||
#include "defines.h"
|
#include "defines.h"
|
||||||
@ -76,6 +77,8 @@ void sendRequest(void)
|
|||||||
|
|
||||||
void requestCB(void* optParm, AsyncHTTPRequest* request, int readyState)
|
void requestCB(void* optParm, AsyncHTTPRequest* request, int readyState)
|
||||||
{
|
{
|
||||||
|
(void) optParm;
|
||||||
|
|
||||||
if (readyState == readyStateDone)
|
if (readyState == readyStateDone)
|
||||||
{
|
{
|
||||||
Serial.println("\n**************************************");
|
Serial.println("\n**************************************");
|
||||||
|
@ -19,13 +19,16 @@
|
|||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
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.0.2
|
Version: 1.1.2
|
||||||
|
|
||||||
Version Modified By Date Comments
|
Version Modified By Date Comments
|
||||||
------- ----------- ---------- -----------
|
------- ----------- ---------- -----------
|
||||||
1.0.0 K Hoang 14/09/2020 Initial coding to add support to STM32 using built-in Ethernet (Nucleo-144, DISCOVERY, etc).
|
1.0.0 K Hoang 14/09/2020 Initial coding to add support to STM32 using built-in Ethernet (Nucleo-144, DISCOVERY, etc).
|
||||||
1.0.1 K Hoang 09/10/2020 Restore cpp code besides Impl.h code.
|
1.0.1 K Hoang 09/10/2020 Restore cpp code besides Impl.h code.
|
||||||
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
|
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
|
||||||
|
1.1.0 K Hoang 23/12/2020 Add HTTP PUT, PATCH, DELETE and HEAD methods
|
||||||
|
1.1.1 K Hoang 24/12/2020 Prevent crash if request and/or method not correct.
|
||||||
|
1.1.2 K Hoang 11/02/2021 Rename _lock and _unlock to avoid conflict with AsyncWebServer library
|
||||||
*****************************************************************************************************************************/
|
*****************************************************************************************************************************/
|
||||||
/*
|
/*
|
||||||
Currently support
|
Currently support
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
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.1.1
|
Version: 1.1.2
|
||||||
|
|
||||||
Version Modified By Date Comments
|
Version Modified By Date Comments
|
||||||
------- ----------- ---------- -----------
|
------- ----------- ---------- -----------
|
||||||
@ -26,6 +26,7 @@
|
|||||||
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
|
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
|
||||||
1.1.0 K Hoang 23/12/2020 Add HTTP PUT, PATCH, DELETE and HEAD methods
|
1.1.0 K Hoang 23/12/2020 Add HTTP PUT, PATCH, DELETE and HEAD methods
|
||||||
1.1.1 K Hoang 24/12/2020 Prevent crash if request and/or method not correct.
|
1.1.1 K Hoang 24/12/2020 Prevent crash if request and/or method not correct.
|
||||||
|
1.1.2 K Hoang 11/02/2021 Rename _lock and _unlock to avoid conflict with AsyncWebServer library
|
||||||
*****************************************************************************************************************************/
|
*****************************************************************************************************************************/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -119,6 +120,8 @@ void parseResponse(String responseText)
|
|||||||
|
|
||||||
void requestCB(void* optParm, AsyncHTTPRequest* request, int readyState)
|
void requestCB(void* optParm, AsyncHTTPRequest* request, int readyState)
|
||||||
{
|
{
|
||||||
|
(void) optParm;
|
||||||
|
|
||||||
if (readyState == readyStateDone)
|
if (readyState == readyStateDone)
|
||||||
{
|
{
|
||||||
String responseText = request->responseText();
|
String responseText = request->responseText();
|
||||||
|
@ -19,13 +19,16 @@
|
|||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
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.0.2
|
Version: 1.1.2
|
||||||
|
|
||||||
Version Modified By Date Comments
|
Version Modified By Date Comments
|
||||||
------- ----------- ---------- -----------
|
------- ----------- ---------- -----------
|
||||||
1.0.0 K Hoang 14/09/2020 Initial coding to add support to STM32 using built-in Ethernet (Nucleo-144, DISCOVERY, etc).
|
1.0.0 K Hoang 14/09/2020 Initial coding to add support to STM32 using built-in Ethernet (Nucleo-144, DISCOVERY, etc).
|
||||||
1.0.1 K Hoang 09/10/2020 Restore cpp code besides Impl.h code.
|
1.0.1 K Hoang 09/10/2020 Restore cpp code besides Impl.h code.
|
||||||
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
|
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
|
||||||
|
1.1.0 K Hoang 23/12/2020 Add HTTP PUT, PATCH, DELETE and HEAD methods
|
||||||
|
1.1.1 K Hoang 24/12/2020 Prevent crash if request and/or method not correct.
|
||||||
|
1.1.2 K Hoang 11/02/2021 Rename _lock and _unlock to avoid conflict with AsyncWebServer library
|
||||||
*****************************************************************************************************************************/
|
*****************************************************************************************************************************/
|
||||||
/*
|
/*
|
||||||
Currently support
|
Currently support
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
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.1.1
|
Version: 1.1.2
|
||||||
|
|
||||||
Version Modified By Date Comments
|
Version Modified By Date Comments
|
||||||
------- ----------- ---------- -----------
|
------- ----------- ---------- -----------
|
||||||
@ -26,6 +26,7 @@
|
|||||||
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
|
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
|
||||||
1.1.0 K Hoang 23/12/2020 Add HTTP PUT, PATCH, DELETE and HEAD methods
|
1.1.0 K Hoang 23/12/2020 Add HTTP PUT, PATCH, DELETE and HEAD methods
|
||||||
1.1.1 K Hoang 24/12/2020 Prevent crash if request and/or method not correct.
|
1.1.1 K Hoang 24/12/2020 Prevent crash if request and/or method not correct.
|
||||||
|
1.1.2 K Hoang 11/02/2021 Rename _lock and _unlock to avoid conflict with AsyncWebServer library
|
||||||
*****************************************************************************************************************************/
|
*****************************************************************************************************************************/
|
||||||
|
|
||||||
// Dweet.io POST client. Connects to dweet.io once every ten seconds, sends a POST request and a request body.
|
// Dweet.io POST client. Connects to dweet.io once every ten seconds, sends a POST request and a request body.
|
||||||
@ -118,6 +119,8 @@ void parseResponse(String responseText)
|
|||||||
|
|
||||||
void requestCB(void* optParm, AsyncHTTPRequest* request, int readyState)
|
void requestCB(void* optParm, AsyncHTTPRequest* request, int readyState)
|
||||||
{
|
{
|
||||||
|
(void) optParm;
|
||||||
|
|
||||||
if (readyState == readyStateDone)
|
if (readyState == readyStateDone)
|
||||||
{
|
{
|
||||||
String responseText = request->responseText();
|
String responseText = request->responseText();
|
||||||
|
@ -19,13 +19,16 @@
|
|||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
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.0.2
|
Version: 1.1.2
|
||||||
|
|
||||||
Version Modified By Date Comments
|
Version Modified By Date Comments
|
||||||
------- ----------- ---------- -----------
|
------- ----------- ---------- -----------
|
||||||
1.0.0 K Hoang 14/09/2020 Initial coding to add support to STM32 using built-in Ethernet (Nucleo-144, DISCOVERY, etc).
|
1.0.0 K Hoang 14/09/2020 Initial coding to add support to STM32 using built-in Ethernet (Nucleo-144, DISCOVERY, etc).
|
||||||
1.0.1 K Hoang 09/10/2020 Restore cpp code besides Impl.h code.
|
1.0.1 K Hoang 09/10/2020 Restore cpp code besides Impl.h code.
|
||||||
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
|
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
|
||||||
|
1.1.0 K Hoang 23/12/2020 Add HTTP PUT, PATCH, DELETE and HEAD methods
|
||||||
|
1.1.1 K Hoang 24/12/2020 Prevent crash if request and/or method not correct.
|
||||||
|
1.1.2 K Hoang 11/02/2021 Rename _lock and _unlock to avoid conflict with AsyncWebServer library
|
||||||
*****************************************************************************************************************************/
|
*****************************************************************************************************************************/
|
||||||
/*
|
/*
|
||||||
Currently support
|
Currently support
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
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.1.1
|
Version: 1.1.2
|
||||||
|
|
||||||
Version Modified By Date Comments
|
Version Modified By Date Comments
|
||||||
------- ----------- ---------- -----------
|
------- ----------- ---------- -----------
|
||||||
@ -26,6 +26,7 @@
|
|||||||
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
|
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
|
||||||
1.1.0 K Hoang 23/12/2020 Add HTTP PUT, PATCH, DELETE and HEAD methods
|
1.1.0 K Hoang 23/12/2020 Add HTTP PUT, PATCH, DELETE and HEAD methods
|
||||||
1.1.1 K Hoang 24/12/2020 Prevent crash if request and/or method not correct.
|
1.1.1 K Hoang 24/12/2020 Prevent crash if request and/or method not correct.
|
||||||
|
1.1.2 K Hoang 11/02/2021 Rename _lock and _unlock to avoid conflict with AsyncWebServer library
|
||||||
*****************************************************************************************************************************/
|
*****************************************************************************************************************************/
|
||||||
//************************************************************************************************************
|
//************************************************************************************************************
|
||||||
//
|
//
|
||||||
@ -56,7 +57,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_ 4
|
#define _ASYNC_HTTP_LOGLEVEL_ 1
|
||||||
|
|
||||||
// 300s = 5 minutes to not flooding
|
// 300s = 5 minutes to not flooding
|
||||||
#define HTTP_REQUEST_INTERVAL 30 //300
|
#define HTTP_REQUEST_INTERVAL 30 //300
|
||||||
@ -149,6 +150,8 @@ void sendRequest()
|
|||||||
|
|
||||||
void requestCB(void* optParm, AsyncHTTPRequest* request, int readyState)
|
void requestCB(void* optParm, AsyncHTTPRequest* request, int readyState)
|
||||||
{
|
{
|
||||||
|
(void) optParm;
|
||||||
|
|
||||||
if (readyState == readyStateDone)
|
if (readyState == readyStateDone)
|
||||||
{
|
{
|
||||||
Serial.print("\n***************"); Serial.print(requestName[ requestIndex ]); Serial.println("***************");
|
Serial.print("\n***************"); Serial.print(requestName[ requestIndex ]); Serial.println("***************");
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
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.1.1
|
Version: 1.1.2
|
||||||
|
|
||||||
Version Modified By Date Comments
|
Version Modified By Date Comments
|
||||||
------- ----------- ---------- -----------
|
------- ----------- ---------- -----------
|
||||||
@ -26,6 +26,7 @@
|
|||||||
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
|
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
|
||||||
1.1.0 K Hoang 23/12/2020 Add HTTP PUT, PATCH, DELETE and HEAD methods
|
1.1.0 K Hoang 23/12/2020 Add HTTP PUT, PATCH, DELETE and HEAD methods
|
||||||
1.1.1 K Hoang 24/12/2020 Prevent crash if request and/or method not correct.
|
1.1.1 K Hoang 24/12/2020 Prevent crash if request and/or method not correct.
|
||||||
|
1.1.2 K Hoang 11/02/2021 Rename _lock and _unlock to avoid conflict with AsyncWebServer library
|
||||||
*****************************************************************************************************************************/
|
*****************************************************************************************************************************/
|
||||||
//************************************************************************************************************
|
//************************************************************************************************************
|
||||||
//
|
//
|
||||||
@ -129,6 +130,8 @@ void sendRequest()
|
|||||||
|
|
||||||
void requestCB(void* optParm, AsyncHTTPRequest* request, int readyState)
|
void requestCB(void* optParm, AsyncHTTPRequest* request, int readyState)
|
||||||
{
|
{
|
||||||
|
(void) optParm;
|
||||||
|
|
||||||
if (readyState == readyStateDone)
|
if (readyState == readyStateDone)
|
||||||
{
|
{
|
||||||
Serial.println("\n**************************************");
|
Serial.println("\n**************************************");
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
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.1.1
|
Version: 1.1.2
|
||||||
|
|
||||||
Version Modified By Date Comments
|
Version Modified By Date Comments
|
||||||
------- ----------- ---------- -----------
|
------- ----------- ---------- -----------
|
||||||
@ -26,6 +26,7 @@
|
|||||||
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
|
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
|
||||||
1.1.0 K Hoang 23/12/2020 Add HTTP PUT, PATCH, DELETE and HEAD methods
|
1.1.0 K Hoang 23/12/2020 Add HTTP PUT, PATCH, DELETE and HEAD methods
|
||||||
1.1.1 K Hoang 24/12/2020 Prevent crash if request and/or method not correct.
|
1.1.1 K Hoang 24/12/2020 Prevent crash if request and/or method not correct.
|
||||||
|
1.1.2 K Hoang 11/02/2021 Rename _lock and _unlock to avoid conflict with AsyncWebServer library
|
||||||
*****************************************************************************************************************************/
|
*****************************************************************************************************************************/
|
||||||
//************************************************************************************************************
|
//************************************************************************************************************
|
||||||
//
|
//
|
||||||
@ -514,6 +515,8 @@ void sendRequest()
|
|||||||
|
|
||||||
void requestCB(void* optParm, AsyncHTTPRequest* request, int readyState)
|
void requestCB(void* optParm, AsyncHTTPRequest* request, int readyState)
|
||||||
{
|
{
|
||||||
|
(void) optParm;
|
||||||
|
|
||||||
if (readyState == readyStateDone)
|
if (readyState == readyStateDone)
|
||||||
{
|
{
|
||||||
Serial.println("\n**************************************");
|
Serial.println("\n**************************************");
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
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.1.1
|
Version: 1.1.2
|
||||||
|
|
||||||
Version Modified By Date Comments
|
Version Modified By Date Comments
|
||||||
------- ----------- ---------- -----------
|
------- ----------- ---------- -----------
|
||||||
@ -26,6 +26,7 @@
|
|||||||
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
|
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
|
||||||
1.1.0 K Hoang 23/12/2020 Add HTTP PUT, PATCH, DELETE and HEAD methods
|
1.1.0 K Hoang 23/12/2020 Add HTTP PUT, PATCH, DELETE and HEAD methods
|
||||||
1.1.1 K Hoang 24/12/2020 Prevent crash if request and/or method not correct.
|
1.1.1 K Hoang 24/12/2020 Prevent crash if request and/or method not correct.
|
||||||
|
1.1.2 K Hoang 11/02/2021 Rename _lock and _unlock to avoid conflict with AsyncWebServer library
|
||||||
*****************************************************************************************************************************/
|
*****************************************************************************************************************************/
|
||||||
//************************************************************************************************************
|
//************************************************************************************************************
|
||||||
//
|
//
|
||||||
@ -93,6 +94,8 @@ void sendRequest(void)
|
|||||||
|
|
||||||
void requestCB(void* optParm, AsyncHTTPRequest* request, int readyState)
|
void requestCB(void* optParm, AsyncHTTPRequest* request, int readyState)
|
||||||
{
|
{
|
||||||
|
(void) optParm;
|
||||||
|
|
||||||
if (readyState == readyStateDone)
|
if (readyState == readyStateDone)
|
||||||
{
|
{
|
||||||
Serial.println("\n**************************************");
|
Serial.println("\n**************************************");
|
||||||
|
@ -19,13 +19,16 @@
|
|||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
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.0.2
|
Version: 1.1.2
|
||||||
|
|
||||||
Version Modified By Date Comments
|
Version Modified By Date Comments
|
||||||
------- ----------- ---------- -----------
|
------- ----------- ---------- -----------
|
||||||
1.0.0 K Hoang 14/09/2020 Initial coding to add support to STM32 using built-in Ethernet (Nucleo-144, DISCOVERY, etc).
|
1.0.0 K Hoang 14/09/2020 Initial coding to add support to STM32 using built-in Ethernet (Nucleo-144, DISCOVERY, etc).
|
||||||
1.0.1 K Hoang 09/10/2020 Restore cpp code besides Impl.h code.
|
1.0.1 K Hoang 09/10/2020 Restore cpp code besides Impl.h code.
|
||||||
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
|
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
|
||||||
|
1.1.0 K Hoang 23/12/2020 Add HTTP PUT, PATCH, DELETE and HEAD methods
|
||||||
|
1.1.1 K Hoang 24/12/2020 Prevent crash if request and/or method not correct.
|
||||||
|
1.1.2 K Hoang 11/02/2021 Rename _lock and _unlock to avoid conflict with AsyncWebServer library
|
||||||
*****************************************************************************************************************************/
|
*****************************************************************************************************************************/
|
||||||
/*
|
/*
|
||||||
Currently support
|
Currently support
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
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.1.1
|
Version: 1.1.2
|
||||||
|
|
||||||
Version Modified By Date Comments
|
Version Modified By Date Comments
|
||||||
------- ----------- ---------- -----------
|
------- ----------- ---------- -----------
|
||||||
@ -26,6 +26,7 @@
|
|||||||
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
|
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
|
||||||
1.1.0 K Hoang 23/12/2020 Add HTTP PUT, PATCH, DELETE and HEAD methods
|
1.1.0 K Hoang 23/12/2020 Add HTTP PUT, PATCH, DELETE and HEAD methods
|
||||||
1.1.1 K Hoang 24/12/2020 Prevent crash if request and/or method not correct.
|
1.1.1 K Hoang 24/12/2020 Prevent crash if request and/or method not correct.
|
||||||
|
1.1.2 K Hoang 11/02/2021 Rename _lock and _unlock to avoid conflict with AsyncWebServer library
|
||||||
*****************************************************************************************************************************/
|
*****************************************************************************************************************************/
|
||||||
|
|
||||||
#include "defines.h"
|
#include "defines.h"
|
||||||
@ -74,6 +75,8 @@ void sendRequest(void)
|
|||||||
|
|
||||||
void requestCB(void* optParm, AsyncHTTPRequest* request, int readyState)
|
void requestCB(void* optParm, AsyncHTTPRequest* request, int readyState)
|
||||||
{
|
{
|
||||||
|
(void) optParm;
|
||||||
|
|
||||||
if (readyState == readyStateDone)
|
if (readyState == readyStateDone)
|
||||||
{
|
{
|
||||||
Serial.println("\n**************************************");
|
Serial.println("\n**************************************");
|
||||||
|
@ -19,13 +19,16 @@
|
|||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
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.0.2
|
Version: 1.1.2
|
||||||
|
|
||||||
Version Modified By Date Comments
|
Version Modified By Date Comments
|
||||||
------- ----------- ---------- -----------
|
------- ----------- ---------- -----------
|
||||||
1.0.0 K Hoang 14/09/2020 Initial coding to add support to STM32 using built-in Ethernet (Nucleo-144, DISCOVERY, etc).
|
1.0.0 K Hoang 14/09/2020 Initial coding to add support to STM32 using built-in Ethernet (Nucleo-144, DISCOVERY, etc).
|
||||||
1.0.1 K Hoang 09/10/2020 Restore cpp code besides Impl.h code.
|
1.0.1 K Hoang 09/10/2020 Restore cpp code besides Impl.h code.
|
||||||
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
|
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
|
||||||
|
1.1.0 K Hoang 23/12/2020 Add HTTP PUT, PATCH, DELETE and HEAD methods
|
||||||
|
1.1.1 K Hoang 24/12/2020 Prevent crash if request and/or method not correct.
|
||||||
|
1.1.2 K Hoang 11/02/2021 Rename _lock and _unlock to avoid conflict with AsyncWebServer library
|
||||||
*****************************************************************************************************************************/
|
*****************************************************************************************************************************/
|
||||||
/*
|
/*
|
||||||
Currently support
|
Currently support
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
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.1.1
|
Version: 1.1.2
|
||||||
|
|
||||||
Version Modified By Date Comments
|
Version Modified By Date Comments
|
||||||
------- ----------- ---------- -----------
|
------- ----------- ---------- -----------
|
||||||
@ -26,6 +26,7 @@
|
|||||||
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
|
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
|
||||||
1.1.0 K Hoang 23/12/2020 Add HTTP PUT, PATCH, DELETE and HEAD methods
|
1.1.0 K Hoang 23/12/2020 Add HTTP PUT, PATCH, DELETE and HEAD methods
|
||||||
1.1.1 K Hoang 24/12/2020 Prevent crash if request and/or method not correct.
|
1.1.1 K Hoang 24/12/2020 Prevent crash if request and/or method not correct.
|
||||||
|
1.1.2 K Hoang 11/02/2021 Rename _lock and _unlock to avoid conflict with AsyncWebServer library
|
||||||
*****************************************************************************************************************************/
|
*****************************************************************************************************************************/
|
||||||
|
|
||||||
#include "defines.h"
|
#include "defines.h"
|
||||||
@ -76,6 +77,8 @@ void sendRequest(void)
|
|||||||
|
|
||||||
void requestCB(void* optParm, AsyncHTTPRequest* request, int readyState)
|
void requestCB(void* optParm, AsyncHTTPRequest* request, int readyState)
|
||||||
{
|
{
|
||||||
|
(void) optParm;
|
||||||
|
|
||||||
if (readyState == readyStateDone)
|
if (readyState == readyStateDone)
|
||||||
{
|
{
|
||||||
Serial.println("\n**************************************");
|
Serial.println("\n**************************************");
|
||||||
|
@ -19,13 +19,16 @@
|
|||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
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.0.2
|
Version: 1.1.2
|
||||||
|
|
||||||
Version Modified By Date Comments
|
Version Modified By Date Comments
|
||||||
------- ----------- ---------- -----------
|
------- ----------- ---------- -----------
|
||||||
1.0.0 K Hoang 14/09/2020 Initial coding to add support to STM32 using built-in Ethernet (Nucleo-144, DISCOVERY, etc).
|
1.0.0 K Hoang 14/09/2020 Initial coding to add support to STM32 using built-in Ethernet (Nucleo-144, DISCOVERY, etc).
|
||||||
1.0.1 K Hoang 09/10/2020 Restore cpp code besides Impl.h code.
|
1.0.1 K Hoang 09/10/2020 Restore cpp code besides Impl.h code.
|
||||||
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
|
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
|
||||||
|
1.1.0 K Hoang 23/12/2020 Add HTTP PUT, PATCH, DELETE and HEAD methods
|
||||||
|
1.1.1 K Hoang 24/12/2020 Prevent crash if request and/or method not correct.
|
||||||
|
1.1.2 K Hoang 11/02/2021 Rename _lock and _unlock to avoid conflict with AsyncWebServer library
|
||||||
*****************************************************************************************************************************/
|
*****************************************************************************************************************************/
|
||||||
/*
|
/*
|
||||||
Currently support
|
Currently support
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
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.1.1
|
Version: 1.1.2
|
||||||
|
|
||||||
Version Modified By Date Comments
|
Version Modified By Date Comments
|
||||||
------- ----------- ---------- -----------
|
------- ----------- ---------- -----------
|
||||||
@ -26,10 +26,14 @@
|
|||||||
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
|
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
|
||||||
1.1.0 K Hoang 23/12/2020 Add HTTP PUT, PATCH, DELETE and HEAD methods
|
1.1.0 K Hoang 23/12/2020 Add HTTP PUT, PATCH, DELETE and HEAD methods
|
||||||
1.1.1 K Hoang 24/12/2020 Prevent crash if request and/or method not correct.
|
1.1.1 K Hoang 24/12/2020 Prevent crash if request and/or method not correct.
|
||||||
|
1.1.2 K Hoang 11/02/2021 Rename _lock and _unlock to avoid conflict with AsyncWebServer library
|
||||||
*****************************************************************************************************************************/
|
*****************************************************************************************************************************/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef ASYNC_HTTP_REQUEST_DEBUG_GENERIC_H
|
||||||
|
#define ASYNC_HTTP_REQUEST_DEBUG_GENERIC_H
|
||||||
|
|
||||||
#ifdef ASYNC_HTTP_DEBUG_PORT
|
#ifdef ASYNC_HTTP_DEBUG_PORT
|
||||||
#define A_DBG_PORT ASYNC_HTTP_DEBUG_PORT
|
#define A_DBG_PORT ASYNC_HTTP_DEBUG_PORT
|
||||||
#else
|
#else
|
||||||
@ -71,3 +75,5 @@
|
|||||||
#define AHTTP_LOGDEBUG2(x,y,z) if(_ASYNC_HTTP_LOGLEVEL_>3) { A_DBG_PORT.print("[AHTTP] "); A_DBG_PORT.print(x); A_DBG_PORT.print(" "); A_DBG_PORT.print(y); A_DBG_PORT.print(" "); A_DBG_PORT.println(z); }
|
#define AHTTP_LOGDEBUG2(x,y,z) if(_ASYNC_HTTP_LOGLEVEL_>3) { A_DBG_PORT.print("[AHTTP] "); A_DBG_PORT.print(x); A_DBG_PORT.print(" "); A_DBG_PORT.print(y); A_DBG_PORT.print(" "); A_DBG_PORT.println(z); }
|
||||||
#define AHTTP_LOGDEBUG3(x,y,z,w) if(_ASYNC_HTTP_LOGLEVEL_>3) { A_DBG_PORT.print("[AHTTP] "); A_DBG_PORT.print(x); A_DBG_PORT.print(" "); A_DBG_PORT.print(y); A_DBG_PORT.print(" "); A_DBG_PORT.print(z); A_DBG_PORT.print(" "); A_DBG_PORT.println(w); }
|
#define AHTTP_LOGDEBUG3(x,y,z,w) if(_ASYNC_HTTP_LOGLEVEL_>3) { A_DBG_PORT.print("[AHTTP] "); A_DBG_PORT.print(x); A_DBG_PORT.print(" "); A_DBG_PORT.print(y); A_DBG_PORT.print(" "); A_DBG_PORT.print(z); A_DBG_PORT.print(" "); A_DBG_PORT.println(w); }
|
||||||
|
|
||||||
|
#endif // ASYNC_HTTP_REQUEST_DEBUG_GENERIC_H
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
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.1.1
|
Version: 1.1.2
|
||||||
|
|
||||||
Version Modified By Date Comments
|
Version Modified By Date Comments
|
||||||
------- ----------- ---------- -----------
|
------- ----------- ---------- -----------
|
||||||
@ -26,11 +26,15 @@
|
|||||||
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
|
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
|
||||||
1.1.0 K Hoang 23/12/2020 Add HTTP PUT, PATCH, DELETE and HEAD methods
|
1.1.0 K Hoang 23/12/2020 Add HTTP PUT, PATCH, DELETE and HEAD methods
|
||||||
1.1.1 K Hoang 24/12/2020 Prevent crash if request and/or method not correct.
|
1.1.1 K Hoang 24/12/2020 Prevent crash if request and/or method not correct.
|
||||||
|
1.1.2 K Hoang 11/02/2021 Rename _lock and _unlock to avoid conflict with AsyncWebServer library
|
||||||
*****************************************************************************************************************************/
|
*****************************************************************************************************************************/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION "AsyncHTTPRequest_Generic v1.1.1"
|
#ifndef ASYNC_HTTP_REQUEST_GENERIC_H
|
||||||
|
#define ASYNC_HTTP_REQUEST_GENERIC_H
|
||||||
|
|
||||||
|
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION "AsyncHTTPRequest_Generic v1.1.2"
|
||||||
|
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
|
||||||
@ -59,8 +63,8 @@
|
|||||||
#define MUTEX_LOCK_NR if (xSemaphoreTakeRecursive(threadLock,portMAX_DELAY) != pdTRUE) { return;}
|
#define MUTEX_LOCK_NR if (xSemaphoreTakeRecursive(threadLock,portMAX_DELAY) != pdTRUE) { return;}
|
||||||
#define MUTEX_LOCK(returnVal) if (xSemaphoreTakeRecursive(threadLock,portMAX_DELAY) != pdTRUE) { return returnVal;}
|
#define MUTEX_LOCK(returnVal) if (xSemaphoreTakeRecursive(threadLock,portMAX_DELAY) != pdTRUE) { return returnVal;}
|
||||||
|
|
||||||
#define _lock xSemaphoreTakeRecursive(threadLock,portMAX_DELAY)
|
#define _AHTTP_lock xSemaphoreTakeRecursive(threadLock,portMAX_DELAY)
|
||||||
#define _unlock xSemaphoreGiveRecursive(threadLock)
|
#define _AHTTP_unlock xSemaphoreGiveRecursive(threadLock)
|
||||||
|
|
||||||
#elif ESP8266
|
#elif ESP8266
|
||||||
|
|
||||||
@ -69,8 +73,8 @@
|
|||||||
#define MUTEX_LOCK_NR
|
#define MUTEX_LOCK_NR
|
||||||
#define MUTEX_LOCK(returnVal)
|
#define MUTEX_LOCK(returnVal)
|
||||||
|
|
||||||
#define _lock
|
#define _AHTTP_lock
|
||||||
#define _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(STM32F7) || \
|
||||||
defined(STM32L0) || defined(STM32L1) || defined(STM32L4) || defined(STM32H7) ||defined(STM32G0) || defined(STM32G4) || \
|
defined(STM32L0) || defined(STM32L1) || defined(STM32L4) || defined(STM32H7) ||defined(STM32G0) || defined(STM32G4) || \
|
||||||
@ -80,8 +84,8 @@
|
|||||||
|
|
||||||
#define MUTEX_LOCK_NR
|
#define MUTEX_LOCK_NR
|
||||||
#define MUTEX_LOCK(returnVal)
|
#define MUTEX_LOCK(returnVal)
|
||||||
#define _lock
|
#define _AHTTP_lock
|
||||||
#define _unlock
|
#define _AHTTP_unlock
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -220,8 +224,11 @@ class AsyncHTTPRequest
|
|||||||
size_t responseLength(); // indicated response length or sum of chunks to date
|
size_t responseLength(); // indicated response length or sum of chunks to date
|
||||||
int responseHTTPcode(); // HTTP response code or (negative) error code
|
int responseHTTPcode(); // HTTP response code or (negative) error code
|
||||||
String responseText(); // response (whole* or partial* as string)
|
String responseText(); // response (whole* or partial* as string)
|
||||||
|
|
||||||
|
char* responseLongText(); // response long (whole* or partial* as string)
|
||||||
|
|
||||||
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
|
||||||
//___________________________________________________________________________________________________________________________________
|
//___________________________________________________________________________________________________________________________________
|
||||||
|
|
||||||
@ -299,4 +306,4 @@ class AsyncHTTPRequest
|
|||||||
|
|
||||||
#include "AsyncHTTPRequest_Impl_Generic.h"
|
#include "AsyncHTTPRequest_Impl_Generic.h"
|
||||||
|
|
||||||
|
#endif // ASYNC_HTTP_REQUEST_GENERIC_H
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
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.1.1
|
Version: 1.1.2
|
||||||
|
|
||||||
Version Modified By Date Comments
|
Version Modified By Date Comments
|
||||||
------- ----------- ---------- -----------
|
------- ----------- ---------- -----------
|
||||||
@ -26,10 +26,14 @@
|
|||||||
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
|
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
|
||||||
1.1.0 K Hoang 23/12/2020 Add HTTP PUT, PATCH, DELETE and HEAD methods
|
1.1.0 K Hoang 23/12/2020 Add HTTP PUT, PATCH, DELETE and HEAD methods
|
||||||
1.1.1 K Hoang 24/12/2020 Prevent crash if request and/or method not correct.
|
1.1.1 K Hoang 24/12/2020 Prevent crash if request and/or method not correct.
|
||||||
|
1.1.2 K Hoang 11/02/2021 Rename _lock and _unlock to avoid conflict with AsyncWebServer library
|
||||||
*****************************************************************************************************************************/
|
*****************************************************************************************************************************/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef ASYNC_HTTP_REQUEST_GENERIC_IMPL_H
|
||||||
|
#define ASYNC_HTTP_REQUEST_GENERIC_IMPL_H
|
||||||
|
|
||||||
#define CANT_SEND_BAD_REQUEST F("Can't send() bad request")
|
#define CANT_SEND_BAD_REQUEST F("Can't send() bad request")
|
||||||
|
|
||||||
//**************************************************************************************************************
|
//**************************************************************************************************************
|
||||||
@ -93,6 +97,8 @@ bool AsyncHTTPRequest::open(const char* method, const char* URL)
|
|||||||
|
|
||||||
if (_readyState != readyStateUnsent && _readyState != readyStateDone)
|
if (_readyState != readyStateUnsent && _readyState != readyStateDone)
|
||||||
{
|
{
|
||||||
|
AHTTP_LOGDEBUG("open: not ready");
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -145,17 +151,23 @@ bool AsyncHTTPRequest::open(const char* method, const char* URL)
|
|||||||
//////
|
//////
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
AHTTP_LOGDEBUG("open: Bad method");
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!_parseURL(URL))
|
if (!_parseURL(URL))
|
||||||
{
|
{
|
||||||
|
AHTTP_LOGDEBUG("open: error parsing URL");
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( _client && _client->connected() && (strcmp(_URL->host, _connectedHost) != 0 || _URL->port != _connectedPort))
|
if ( _client && _client->connected() && (strcmp(_URL->host, _connectedHost) != 0 || _URL->port != _connectedPort))
|
||||||
{
|
{
|
||||||
|
AHTTP_LOGDEBUG("open: not connected");
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -173,11 +185,17 @@ bool AsyncHTTPRequest::open(const char* method, const char* URL)
|
|||||||
// New in v1.1.1
|
// New in v1.1.1
|
||||||
_requestReadyToSend = true;
|
_requestReadyToSend = true;
|
||||||
//////
|
//////
|
||||||
|
|
||||||
|
AHTTP_LOGDEBUG1("open: conneting to hostname =", hostName);
|
||||||
|
|
||||||
return _connect();
|
return _connect();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
AHTTP_LOGDEBUG("open: error alloc");
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//**************************************************************************************************************
|
//**************************************************************************************************************
|
||||||
void AsyncHTTPRequest::onReadyStateChange(readyStateChangeCB cb, void* arg)
|
void AsyncHTTPRequest::onReadyStateChange(readyStateChangeCB cb, void* arg)
|
||||||
@ -216,7 +234,7 @@ bool AsyncHTTPRequest::send()
|
|||||||
|
|
||||||
_send();
|
_send();
|
||||||
|
|
||||||
_unlock;
|
_AHTTP_unlock;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -242,7 +260,7 @@ bool AsyncHTTPRequest::send(String body)
|
|||||||
|
|
||||||
if ( ! _buildRequest())
|
if ( ! _buildRequest())
|
||||||
{
|
{
|
||||||
_unlock;
|
_AHTTP_unlock;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -250,7 +268,7 @@ bool AsyncHTTPRequest::send(String body)
|
|||||||
_request->write(body);
|
_request->write(body);
|
||||||
_send();
|
_send();
|
||||||
|
|
||||||
_unlock;
|
_AHTTP_unlock;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -276,7 +294,7 @@ bool AsyncHTTPRequest::send(const char* body)
|
|||||||
|
|
||||||
if ( ! _buildRequest())
|
if ( ! _buildRequest())
|
||||||
{
|
{
|
||||||
_unlock;
|
_AHTTP_unlock;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -284,7 +302,7 @@ bool AsyncHTTPRequest::send(const char* body)
|
|||||||
_request->write(body);
|
_request->write(body);
|
||||||
_send();
|
_send();
|
||||||
|
|
||||||
_unlock;
|
_AHTTP_unlock;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -310,7 +328,7 @@ bool AsyncHTTPRequest::send(const uint8_t* body, size_t len)
|
|||||||
|
|
||||||
if ( ! _buildRequest())
|
if ( ! _buildRequest())
|
||||||
{
|
{
|
||||||
_unlock;
|
_AHTTP_unlock;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -318,7 +336,7 @@ bool AsyncHTTPRequest::send(const uint8_t* body, size_t len)
|
|||||||
_request->write(body, len);
|
_request->write(body, len);
|
||||||
_send();
|
_send();
|
||||||
|
|
||||||
_unlock;
|
_AHTTP_unlock;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -344,7 +362,7 @@ bool AsyncHTTPRequest::send(xbuf* body, size_t len)
|
|||||||
|
|
||||||
if ( ! _buildRequest())
|
if ( ! _buildRequest())
|
||||||
{
|
{
|
||||||
_unlock;
|
_AHTTP_unlock;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -352,7 +370,7 @@ bool AsyncHTTPRequest::send(xbuf* body, size_t len)
|
|||||||
_request->write(body, len);
|
_request->write(body, len);
|
||||||
_send();
|
_send();
|
||||||
|
|
||||||
_unlock;
|
_AHTTP_unlock;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -371,7 +389,7 @@ void AsyncHTTPRequest::abort()
|
|||||||
|
|
||||||
_client->abort();
|
_client->abort();
|
||||||
|
|
||||||
_unlock;
|
_AHTTP_unlock;
|
||||||
}
|
}
|
||||||
//**************************************************************************************************************
|
//**************************************************************************************************************
|
||||||
reqStates AsyncHTTPRequest::readyState()
|
reqStates AsyncHTTPRequest::readyState()
|
||||||
@ -396,7 +414,7 @@ String AsyncHTTPRequest::responseText()
|
|||||||
{
|
{
|
||||||
AHTTP_LOGDEBUG("responseText() no data");
|
AHTTP_LOGDEBUG("responseText() no data");
|
||||||
|
|
||||||
_unlock;
|
_AHTTP_unlock;
|
||||||
|
|
||||||
return String();
|
return String();
|
||||||
}
|
}
|
||||||
@ -411,7 +429,7 @@ String AsyncHTTPRequest::responseText()
|
|||||||
_HTTPcode = HTTPCODE_TOO_LESS_RAM;
|
_HTTPcode = HTTPCODE_TOO_LESS_RAM;
|
||||||
_client->abort();
|
_client->abort();
|
||||||
|
|
||||||
_unlock;
|
_AHTTP_unlock;
|
||||||
|
|
||||||
return String();
|
return String();
|
||||||
}
|
}
|
||||||
@ -419,13 +437,61 @@ String AsyncHTTPRequest::responseText()
|
|||||||
localString = _response->readString(avail);
|
localString = _response->readString(avail);
|
||||||
_contentRead += localString.length();
|
_contentRead += localString.length();
|
||||||
|
|
||||||
AHTTP_LOGDEBUG3("responseText(char)", localString.substring(0, 16).c_str(), ", avail =", avail);
|
//AHTTP_LOGDEBUG3("responseText(char)", localString.substring(0, 16).c_str(), ", avail =", avail);
|
||||||
|
AHTTP_LOGDEBUG3("responseText(char)", localString, ", avail =", avail);
|
||||||
|
|
||||||
_unlock;
|
_AHTTP_unlock;
|
||||||
|
|
||||||
return localString;
|
return localString;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//**************************************************************************************************************
|
||||||
|
|
||||||
|
#if 1
|
||||||
|
|
||||||
|
#if (ESP32)
|
||||||
|
#define GLOBAL_STR_LEN (32 * 1024)
|
||||||
|
#elif (ESP8266)
|
||||||
|
#define GLOBAL_STR_LEN (16 * 1024)
|
||||||
|
#else
|
||||||
|
#define GLOBAL_STR_LEN (4 * 1024)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
char globalLongString[GLOBAL_STR_LEN + 1];
|
||||||
|
|
||||||
|
char* AsyncHTTPRequest::responseLongText()
|
||||||
|
{
|
||||||
|
AHTTP_LOGDEBUG("responseLongText()");
|
||||||
|
|
||||||
|
MUTEX_LOCK(NULL)
|
||||||
|
|
||||||
|
if ( ! _response || _readyState < readyStateLoading || ! available())
|
||||||
|
{
|
||||||
|
AHTTP_LOGDEBUG("responseText() no data");
|
||||||
|
|
||||||
|
_AHTTP_unlock;
|
||||||
|
|
||||||
|
//return String();
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// String localString;
|
||||||
|
size_t avail = available();
|
||||||
|
size_t lenToCopy = (avail <= GLOBAL_STR_LEN) ? avail : GLOBAL_STR_LEN;
|
||||||
|
|
||||||
|
strncpy(globalLongString, _response->readString(avail).c_str(), lenToCopy );
|
||||||
|
globalLongString[ lenToCopy + 1 ] = 0;
|
||||||
|
|
||||||
|
_contentRead += _response->readString(avail).length();
|
||||||
|
|
||||||
|
AHTTP_LOGDEBUG3("responseLongText(char)", globalLongString, ", avail =", avail);
|
||||||
|
|
||||||
|
_AHTTP_unlock;
|
||||||
|
|
||||||
|
return globalLongString;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
//**************************************************************************************************************
|
//**************************************************************************************************************
|
||||||
size_t AsyncHTTPRequest::responseRead(uint8_t* buf, size_t len)
|
size_t AsyncHTTPRequest::responseRead(uint8_t* buf, size_t len)
|
||||||
{
|
{
|
||||||
@ -445,7 +511,7 @@ size_t AsyncHTTPRequest::responseRead(uint8_t* buf, size_t len)
|
|||||||
|
|
||||||
_contentRead += avail;
|
_contentRead += avail;
|
||||||
|
|
||||||
_unlock;
|
_AHTTP_unlock;
|
||||||
|
|
||||||
return avail;
|
return avail;
|
||||||
}
|
}
|
||||||
@ -847,11 +913,18 @@ void AsyncHTTPRequest::_onConnect(AsyncClient* client)
|
|||||||
_client = client;
|
_client = client;
|
||||||
_setReadyState(readyStateOpened);
|
_setReadyState(readyStateOpened);
|
||||||
|
|
||||||
|
// KH test
|
||||||
_response = new xbuf;
|
_response = new xbuf;
|
||||||
|
//_response = new xbuf(256);
|
||||||
|
//////
|
||||||
|
|
||||||
if (!_response)
|
if (!_response)
|
||||||
{
|
{
|
||||||
_unlock;
|
_AHTTP_unlock;
|
||||||
|
|
||||||
|
// KH, to remove
|
||||||
|
AHTTP_LOGDEBUG("_onConnect: Can't new _responser");
|
||||||
|
///////
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -862,11 +935,17 @@ void AsyncHTTPRequest::_onConnect(AsyncClient* client)
|
|||||||
|
|
||||||
_client->onAck([](void* obj, AsyncClient * client, size_t len, uint32_t time)
|
_client->onAck([](void* obj, AsyncClient * client, size_t len, uint32_t time)
|
||||||
{
|
{
|
||||||
|
(void) client;
|
||||||
|
(void) len;
|
||||||
|
(void) time;
|
||||||
|
|
||||||
((AsyncHTTPRequest*)(obj))->_send();
|
((AsyncHTTPRequest*)(obj))->_send();
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
_client->onData([](void* obj, AsyncClient * client, void* data, size_t len)
|
_client->onData([](void* obj, AsyncClient * client, void* data, size_t len)
|
||||||
{
|
{
|
||||||
|
(void) client;
|
||||||
|
|
||||||
((AsyncHTTPRequest*)(obj))->_onData(data, len);
|
((AsyncHTTPRequest*)(obj))->_onData(data, len);
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
@ -877,12 +956,14 @@ void AsyncHTTPRequest::_onConnect(AsyncClient* client)
|
|||||||
|
|
||||||
_lastActivity = millis();
|
_lastActivity = millis();
|
||||||
|
|
||||||
_unlock;
|
_AHTTP_unlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
//**************************************************************************************************************
|
//**************************************************************************************************************
|
||||||
void AsyncHTTPRequest::_onPoll(AsyncClient* client)
|
void AsyncHTTPRequest::_onPoll(AsyncClient* client)
|
||||||
{
|
{
|
||||||
|
(void) client;
|
||||||
|
|
||||||
MUTEX_LOCK_NR
|
MUTEX_LOCK_NR
|
||||||
|
|
||||||
if (_timeout && (millis() - _lastActivity) > (_timeout * 1000))
|
if (_timeout && (millis() - _lastActivity) > (_timeout * 1000))
|
||||||
@ -898,12 +979,14 @@ void AsyncHTTPRequest::_onPoll(AsyncClient* client)
|
|||||||
_onDataCB(_onDataCBarg, this, available());
|
_onDataCB(_onDataCBarg, this, available());
|
||||||
}
|
}
|
||||||
|
|
||||||
_unlock;
|
_AHTTP_unlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
//**************************************************************************************************************
|
//**************************************************************************************************************
|
||||||
void AsyncHTTPRequest::_onError(AsyncClient* client, int8_t error)
|
void AsyncHTTPRequest::_onError(AsyncClient* client, int8_t error)
|
||||||
{
|
{
|
||||||
|
(void) client;
|
||||||
|
|
||||||
AHTTP_LOGDEBUG1("_onError handler error =", error);
|
AHTTP_LOGDEBUG1("_onError handler error =", error);
|
||||||
|
|
||||||
_HTTPcode = error;
|
_HTTPcode = error;
|
||||||
@ -912,6 +995,8 @@ void AsyncHTTPRequest::_onError(AsyncClient* client, int8_t error)
|
|||||||
//**************************************************************************************************************
|
//**************************************************************************************************************
|
||||||
void AsyncHTTPRequest::_onDisconnect(AsyncClient* client)
|
void AsyncHTTPRequest::_onDisconnect(AsyncClient* client)
|
||||||
{
|
{
|
||||||
|
(void) client;
|
||||||
|
|
||||||
AHTTP_LOGDEBUG("\n_onDisconnect handler");
|
AHTTP_LOGDEBUG("\n_onDisconnect handler");
|
||||||
|
|
||||||
MUTEX_LOCK_NR
|
MUTEX_LOCK_NR
|
||||||
@ -939,7 +1024,7 @@ void AsyncHTTPRequest::_onDisconnect(AsyncClient* client)
|
|||||||
_lastActivity = 0;
|
_lastActivity = 0;
|
||||||
_setReadyState(readyStateDone);
|
_setReadyState(readyStateDone);
|
||||||
|
|
||||||
_unlock;
|
_AHTTP_unlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
//**************************************************************************************************************
|
//**************************************************************************************************************
|
||||||
@ -955,6 +1040,11 @@ void AsyncHTTPRequest::_onData(void* Vbuf, size_t len)
|
|||||||
if (_chunks)
|
if (_chunks)
|
||||||
{
|
{
|
||||||
_chunks->write((uint8_t*)Vbuf, len);
|
_chunks->write((uint8_t*)Vbuf, len);
|
||||||
|
|
||||||
|
// KH, to remove
|
||||||
|
AHTTP_LOGDEBUG("_onData: _processChunks");
|
||||||
|
///////
|
||||||
|
|
||||||
_processChunks();
|
_processChunks();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -967,7 +1057,11 @@ void AsyncHTTPRequest::_onData(void* Vbuf, size_t len)
|
|||||||
{
|
{
|
||||||
if ( ! _collectHeaders())
|
if ( ! _collectHeaders())
|
||||||
{
|
{
|
||||||
_unlock;
|
_AHTTP_unlock;
|
||||||
|
|
||||||
|
// KH, to remove
|
||||||
|
AHTTP_LOGDEBUG("_onData: headers not complete");
|
||||||
|
///////
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1007,7 +1101,7 @@ void AsyncHTTPRequest::_onData(void* Vbuf, size_t len)
|
|||||||
_onDataCB(_onDataCBarg, this, available());
|
_onDataCB(_onDataCBarg, this, available());
|
||||||
}
|
}
|
||||||
|
|
||||||
_unlock;
|
_AHTTP_unlock;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1292,7 +1386,7 @@ String AsyncHTTPRequest::headers()
|
|||||||
|
|
||||||
_response += "\r\n";
|
_response += "\r\n";
|
||||||
|
|
||||||
_unlock;
|
_AHTTP_unlock;
|
||||||
|
|
||||||
return _response;
|
return _response;
|
||||||
}
|
}
|
||||||
@ -1352,7 +1446,7 @@ AsyncHTTPRequest::header* AsyncHTTPRequest::_addHeader(const char* name, const
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
_unlock;
|
_AHTTP_unlock;
|
||||||
|
|
||||||
return hdr->next;
|
return hdr->next;
|
||||||
}
|
}
|
||||||
@ -1372,7 +1466,7 @@ AsyncHTTPRequest::header* AsyncHTTPRequest::_getHeader(const char* name)
|
|||||||
hdr = hdr->next;
|
hdr = hdr->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
_unlock;
|
_AHTTP_unlock;
|
||||||
|
|
||||||
return hdr;
|
return hdr;
|
||||||
}
|
}
|
||||||
@ -1392,7 +1486,7 @@ AsyncHTTPRequest::header* AsyncHTTPRequest::_getHeader(int ndx)
|
|||||||
hdr = hdr->next;
|
hdr = hdr->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
_unlock;
|
_AHTTP_unlock;
|
||||||
|
|
||||||
return hdr;
|
return hdr;
|
||||||
}
|
}
|
||||||
@ -1417,3 +1511,5 @@ char* AsyncHTTPRequest::_charstar(const __FlashStringHelper * str)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif // ASYNC_HTTP_REQUEST_GENERIC_IMPL_H
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
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.1.1
|
Version: 1.1.2
|
||||||
|
|
||||||
Version Modified By Date Comments
|
Version Modified By Date Comments
|
||||||
------- ----------- ---------- -----------
|
------- ----------- ---------- -----------
|
||||||
@ -26,6 +26,7 @@
|
|||||||
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
|
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
|
||||||
1.1.0 K Hoang 23/12/2020 Add HTTP PUT, PATCH, DELETE and HEAD methods
|
1.1.0 K Hoang 23/12/2020 Add HTTP PUT, PATCH, DELETE and HEAD methods
|
||||||
1.1.1 K Hoang 24/12/2020 Prevent crash if request and/or method not correct.
|
1.1.1 K Hoang 24/12/2020 Prevent crash if request and/or method not correct.
|
||||||
|
1.1.2 K Hoang 11/02/2021 Rename _lock and _unlock to avoid conflict with AsyncWebServer library
|
||||||
*****************************************************************************************************************************/
|
*****************************************************************************************************************************/
|
||||||
|
|
||||||
/********************************************************************************************
|
/********************************************************************************************
|
||||||
@ -48,6 +49,9 @@
|
|||||||
********************************************************************************************/
|
********************************************************************************************/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef XBUF_H
|
||||||
|
#define XBUF_H
|
||||||
|
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
|
||||||
struct xseg
|
struct xseg
|
||||||
@ -151,3 +155,5 @@ class xbuf: public Print
|
|||||||
|
|
||||||
#include "utility/xbuf_Impl.h"
|
#include "utility/xbuf_Impl.h"
|
||||||
|
|
||||||
|
#endif // XBUF_H
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
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.1.1
|
Version: 1.1.2
|
||||||
|
|
||||||
Version Modified By Date Comments
|
Version Modified By Date Comments
|
||||||
------- ----------- ---------- -----------
|
------- ----------- ---------- -----------
|
||||||
@ -26,10 +26,14 @@
|
|||||||
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
|
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
|
||||||
1.1.0 K Hoang 23/12/2020 Add HTTP PUT, PATCH, DELETE and HEAD methods
|
1.1.0 K Hoang 23/12/2020 Add HTTP PUT, PATCH, DELETE and HEAD methods
|
||||||
1.1.1 K Hoang 24/12/2020 Prevent crash if request and/or method not correct.
|
1.1.1 K Hoang 24/12/2020 Prevent crash if request and/or method not correct.
|
||||||
|
1.1.2 K Hoang 11/02/2021 Rename _lock and _unlock to avoid conflict with AsyncWebServer library
|
||||||
*****************************************************************************************************************************/
|
*****************************************************************************************************************************/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef XBUF_IMPL_H
|
||||||
|
#define XBUF_IMPL_H
|
||||||
|
|
||||||
xbuf::xbuf(const uint16_t segSize) : _head(nullptr), _tail(nullptr), _used(0), _free(0), _offset(0)
|
xbuf::xbuf(const uint16_t segSize) : _head(nullptr), _tail(nullptr), _used(0), _free(0), _offset(0)
|
||||||
{
|
{
|
||||||
_segSize = (segSize + 3) & -4;//((segSize + 3) >> 2) << 2;
|
_segSize = (segSize + 3) & -4;//((segSize + 3) >> 2) << 2;
|
||||||
@ -291,9 +295,17 @@ String xbuf::readString(int endPos)
|
|||||||
|
|
||||||
if ( ! result.reserve(endPos + 1))
|
if ( ! result.reserve(endPos + 1))
|
||||||
{
|
{
|
||||||
|
// KH, to remove
|
||||||
|
AHTTP_LOGDEBUG1("xbuf::readString: can't reserve size = ", endPos + 1);
|
||||||
|
///////
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// KH, to remove
|
||||||
|
AHTTP_LOGDEBUG1("xbuf::readString: Reserved size = ", endPos + 1);
|
||||||
|
///////
|
||||||
|
|
||||||
if (endPos > _used)
|
if (endPos > _used)
|
||||||
{
|
{
|
||||||
endPos = _used;
|
endPos = _used;
|
||||||
@ -365,6 +377,9 @@ void xbuf::addSeg()
|
|||||||
{
|
{
|
||||||
_tail->next = (xseg*) new uint32_t[_segSize / 4 + 1];
|
_tail->next = (xseg*) new uint32_t[_segSize / 4 + 1];
|
||||||
|
|
||||||
|
if (_tail->next == NULL)
|
||||||
|
AHTTP_LOGERROR("xbuf::addSeg: error new 1");
|
||||||
|
|
||||||
// KH, Must check NULL here
|
// KH, Must check NULL here
|
||||||
_tail = _tail->next;
|
_tail = _tail->next;
|
||||||
}
|
}
|
||||||
@ -372,6 +387,9 @@ void xbuf::addSeg()
|
|||||||
{
|
{
|
||||||
// KH, Must check NULL here
|
// KH, Must check NULL here
|
||||||
_tail = _head = (xseg*) new uint32_t[_segSize / 4 + 1];
|
_tail = _head = (xseg*) new uint32_t[_segSize / 4 + 1];
|
||||||
|
|
||||||
|
if (_tail == NULL)
|
||||||
|
AHTTP_LOGERROR("xbuf::addSeg: error new 2");
|
||||||
}
|
}
|
||||||
|
|
||||||
// KH, Must check NULL here
|
// KH, Must check NULL here
|
||||||
@ -399,3 +417,5 @@ void xbuf::remSeg()
|
|||||||
_offset = 0;
|
_offset = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif // XBUF_IMPL_H
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
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.1.1
|
Version: 1.1.2
|
||||||
|
|
||||||
Version Modified By Date Comments
|
Version Modified By Date Comments
|
||||||
------- ----------- ---------- -----------
|
------- ----------- ---------- -----------
|
||||||
@ -26,10 +26,14 @@
|
|||||||
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
|
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
|
||||||
1.1.0 K Hoang 23/12/2020 Add HTTP PUT, PATCH, DELETE and HEAD methods
|
1.1.0 K Hoang 23/12/2020 Add HTTP PUT, PATCH, DELETE and HEAD methods
|
||||||
1.1.1 K Hoang 24/12/2020 Prevent crash if request and/or method not correct.
|
1.1.1 K Hoang 24/12/2020 Prevent crash if request and/or method not correct.
|
||||||
|
1.1.2 K Hoang 11/02/2021 Rename _lock and _unlock to avoid conflict with AsyncWebServer library
|
||||||
*****************************************************************************************************************************/
|
*****************************************************************************************************************************/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef ASYNC_HTTP_REQUEST_DEBUG_GENERIC_H
|
||||||
|
#define ASYNC_HTTP_REQUEST_DEBUG_GENERIC_H
|
||||||
|
|
||||||
#ifdef ASYNC_HTTP_DEBUG_PORT
|
#ifdef ASYNC_HTTP_DEBUG_PORT
|
||||||
#define A_DBG_PORT ASYNC_HTTP_DEBUG_PORT
|
#define A_DBG_PORT ASYNC_HTTP_DEBUG_PORT
|
||||||
#else
|
#else
|
||||||
@ -71,3 +75,5 @@
|
|||||||
#define AHTTP_LOGDEBUG2(x,y,z) if(_ASYNC_HTTP_LOGLEVEL_>3) { A_DBG_PORT.print("[AHTTP] "); A_DBG_PORT.print(x); A_DBG_PORT.print(" "); A_DBG_PORT.print(y); A_DBG_PORT.print(" "); A_DBG_PORT.println(z); }
|
#define AHTTP_LOGDEBUG2(x,y,z) if(_ASYNC_HTTP_LOGLEVEL_>3) { A_DBG_PORT.print("[AHTTP] "); A_DBG_PORT.print(x); A_DBG_PORT.print(" "); A_DBG_PORT.print(y); A_DBG_PORT.print(" "); A_DBG_PORT.println(z); }
|
||||||
#define AHTTP_LOGDEBUG3(x,y,z,w) if(_ASYNC_HTTP_LOGLEVEL_>3) { A_DBG_PORT.print("[AHTTP] "); A_DBG_PORT.print(x); A_DBG_PORT.print(" "); A_DBG_PORT.print(y); A_DBG_PORT.print(" "); A_DBG_PORT.print(z); A_DBG_PORT.print(" "); A_DBG_PORT.println(w); }
|
#define AHTTP_LOGDEBUG3(x,y,z,w) if(_ASYNC_HTTP_LOGLEVEL_>3) { A_DBG_PORT.print("[AHTTP] "); A_DBG_PORT.print(x); A_DBG_PORT.print(" "); A_DBG_PORT.print(y); A_DBG_PORT.print(" "); A_DBG_PORT.print(z); A_DBG_PORT.print(" "); A_DBG_PORT.println(w); }
|
||||||
|
|
||||||
|
#endif // ASYNC_HTTP_REQUEST_DEBUG_GENERIC_H
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
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.1.1
|
Version: 1.1.2
|
||||||
|
|
||||||
Version Modified By Date Comments
|
Version Modified By Date Comments
|
||||||
------- ----------- ---------- -----------
|
------- ----------- ---------- -----------
|
||||||
@ -26,6 +26,7 @@
|
|||||||
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
|
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
|
||||||
1.1.0 K Hoang 23/12/2020 Add HTTP PUT, PATCH, DELETE and HEAD methods
|
1.1.0 K Hoang 23/12/2020 Add HTTP PUT, PATCH, DELETE and HEAD methods
|
||||||
1.1.1 K Hoang 24/12/2020 Prevent crash if request and/or method not correct.
|
1.1.1 K Hoang 24/12/2020 Prevent crash if request and/or method not correct.
|
||||||
|
1.1.2 K Hoang 11/02/2021 Rename _lock and _unlock to avoid conflict with AsyncWebServer library
|
||||||
*****************************************************************************************************************************/
|
*****************************************************************************************************************************/
|
||||||
|
|
||||||
#include "AsyncHTTPRequest_Debug_Generic.h"
|
#include "AsyncHTTPRequest_Debug_Generic.h"
|
||||||
@ -218,7 +219,7 @@ bool AsyncHTTPRequest::send()
|
|||||||
|
|
||||||
_send();
|
_send();
|
||||||
|
|
||||||
_unlock;
|
_AHTTP_unlock;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -244,7 +245,7 @@ bool AsyncHTTPRequest::send(String body)
|
|||||||
|
|
||||||
if ( ! _buildRequest())
|
if ( ! _buildRequest())
|
||||||
{
|
{
|
||||||
_unlock;
|
_AHTTP_unlock;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -252,7 +253,7 @@ bool AsyncHTTPRequest::send(String body)
|
|||||||
_request->write(body);
|
_request->write(body);
|
||||||
_send();
|
_send();
|
||||||
|
|
||||||
_unlock;
|
_AHTTP_unlock;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -278,7 +279,7 @@ bool AsyncHTTPRequest::send(const char* body)
|
|||||||
|
|
||||||
if ( ! _buildRequest())
|
if ( ! _buildRequest())
|
||||||
{
|
{
|
||||||
_unlock;
|
_AHTTP_unlock;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -286,7 +287,7 @@ bool AsyncHTTPRequest::send(const char* body)
|
|||||||
_request->write(body);
|
_request->write(body);
|
||||||
_send();
|
_send();
|
||||||
|
|
||||||
_unlock;
|
_AHTTP_unlock;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -312,7 +313,7 @@ bool AsyncHTTPRequest::send(const uint8_t* body, size_t len)
|
|||||||
|
|
||||||
if ( ! _buildRequest())
|
if ( ! _buildRequest())
|
||||||
{
|
{
|
||||||
_unlock;
|
_AHTTP_unlock;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -320,7 +321,7 @@ bool AsyncHTTPRequest::send(const uint8_t* body, size_t len)
|
|||||||
_request->write(body, len);
|
_request->write(body, len);
|
||||||
_send();
|
_send();
|
||||||
|
|
||||||
_unlock;
|
_AHTTP_unlock;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -346,7 +347,7 @@ bool AsyncHTTPRequest::send(xbuf* body, size_t len)
|
|||||||
|
|
||||||
if ( ! _buildRequest())
|
if ( ! _buildRequest())
|
||||||
{
|
{
|
||||||
_unlock;
|
_AHTTP_unlock;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -354,7 +355,7 @@ bool AsyncHTTPRequest::send(xbuf* body, size_t len)
|
|||||||
_request->write(body, len);
|
_request->write(body, len);
|
||||||
_send();
|
_send();
|
||||||
|
|
||||||
_unlock;
|
_AHTTP_unlock;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -373,7 +374,7 @@ void AsyncHTTPRequest::abort()
|
|||||||
|
|
||||||
_client->abort();
|
_client->abort();
|
||||||
|
|
||||||
_unlock;
|
_AHTTP_unlock;
|
||||||
}
|
}
|
||||||
//**************************************************************************************************************
|
//**************************************************************************************************************
|
||||||
reqStates AsyncHTTPRequest::readyState()
|
reqStates AsyncHTTPRequest::readyState()
|
||||||
@ -398,7 +399,7 @@ String AsyncHTTPRequest::responseText()
|
|||||||
{
|
{
|
||||||
AHTTP_LOGDEBUG("responseText() no data");
|
AHTTP_LOGDEBUG("responseText() no data");
|
||||||
|
|
||||||
_unlock;
|
_AHTTP_unlock;
|
||||||
|
|
||||||
return String();
|
return String();
|
||||||
}
|
}
|
||||||
@ -413,7 +414,7 @@ String AsyncHTTPRequest::responseText()
|
|||||||
_HTTPcode = HTTPCODE_TOO_LESS_RAM;
|
_HTTPcode = HTTPCODE_TOO_LESS_RAM;
|
||||||
_client->abort();
|
_client->abort();
|
||||||
|
|
||||||
_unlock;
|
_AHTTP_unlock;
|
||||||
|
|
||||||
return String();
|
return String();
|
||||||
}
|
}
|
||||||
@ -423,7 +424,7 @@ String AsyncHTTPRequest::responseText()
|
|||||||
|
|
||||||
AHTTP_LOGDEBUG3("responseText(char)", localString.substring(0, 16).c_str(), ", avail =", avail);
|
AHTTP_LOGDEBUG3("responseText(char)", localString.substring(0, 16).c_str(), ", avail =", avail);
|
||||||
|
|
||||||
_unlock;
|
_AHTTP_unlock;
|
||||||
|
|
||||||
return localString;
|
return localString;
|
||||||
}
|
}
|
||||||
@ -447,7 +448,7 @@ size_t AsyncHTTPRequest::responseRead(uint8_t* buf, size_t len)
|
|||||||
|
|
||||||
_contentRead += avail;
|
_contentRead += avail;
|
||||||
|
|
||||||
_unlock;
|
_AHTTP_unlock;
|
||||||
|
|
||||||
return avail;
|
return avail;
|
||||||
}
|
}
|
||||||
@ -853,7 +854,7 @@ void AsyncHTTPRequest::_onConnect(AsyncClient* client)
|
|||||||
|
|
||||||
if (!_response)
|
if (!_response)
|
||||||
{
|
{
|
||||||
_unlock;
|
_AHTTP_unlock;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -879,7 +880,7 @@ void AsyncHTTPRequest::_onConnect(AsyncClient* client)
|
|||||||
|
|
||||||
_lastActivity = millis();
|
_lastActivity = millis();
|
||||||
|
|
||||||
_unlock;
|
_AHTTP_unlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
//**************************************************************************************************************
|
//**************************************************************************************************************
|
||||||
@ -900,7 +901,7 @@ void AsyncHTTPRequest::_onPoll(AsyncClient* client)
|
|||||||
_onDataCB(_onDataCBarg, this, available());
|
_onDataCB(_onDataCBarg, this, available());
|
||||||
}
|
}
|
||||||
|
|
||||||
_unlock;
|
_AHTTP_unlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
//**************************************************************************************************************
|
//**************************************************************************************************************
|
||||||
@ -941,7 +942,7 @@ void AsyncHTTPRequest::_onDisconnect(AsyncClient* client)
|
|||||||
_lastActivity = 0;
|
_lastActivity = 0;
|
||||||
_setReadyState(readyStateDone);
|
_setReadyState(readyStateDone);
|
||||||
|
|
||||||
_unlock;
|
_AHTTP_unlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
//**************************************************************************************************************
|
//**************************************************************************************************************
|
||||||
@ -969,7 +970,7 @@ void AsyncHTTPRequest::_onData(void* Vbuf, size_t len)
|
|||||||
{
|
{
|
||||||
if ( ! _collectHeaders())
|
if ( ! _collectHeaders())
|
||||||
{
|
{
|
||||||
_unlock;
|
_AHTTP_unlock;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1009,7 +1010,7 @@ void AsyncHTTPRequest::_onData(void* Vbuf, size_t len)
|
|||||||
_onDataCB(_onDataCBarg, this, available());
|
_onDataCB(_onDataCBarg, this, available());
|
||||||
}
|
}
|
||||||
|
|
||||||
_unlock;
|
_AHTTP_unlock;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1294,7 +1295,7 @@ String AsyncHTTPRequest::headers()
|
|||||||
|
|
||||||
_response += "\r\n";
|
_response += "\r\n";
|
||||||
|
|
||||||
_unlock;
|
_AHTTP_unlock;
|
||||||
|
|
||||||
return _response;
|
return _response;
|
||||||
}
|
}
|
||||||
@ -1354,7 +1355,7 @@ AsyncHTTPRequest::header* AsyncHTTPRequest::_addHeader(const char* name, const
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
_unlock;
|
_AHTTP_unlock;
|
||||||
|
|
||||||
return hdr->next;
|
return hdr->next;
|
||||||
}
|
}
|
||||||
@ -1374,7 +1375,7 @@ AsyncHTTPRequest::header* AsyncHTTPRequest::_getHeader(const char* name)
|
|||||||
hdr = hdr->next;
|
hdr = hdr->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
_unlock;
|
_AHTTP_unlock;
|
||||||
|
|
||||||
return hdr;
|
return hdr;
|
||||||
}
|
}
|
||||||
@ -1394,7 +1395,7 @@ AsyncHTTPRequest::header* AsyncHTTPRequest::_getHeader(int ndx)
|
|||||||
hdr = hdr->next;
|
hdr = hdr->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
_unlock;
|
_AHTTP_unlock;
|
||||||
|
|
||||||
return hdr;
|
return hdr;
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
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.1.1
|
Version: 1.1.2
|
||||||
|
|
||||||
Version Modified By Date Comments
|
Version Modified By Date Comments
|
||||||
------- ----------- ---------- -----------
|
------- ----------- ---------- -----------
|
||||||
@ -26,11 +26,15 @@
|
|||||||
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
|
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
|
||||||
1.1.0 K Hoang 23/12/2020 Add HTTP PUT, PATCH, DELETE and HEAD methods
|
1.1.0 K Hoang 23/12/2020 Add HTTP PUT, PATCH, DELETE and HEAD methods
|
||||||
1.1.1 K Hoang 24/12/2020 Prevent crash if request and/or method not correct.
|
1.1.1 K Hoang 24/12/2020 Prevent crash if request and/or method not correct.
|
||||||
|
1.1.2 K Hoang 11/02/2021 Rename _lock and _unlock to avoid conflict with AsyncWebServer library
|
||||||
*****************************************************************************************************************************/
|
*****************************************************************************************************************************/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION "AsyncHTTPRequest_Generic v1.1.1"
|
#ifndef ASYNC_HTTP_REQUEST_GENERIC_H
|
||||||
|
#define ASYNC_HTTP_REQUEST_GENERIC_H
|
||||||
|
|
||||||
|
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION "AsyncHTTPRequest_Generic v1.1.2"
|
||||||
|
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
|
||||||
@ -59,8 +63,8 @@
|
|||||||
#define MUTEX_LOCK_NR if (xSemaphoreTakeRecursive(threadLock,portMAX_DELAY) != pdTRUE) { return;}
|
#define MUTEX_LOCK_NR if (xSemaphoreTakeRecursive(threadLock,portMAX_DELAY) != pdTRUE) { return;}
|
||||||
#define MUTEX_LOCK(returnVal) if (xSemaphoreTakeRecursive(threadLock,portMAX_DELAY) != pdTRUE) { return returnVal;}
|
#define MUTEX_LOCK(returnVal) if (xSemaphoreTakeRecursive(threadLock,portMAX_DELAY) != pdTRUE) { return returnVal;}
|
||||||
|
|
||||||
#define _lock xSemaphoreTakeRecursive(threadLock,portMAX_DELAY)
|
#define _AHTTP_lock xSemaphoreTakeRecursive(threadLock,portMAX_DELAY)
|
||||||
#define _unlock xSemaphoreGiveRecursive(threadLock)
|
#define _AHTTP_unlock xSemaphoreGiveRecursive(threadLock)
|
||||||
|
|
||||||
#elif ESP8266
|
#elif ESP8266
|
||||||
|
|
||||||
@ -69,8 +73,8 @@
|
|||||||
#define MUTEX_LOCK_NR
|
#define MUTEX_LOCK_NR
|
||||||
#define MUTEX_LOCK(returnVal)
|
#define MUTEX_LOCK(returnVal)
|
||||||
|
|
||||||
#define _lock
|
#define _AHTTP_lock
|
||||||
#define _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(STM32F7) || \
|
||||||
defined(STM32L0) || defined(STM32L1) || defined(STM32L4) || defined(STM32H7) ||defined(STM32G0) || defined(STM32G4) || \
|
defined(STM32L0) || defined(STM32L1) || defined(STM32L4) || defined(STM32H7) ||defined(STM32G0) || defined(STM32G4) || \
|
||||||
@ -80,8 +84,8 @@
|
|||||||
|
|
||||||
#define MUTEX_LOCK_NR
|
#define MUTEX_LOCK_NR
|
||||||
#define MUTEX_LOCK(returnVal)
|
#define MUTEX_LOCK(returnVal)
|
||||||
#define _lock
|
#define _AHTTP_lock
|
||||||
#define _unlock
|
#define _AHTTP_unlock
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -297,6 +301,6 @@ class AsyncHTTPRequest
|
|||||||
bool _collectHeaders();
|
bool _collectHeaders();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#endif // ASYNC_HTTP_REQUEST_GENERIC_H
|
||||||
|
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
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.1.1
|
Version: 1.1.2
|
||||||
|
|
||||||
Version Modified By Date Comments
|
Version Modified By Date Comments
|
||||||
------- ----------- ---------- -----------
|
------- ----------- ---------- -----------
|
||||||
@ -26,6 +26,7 @@
|
|||||||
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
|
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
|
||||||
1.1.0 K Hoang 23/12/2020 Add HTTP PUT, PATCH, DELETE and HEAD methods
|
1.1.0 K Hoang 23/12/2020 Add HTTP PUT, PATCH, DELETE and HEAD methods
|
||||||
1.1.1 K Hoang 24/12/2020 Prevent crash if request and/or method not correct.
|
1.1.1 K Hoang 24/12/2020 Prevent crash if request and/or method not correct.
|
||||||
|
1.1.2 K Hoang 11/02/2021 Rename _lock and _unlock to avoid conflict with AsyncWebServer library
|
||||||
*****************************************************************************************************************************/
|
*****************************************************************************************************************************/
|
||||||
|
|
||||||
#include "utility/xbuf.h"
|
#include "utility/xbuf.h"
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
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.1.1
|
Version: 1.1.2
|
||||||
|
|
||||||
Version Modified By Date Comments
|
Version Modified By Date Comments
|
||||||
------- ----------- ---------- -----------
|
------- ----------- ---------- -----------
|
||||||
@ -26,6 +26,7 @@
|
|||||||
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
|
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
|
||||||
1.1.0 K Hoang 23/12/2020 Add HTTP PUT, PATCH, DELETE and HEAD methods
|
1.1.0 K Hoang 23/12/2020 Add HTTP PUT, PATCH, DELETE and HEAD methods
|
||||||
1.1.1 K Hoang 24/12/2020 Prevent crash if request and/or method not correct.
|
1.1.1 K Hoang 24/12/2020 Prevent crash if request and/or method not correct.
|
||||||
|
1.1.2 K Hoang 11/02/2021 Rename _lock and _unlock to avoid conflict with AsyncWebServer library
|
||||||
*****************************************************************************************************************************/
|
*****************************************************************************************************************************/
|
||||||
|
|
||||||
/********************************************************************************************
|
/********************************************************************************************
|
||||||
@ -48,6 +49,9 @@
|
|||||||
********************************************************************************************/
|
********************************************************************************************/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef XBUF_H
|
||||||
|
#define XBUF_H
|
||||||
|
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
|
||||||
struct xseg
|
struct xseg
|
||||||
@ -149,5 +153,6 @@ class xbuf: public Print
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#include "utility/xbuf_Impl.h"
|
|
||||||
|
#endif // XBUF_H
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
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.1.1
|
Version: 1.1.2
|
||||||
|
|
||||||
Version Modified By Date Comments
|
Version Modified By Date Comments
|
||||||
------- ----------- ---------- -----------
|
------- ----------- ---------- -----------
|
||||||
@ -26,10 +26,14 @@
|
|||||||
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
|
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
|
||||||
1.1.0 K Hoang 23/12/2020 Add HTTP PUT, PATCH, DELETE and HEAD methods
|
1.1.0 K Hoang 23/12/2020 Add HTTP PUT, PATCH, DELETE and HEAD methods
|
||||||
1.1.1 K Hoang 24/12/2020 Prevent crash if request and/or method not correct.
|
1.1.1 K Hoang 24/12/2020 Prevent crash if request and/or method not correct.
|
||||||
|
1.1.2 K Hoang 11/02/2021 Rename _lock and _unlock to avoid conflict with AsyncWebServer library
|
||||||
*****************************************************************************************************************************/
|
*****************************************************************************************************************************/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef ASYNC_HTTP_REQUEST_DEBUG_GENERIC_H
|
||||||
|
#define ASYNC_HTTP_REQUEST_DEBUG_GENERIC_H
|
||||||
|
|
||||||
#ifdef ASYNC_HTTP_DEBUG_PORT
|
#ifdef ASYNC_HTTP_DEBUG_PORT
|
||||||
#define A_DBG_PORT ASYNC_HTTP_DEBUG_PORT
|
#define A_DBG_PORT ASYNC_HTTP_DEBUG_PORT
|
||||||
#else
|
#else
|
||||||
@ -71,3 +75,5 @@
|
|||||||
#define AHTTP_LOGDEBUG2(x,y,z) if(_ASYNC_HTTP_LOGLEVEL_>3) { A_DBG_PORT.print("[AHTTP] "); A_DBG_PORT.print(x); A_DBG_PORT.print(" "); A_DBG_PORT.print(y); A_DBG_PORT.print(" "); A_DBG_PORT.println(z); }
|
#define AHTTP_LOGDEBUG2(x,y,z) if(_ASYNC_HTTP_LOGLEVEL_>3) { A_DBG_PORT.print("[AHTTP] "); A_DBG_PORT.print(x); A_DBG_PORT.print(" "); A_DBG_PORT.print(y); A_DBG_PORT.print(" "); A_DBG_PORT.println(z); }
|
||||||
#define AHTTP_LOGDEBUG3(x,y,z,w) if(_ASYNC_HTTP_LOGLEVEL_>3) { A_DBG_PORT.print("[AHTTP] "); A_DBG_PORT.print(x); A_DBG_PORT.print(" "); A_DBG_PORT.print(y); A_DBG_PORT.print(" "); A_DBG_PORT.print(z); A_DBG_PORT.print(" "); A_DBG_PORT.println(w); }
|
#define AHTTP_LOGDEBUG3(x,y,z,w) if(_ASYNC_HTTP_LOGLEVEL_>3) { A_DBG_PORT.print("[AHTTP] "); A_DBG_PORT.print(x); A_DBG_PORT.print(" "); A_DBG_PORT.print(y); A_DBG_PORT.print(" "); A_DBG_PORT.print(z); A_DBG_PORT.print(" "); A_DBG_PORT.println(w); }
|
||||||
|
|
||||||
|
#endif // ASYNC_HTTP_REQUEST_DEBUG_GENERIC_H
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
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.1.1
|
Version: 1.1.2
|
||||||
|
|
||||||
Version Modified By Date Comments
|
Version Modified By Date Comments
|
||||||
------- ----------- ---------- -----------
|
------- ----------- ---------- -----------
|
||||||
@ -26,11 +26,15 @@
|
|||||||
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
|
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
|
||||||
1.1.0 K Hoang 23/12/2020 Add HTTP PUT, PATCH, DELETE and HEAD methods
|
1.1.0 K Hoang 23/12/2020 Add HTTP PUT, PATCH, DELETE and HEAD methods
|
||||||
1.1.1 K Hoang 24/12/2020 Prevent crash if request and/or method not correct.
|
1.1.1 K Hoang 24/12/2020 Prevent crash if request and/or method not correct.
|
||||||
|
1.1.2 K Hoang 11/02/2021 Rename _lock and _unlock to avoid conflict with AsyncWebServer library
|
||||||
*****************************************************************************************************************************/
|
*****************************************************************************************************************************/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION "AsyncHTTPRequest_Generic v1.1.1"
|
#ifndef ASYNC_HTTP_REQUEST_GENERIC_H
|
||||||
|
#define ASYNC_HTTP_REQUEST_GENERIC_H
|
||||||
|
|
||||||
|
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION "AsyncHTTPRequest_Generic v1.1.2"
|
||||||
|
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
|
||||||
@ -59,8 +63,8 @@
|
|||||||
#define MUTEX_LOCK_NR if (xSemaphoreTakeRecursive(threadLock,portMAX_DELAY) != pdTRUE) { return;}
|
#define MUTEX_LOCK_NR if (xSemaphoreTakeRecursive(threadLock,portMAX_DELAY) != pdTRUE) { return;}
|
||||||
#define MUTEX_LOCK(returnVal) if (xSemaphoreTakeRecursive(threadLock,portMAX_DELAY) != pdTRUE) { return returnVal;}
|
#define MUTEX_LOCK(returnVal) if (xSemaphoreTakeRecursive(threadLock,portMAX_DELAY) != pdTRUE) { return returnVal;}
|
||||||
|
|
||||||
#define _lock xSemaphoreTakeRecursive(threadLock,portMAX_DELAY)
|
#define _AHTTP_lock xSemaphoreTakeRecursive(threadLock,portMAX_DELAY)
|
||||||
#define _unlock xSemaphoreGiveRecursive(threadLock)
|
#define _AHTTP_unlock xSemaphoreGiveRecursive(threadLock)
|
||||||
|
|
||||||
#elif ESP8266
|
#elif ESP8266
|
||||||
|
|
||||||
@ -69,8 +73,8 @@
|
|||||||
#define MUTEX_LOCK_NR
|
#define MUTEX_LOCK_NR
|
||||||
#define MUTEX_LOCK(returnVal)
|
#define MUTEX_LOCK(returnVal)
|
||||||
|
|
||||||
#define _lock
|
#define _AHTTP_lock
|
||||||
#define _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(STM32F7) || \
|
||||||
defined(STM32L0) || defined(STM32L1) || defined(STM32L4) || defined(STM32H7) ||defined(STM32G0) || defined(STM32G4) || \
|
defined(STM32L0) || defined(STM32L1) || defined(STM32L4) || defined(STM32H7) ||defined(STM32G0) || defined(STM32G4) || \
|
||||||
@ -80,8 +84,8 @@
|
|||||||
|
|
||||||
#define MUTEX_LOCK_NR
|
#define MUTEX_LOCK_NR
|
||||||
#define MUTEX_LOCK(returnVal)
|
#define MUTEX_LOCK(returnVal)
|
||||||
#define _lock
|
#define _AHTTP_lock
|
||||||
#define _unlock
|
#define _AHTTP_unlock
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -220,8 +224,11 @@ class AsyncHTTPRequest
|
|||||||
size_t responseLength(); // indicated response length or sum of chunks to date
|
size_t responseLength(); // indicated response length or sum of chunks to date
|
||||||
int responseHTTPcode(); // HTTP response code or (negative) error code
|
int responseHTTPcode(); // HTTP response code or (negative) error code
|
||||||
String responseText(); // response (whole* or partial* as string)
|
String responseText(); // response (whole* or partial* as string)
|
||||||
|
|
||||||
|
char* responseLongText(); // response long (whole* or partial* as string)
|
||||||
|
|
||||||
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
|
||||||
//___________________________________________________________________________________________________________________________________
|
//___________________________________________________________________________________________________________________________________
|
||||||
|
|
||||||
@ -299,4 +306,4 @@ class AsyncHTTPRequest
|
|||||||
|
|
||||||
#include "AsyncHTTPRequest_Impl_Generic.h"
|
#include "AsyncHTTPRequest_Impl_Generic.h"
|
||||||
|
|
||||||
|
#endif // ASYNC_HTTP_REQUEST_GENERIC_H
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
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.1.1
|
Version: 1.1.2
|
||||||
|
|
||||||
Version Modified By Date Comments
|
Version Modified By Date Comments
|
||||||
------- ----------- ---------- -----------
|
------- ----------- ---------- -----------
|
||||||
@ -26,10 +26,14 @@
|
|||||||
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
|
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
|
||||||
1.1.0 K Hoang 23/12/2020 Add HTTP PUT, PATCH, DELETE and HEAD methods
|
1.1.0 K Hoang 23/12/2020 Add HTTP PUT, PATCH, DELETE and HEAD methods
|
||||||
1.1.1 K Hoang 24/12/2020 Prevent crash if request and/or method not correct.
|
1.1.1 K Hoang 24/12/2020 Prevent crash if request and/or method not correct.
|
||||||
|
1.1.2 K Hoang 11/02/2021 Rename _lock and _unlock to avoid conflict with AsyncWebServer library
|
||||||
*****************************************************************************************************************************/
|
*****************************************************************************************************************************/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef ASYNC_HTTP_REQUEST_GENERIC_IMPL_H
|
||||||
|
#define ASYNC_HTTP_REQUEST_GENERIC_IMPL_H
|
||||||
|
|
||||||
#define CANT_SEND_BAD_REQUEST F("Can't send() bad request")
|
#define CANT_SEND_BAD_REQUEST F("Can't send() bad request")
|
||||||
|
|
||||||
//**************************************************************************************************************
|
//**************************************************************************************************************
|
||||||
@ -93,6 +97,8 @@ bool AsyncHTTPRequest::open(const char* method, const char* URL)
|
|||||||
|
|
||||||
if (_readyState != readyStateUnsent && _readyState != readyStateDone)
|
if (_readyState != readyStateUnsent && _readyState != readyStateDone)
|
||||||
{
|
{
|
||||||
|
AHTTP_LOGDEBUG("open: not ready");
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -145,17 +151,23 @@ bool AsyncHTTPRequest::open(const char* method, const char* URL)
|
|||||||
//////
|
//////
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
AHTTP_LOGDEBUG("open: Bad method");
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!_parseURL(URL))
|
if (!_parseURL(URL))
|
||||||
{
|
{
|
||||||
|
AHTTP_LOGDEBUG("open: error parsing URL");
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( _client && _client->connected() && (strcmp(_URL->host, _connectedHost) != 0 || _URL->port != _connectedPort))
|
if ( _client && _client->connected() && (strcmp(_URL->host, _connectedHost) != 0 || _URL->port != _connectedPort))
|
||||||
{
|
{
|
||||||
|
AHTTP_LOGDEBUG("open: not connected");
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -173,11 +185,17 @@ bool AsyncHTTPRequest::open(const char* method, const char* URL)
|
|||||||
// New in v1.1.1
|
// New in v1.1.1
|
||||||
_requestReadyToSend = true;
|
_requestReadyToSend = true;
|
||||||
//////
|
//////
|
||||||
|
|
||||||
|
AHTTP_LOGDEBUG1("open: conneting to hostname =", hostName);
|
||||||
|
|
||||||
return _connect();
|
return _connect();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
AHTTP_LOGDEBUG("open: error alloc");
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//**************************************************************************************************************
|
//**************************************************************************************************************
|
||||||
void AsyncHTTPRequest::onReadyStateChange(readyStateChangeCB cb, void* arg)
|
void AsyncHTTPRequest::onReadyStateChange(readyStateChangeCB cb, void* arg)
|
||||||
@ -216,7 +234,7 @@ bool AsyncHTTPRequest::send()
|
|||||||
|
|
||||||
_send();
|
_send();
|
||||||
|
|
||||||
_unlock;
|
_AHTTP_unlock;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -242,7 +260,7 @@ bool AsyncHTTPRequest::send(String body)
|
|||||||
|
|
||||||
if ( ! _buildRequest())
|
if ( ! _buildRequest())
|
||||||
{
|
{
|
||||||
_unlock;
|
_AHTTP_unlock;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -250,7 +268,7 @@ bool AsyncHTTPRequest::send(String body)
|
|||||||
_request->write(body);
|
_request->write(body);
|
||||||
_send();
|
_send();
|
||||||
|
|
||||||
_unlock;
|
_AHTTP_unlock;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -276,7 +294,7 @@ bool AsyncHTTPRequest::send(const char* body)
|
|||||||
|
|
||||||
if ( ! _buildRequest())
|
if ( ! _buildRequest())
|
||||||
{
|
{
|
||||||
_unlock;
|
_AHTTP_unlock;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -284,7 +302,7 @@ bool AsyncHTTPRequest::send(const char* body)
|
|||||||
_request->write(body);
|
_request->write(body);
|
||||||
_send();
|
_send();
|
||||||
|
|
||||||
_unlock;
|
_AHTTP_unlock;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -310,7 +328,7 @@ bool AsyncHTTPRequest::send(const uint8_t* body, size_t len)
|
|||||||
|
|
||||||
if ( ! _buildRequest())
|
if ( ! _buildRequest())
|
||||||
{
|
{
|
||||||
_unlock;
|
_AHTTP_unlock;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -318,7 +336,7 @@ bool AsyncHTTPRequest::send(const uint8_t* body, size_t len)
|
|||||||
_request->write(body, len);
|
_request->write(body, len);
|
||||||
_send();
|
_send();
|
||||||
|
|
||||||
_unlock;
|
_AHTTP_unlock;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -344,7 +362,7 @@ bool AsyncHTTPRequest::send(xbuf* body, size_t len)
|
|||||||
|
|
||||||
if ( ! _buildRequest())
|
if ( ! _buildRequest())
|
||||||
{
|
{
|
||||||
_unlock;
|
_AHTTP_unlock;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -352,7 +370,7 @@ bool AsyncHTTPRequest::send(xbuf* body, size_t len)
|
|||||||
_request->write(body, len);
|
_request->write(body, len);
|
||||||
_send();
|
_send();
|
||||||
|
|
||||||
_unlock;
|
_AHTTP_unlock;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -371,7 +389,7 @@ void AsyncHTTPRequest::abort()
|
|||||||
|
|
||||||
_client->abort();
|
_client->abort();
|
||||||
|
|
||||||
_unlock;
|
_AHTTP_unlock;
|
||||||
}
|
}
|
||||||
//**************************************************************************************************************
|
//**************************************************************************************************************
|
||||||
reqStates AsyncHTTPRequest::readyState()
|
reqStates AsyncHTTPRequest::readyState()
|
||||||
@ -396,7 +414,7 @@ String AsyncHTTPRequest::responseText()
|
|||||||
{
|
{
|
||||||
AHTTP_LOGDEBUG("responseText() no data");
|
AHTTP_LOGDEBUG("responseText() no data");
|
||||||
|
|
||||||
_unlock;
|
_AHTTP_unlock;
|
||||||
|
|
||||||
return String();
|
return String();
|
||||||
}
|
}
|
||||||
@ -411,7 +429,7 @@ String AsyncHTTPRequest::responseText()
|
|||||||
_HTTPcode = HTTPCODE_TOO_LESS_RAM;
|
_HTTPcode = HTTPCODE_TOO_LESS_RAM;
|
||||||
_client->abort();
|
_client->abort();
|
||||||
|
|
||||||
_unlock;
|
_AHTTP_unlock;
|
||||||
|
|
||||||
return String();
|
return String();
|
||||||
}
|
}
|
||||||
@ -419,13 +437,61 @@ String AsyncHTTPRequest::responseText()
|
|||||||
localString = _response->readString(avail);
|
localString = _response->readString(avail);
|
||||||
_contentRead += localString.length();
|
_contentRead += localString.length();
|
||||||
|
|
||||||
AHTTP_LOGDEBUG3("responseText(char)", localString.substring(0, 16).c_str(), ", avail =", avail);
|
//AHTTP_LOGDEBUG3("responseText(char)", localString.substring(0, 16).c_str(), ", avail =", avail);
|
||||||
|
AHTTP_LOGDEBUG3("responseText(char)", localString, ", avail =", avail);
|
||||||
|
|
||||||
_unlock;
|
_AHTTP_unlock;
|
||||||
|
|
||||||
return localString;
|
return localString;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//**************************************************************************************************************
|
||||||
|
|
||||||
|
#if 1
|
||||||
|
|
||||||
|
#if (ESP32)
|
||||||
|
#define GLOBAL_STR_LEN (32 * 1024)
|
||||||
|
#elif (ESP8266)
|
||||||
|
#define GLOBAL_STR_LEN (16 * 1024)
|
||||||
|
#else
|
||||||
|
#define GLOBAL_STR_LEN (4 * 1024)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
char globalLongString[GLOBAL_STR_LEN + 1];
|
||||||
|
|
||||||
|
char* AsyncHTTPRequest::responseLongText()
|
||||||
|
{
|
||||||
|
AHTTP_LOGDEBUG("responseLongText()");
|
||||||
|
|
||||||
|
MUTEX_LOCK(NULL)
|
||||||
|
|
||||||
|
if ( ! _response || _readyState < readyStateLoading || ! available())
|
||||||
|
{
|
||||||
|
AHTTP_LOGDEBUG("responseText() no data");
|
||||||
|
|
||||||
|
_AHTTP_unlock;
|
||||||
|
|
||||||
|
//return String();
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// String localString;
|
||||||
|
size_t avail = available();
|
||||||
|
size_t lenToCopy = (avail <= GLOBAL_STR_LEN) ? avail : GLOBAL_STR_LEN;
|
||||||
|
|
||||||
|
strncpy(globalLongString, _response->readString(avail).c_str(), lenToCopy );
|
||||||
|
globalLongString[ lenToCopy + 1 ] = 0;
|
||||||
|
|
||||||
|
_contentRead += _response->readString(avail).length();
|
||||||
|
|
||||||
|
AHTTP_LOGDEBUG3("responseLongText(char)", globalLongString, ", avail =", avail);
|
||||||
|
|
||||||
|
_AHTTP_unlock;
|
||||||
|
|
||||||
|
return globalLongString;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
//**************************************************************************************************************
|
//**************************************************************************************************************
|
||||||
size_t AsyncHTTPRequest::responseRead(uint8_t* buf, size_t len)
|
size_t AsyncHTTPRequest::responseRead(uint8_t* buf, size_t len)
|
||||||
{
|
{
|
||||||
@ -445,7 +511,7 @@ size_t AsyncHTTPRequest::responseRead(uint8_t* buf, size_t len)
|
|||||||
|
|
||||||
_contentRead += avail;
|
_contentRead += avail;
|
||||||
|
|
||||||
_unlock;
|
_AHTTP_unlock;
|
||||||
|
|
||||||
return avail;
|
return avail;
|
||||||
}
|
}
|
||||||
@ -847,11 +913,18 @@ void AsyncHTTPRequest::_onConnect(AsyncClient* client)
|
|||||||
_client = client;
|
_client = client;
|
||||||
_setReadyState(readyStateOpened);
|
_setReadyState(readyStateOpened);
|
||||||
|
|
||||||
|
// KH test
|
||||||
_response = new xbuf;
|
_response = new xbuf;
|
||||||
|
//_response = new xbuf(256);
|
||||||
|
//////
|
||||||
|
|
||||||
if (!_response)
|
if (!_response)
|
||||||
{
|
{
|
||||||
_unlock;
|
_AHTTP_unlock;
|
||||||
|
|
||||||
|
// KH, to remove
|
||||||
|
AHTTP_LOGDEBUG("_onConnect: Can't new _responser");
|
||||||
|
///////
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -862,11 +935,17 @@ void AsyncHTTPRequest::_onConnect(AsyncClient* client)
|
|||||||
|
|
||||||
_client->onAck([](void* obj, AsyncClient * client, size_t len, uint32_t time)
|
_client->onAck([](void* obj, AsyncClient * client, size_t len, uint32_t time)
|
||||||
{
|
{
|
||||||
|
(void) client;
|
||||||
|
(void) len;
|
||||||
|
(void) time;
|
||||||
|
|
||||||
((AsyncHTTPRequest*)(obj))->_send();
|
((AsyncHTTPRequest*)(obj))->_send();
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
_client->onData([](void* obj, AsyncClient * client, void* data, size_t len)
|
_client->onData([](void* obj, AsyncClient * client, void* data, size_t len)
|
||||||
{
|
{
|
||||||
|
(void) client;
|
||||||
|
|
||||||
((AsyncHTTPRequest*)(obj))->_onData(data, len);
|
((AsyncHTTPRequest*)(obj))->_onData(data, len);
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
@ -877,12 +956,14 @@ void AsyncHTTPRequest::_onConnect(AsyncClient* client)
|
|||||||
|
|
||||||
_lastActivity = millis();
|
_lastActivity = millis();
|
||||||
|
|
||||||
_unlock;
|
_AHTTP_unlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
//**************************************************************************************************************
|
//**************************************************************************************************************
|
||||||
void AsyncHTTPRequest::_onPoll(AsyncClient* client)
|
void AsyncHTTPRequest::_onPoll(AsyncClient* client)
|
||||||
{
|
{
|
||||||
|
(void) client;
|
||||||
|
|
||||||
MUTEX_LOCK_NR
|
MUTEX_LOCK_NR
|
||||||
|
|
||||||
if (_timeout && (millis() - _lastActivity) > (_timeout * 1000))
|
if (_timeout && (millis() - _lastActivity) > (_timeout * 1000))
|
||||||
@ -898,12 +979,14 @@ void AsyncHTTPRequest::_onPoll(AsyncClient* client)
|
|||||||
_onDataCB(_onDataCBarg, this, available());
|
_onDataCB(_onDataCBarg, this, available());
|
||||||
}
|
}
|
||||||
|
|
||||||
_unlock;
|
_AHTTP_unlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
//**************************************************************************************************************
|
//**************************************************************************************************************
|
||||||
void AsyncHTTPRequest::_onError(AsyncClient* client, int8_t error)
|
void AsyncHTTPRequest::_onError(AsyncClient* client, int8_t error)
|
||||||
{
|
{
|
||||||
|
(void) client;
|
||||||
|
|
||||||
AHTTP_LOGDEBUG1("_onError handler error =", error);
|
AHTTP_LOGDEBUG1("_onError handler error =", error);
|
||||||
|
|
||||||
_HTTPcode = error;
|
_HTTPcode = error;
|
||||||
@ -912,6 +995,8 @@ void AsyncHTTPRequest::_onError(AsyncClient* client, int8_t error)
|
|||||||
//**************************************************************************************************************
|
//**************************************************************************************************************
|
||||||
void AsyncHTTPRequest::_onDisconnect(AsyncClient* client)
|
void AsyncHTTPRequest::_onDisconnect(AsyncClient* client)
|
||||||
{
|
{
|
||||||
|
(void) client;
|
||||||
|
|
||||||
AHTTP_LOGDEBUG("\n_onDisconnect handler");
|
AHTTP_LOGDEBUG("\n_onDisconnect handler");
|
||||||
|
|
||||||
MUTEX_LOCK_NR
|
MUTEX_LOCK_NR
|
||||||
@ -939,7 +1024,7 @@ void AsyncHTTPRequest::_onDisconnect(AsyncClient* client)
|
|||||||
_lastActivity = 0;
|
_lastActivity = 0;
|
||||||
_setReadyState(readyStateDone);
|
_setReadyState(readyStateDone);
|
||||||
|
|
||||||
_unlock;
|
_AHTTP_unlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
//**************************************************************************************************************
|
//**************************************************************************************************************
|
||||||
@ -955,6 +1040,11 @@ void AsyncHTTPRequest::_onData(void* Vbuf, size_t len)
|
|||||||
if (_chunks)
|
if (_chunks)
|
||||||
{
|
{
|
||||||
_chunks->write((uint8_t*)Vbuf, len);
|
_chunks->write((uint8_t*)Vbuf, len);
|
||||||
|
|
||||||
|
// KH, to remove
|
||||||
|
AHTTP_LOGDEBUG("_onData: _processChunks");
|
||||||
|
///////
|
||||||
|
|
||||||
_processChunks();
|
_processChunks();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -967,7 +1057,11 @@ void AsyncHTTPRequest::_onData(void* Vbuf, size_t len)
|
|||||||
{
|
{
|
||||||
if ( ! _collectHeaders())
|
if ( ! _collectHeaders())
|
||||||
{
|
{
|
||||||
_unlock;
|
_AHTTP_unlock;
|
||||||
|
|
||||||
|
// KH, to remove
|
||||||
|
AHTTP_LOGDEBUG("_onData: headers not complete");
|
||||||
|
///////
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1007,7 +1101,7 @@ void AsyncHTTPRequest::_onData(void* Vbuf, size_t len)
|
|||||||
_onDataCB(_onDataCBarg, this, available());
|
_onDataCB(_onDataCBarg, this, available());
|
||||||
}
|
}
|
||||||
|
|
||||||
_unlock;
|
_AHTTP_unlock;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1292,7 +1386,7 @@ String AsyncHTTPRequest::headers()
|
|||||||
|
|
||||||
_response += "\r\n";
|
_response += "\r\n";
|
||||||
|
|
||||||
_unlock;
|
_AHTTP_unlock;
|
||||||
|
|
||||||
return _response;
|
return _response;
|
||||||
}
|
}
|
||||||
@ -1352,7 +1446,7 @@ AsyncHTTPRequest::header* AsyncHTTPRequest::_addHeader(const char* name, const
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
_unlock;
|
_AHTTP_unlock;
|
||||||
|
|
||||||
return hdr->next;
|
return hdr->next;
|
||||||
}
|
}
|
||||||
@ -1372,7 +1466,7 @@ AsyncHTTPRequest::header* AsyncHTTPRequest::_getHeader(const char* name)
|
|||||||
hdr = hdr->next;
|
hdr = hdr->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
_unlock;
|
_AHTTP_unlock;
|
||||||
|
|
||||||
return hdr;
|
return hdr;
|
||||||
}
|
}
|
||||||
@ -1392,7 +1486,7 @@ AsyncHTTPRequest::header* AsyncHTTPRequest::_getHeader(int ndx)
|
|||||||
hdr = hdr->next;
|
hdr = hdr->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
_unlock;
|
_AHTTP_unlock;
|
||||||
|
|
||||||
return hdr;
|
return hdr;
|
||||||
}
|
}
|
||||||
@ -1417,3 +1511,5 @@ char* AsyncHTTPRequest::_charstar(const __FlashStringHelper * str)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif // ASYNC_HTTP_REQUEST_GENERIC_IMPL_H
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
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.1.1
|
Version: 1.1.2
|
||||||
|
|
||||||
Version Modified By Date Comments
|
Version Modified By Date Comments
|
||||||
------- ----------- ---------- -----------
|
------- ----------- ---------- -----------
|
||||||
@ -26,6 +26,7 @@
|
|||||||
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
|
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
|
||||||
1.1.0 K Hoang 23/12/2020 Add HTTP PUT, PATCH, DELETE and HEAD methods
|
1.1.0 K Hoang 23/12/2020 Add HTTP PUT, PATCH, DELETE and HEAD methods
|
||||||
1.1.1 K Hoang 24/12/2020 Prevent crash if request and/or method not correct.
|
1.1.1 K Hoang 24/12/2020 Prevent crash if request and/or method not correct.
|
||||||
|
1.1.2 K Hoang 11/02/2021 Rename _lock and _unlock to avoid conflict with AsyncWebServer library
|
||||||
*****************************************************************************************************************************/
|
*****************************************************************************************************************************/
|
||||||
|
|
||||||
/********************************************************************************************
|
/********************************************************************************************
|
||||||
@ -48,6 +49,9 @@
|
|||||||
********************************************************************************************/
|
********************************************************************************************/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef XBUF_H
|
||||||
|
#define XBUF_H
|
||||||
|
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
|
||||||
struct xseg
|
struct xseg
|
||||||
@ -151,3 +155,5 @@ class xbuf: public Print
|
|||||||
|
|
||||||
#include "utility/xbuf_Impl.h"
|
#include "utility/xbuf_Impl.h"
|
||||||
|
|
||||||
|
#endif // XBUF_H
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
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.1.1
|
Version: 1.1.2
|
||||||
|
|
||||||
Version Modified By Date Comments
|
Version Modified By Date Comments
|
||||||
------- ----------- ---------- -----------
|
------- ----------- ---------- -----------
|
||||||
@ -26,10 +26,14 @@
|
|||||||
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
|
1.0.2 K Hoang 09/11/2020 Make Mutex Lock and delete more reliable and error-proof
|
||||||
1.1.0 K Hoang 23/12/2020 Add HTTP PUT, PATCH, DELETE and HEAD methods
|
1.1.0 K Hoang 23/12/2020 Add HTTP PUT, PATCH, DELETE and HEAD methods
|
||||||
1.1.1 K Hoang 24/12/2020 Prevent crash if request and/or method not correct.
|
1.1.1 K Hoang 24/12/2020 Prevent crash if request and/or method not correct.
|
||||||
|
1.1.2 K Hoang 11/02/2021 Rename _lock and _unlock to avoid conflict with AsyncWebServer library
|
||||||
*****************************************************************************************************************************/
|
*****************************************************************************************************************************/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef XBUF_IMPL_H
|
||||||
|
#define XBUF_IMPL_H
|
||||||
|
|
||||||
xbuf::xbuf(const uint16_t segSize) : _head(nullptr), _tail(nullptr), _used(0), _free(0), _offset(0)
|
xbuf::xbuf(const uint16_t segSize) : _head(nullptr), _tail(nullptr), _used(0), _free(0), _offset(0)
|
||||||
{
|
{
|
||||||
_segSize = (segSize + 3) & -4;//((segSize + 3) >> 2) << 2;
|
_segSize = (segSize + 3) & -4;//((segSize + 3) >> 2) << 2;
|
||||||
@ -291,9 +295,17 @@ String xbuf::readString(int endPos)
|
|||||||
|
|
||||||
if ( ! result.reserve(endPos + 1))
|
if ( ! result.reserve(endPos + 1))
|
||||||
{
|
{
|
||||||
|
// KH, to remove
|
||||||
|
AHTTP_LOGDEBUG1("xbuf::readString: can't reserve size = ", endPos + 1);
|
||||||
|
///////
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// KH, to remove
|
||||||
|
AHTTP_LOGDEBUG1("xbuf::readString: Reserved size = ", endPos + 1);
|
||||||
|
///////
|
||||||
|
|
||||||
if (endPos > _used)
|
if (endPos > _used)
|
||||||
{
|
{
|
||||||
endPos = _used;
|
endPos = _used;
|
||||||
@ -365,6 +377,9 @@ void xbuf::addSeg()
|
|||||||
{
|
{
|
||||||
_tail->next = (xseg*) new uint32_t[_segSize / 4 + 1];
|
_tail->next = (xseg*) new uint32_t[_segSize / 4 + 1];
|
||||||
|
|
||||||
|
if (_tail->next == NULL)
|
||||||
|
AHTTP_LOGERROR("xbuf::addSeg: error new 1");
|
||||||
|
|
||||||
// KH, Must check NULL here
|
// KH, Must check NULL here
|
||||||
_tail = _tail->next;
|
_tail = _tail->next;
|
||||||
}
|
}
|
||||||
@ -372,6 +387,9 @@ void xbuf::addSeg()
|
|||||||
{
|
{
|
||||||
// KH, Must check NULL here
|
// KH, Must check NULL here
|
||||||
_tail = _head = (xseg*) new uint32_t[_segSize / 4 + 1];
|
_tail = _head = (xseg*) new uint32_t[_segSize / 4 + 1];
|
||||||
|
|
||||||
|
if (_tail == NULL)
|
||||||
|
AHTTP_LOGERROR("xbuf::addSeg: error new 2");
|
||||||
}
|
}
|
||||||
|
|
||||||
// KH, Must check NULL here
|
// KH, Must check NULL here
|
||||||
@ -399,3 +417,5 @@ void xbuf::remSeg()
|
|||||||
_offset = 0;
|
_offset = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif // XBUF_IMPL_H
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user