AsyncHTTPSRequest_Generic Library for ESP32, WT32_ETH01

arduino-library-badgeGitHub release

Why do we need this Async AsyncHTTPSRequest_Generic library

Features

  1. Asynchronous HTTPS Request library for ESP32, ESP32_S2, ESP32_C3 using built-in WiFi.
  2. Providing a subset of HTTPS.
  3. Relying on on AsyncTCP_SSL library for ESP32
  4. Methods similar in format and usage to XmlHTTPrequest in Javascript.

Supports

  1. GET, POST, PUT, PATCH, DELETE and HEAD
  2. Request and response headers
  3. Chunked response
  4. Single String response for short (<~5K) responses (heap permitting).
  5. Optional onData callback.
  6. Optional onReadyStatechange callback.

Principles of operation

This library adds a simple HTTPS layer on top of the AsyncTCP_SSL library to facilitate REST communication from a Client to a Server. The paradigm is similar to the XMLHttpRequest in Javascript, employing the notion of a ready-state progression through the transaction request.

Synchronization can be accomplished using callbacks on ready-state change, a callback on data receipt, or simply polling for ready-state change. Data retrieval can be incremental as received, or bulk retrieved when the transaction completes provided there is enough heap to buffer the entire response.

The underlying buffering uses a new xbuf class. It handles both character and binary data. Class xbuf uses a chain of small (64 byte) segments that are allocated and added to the tail as data is added and deallocated from the head as data is read, achieving the same result as a dynamic circular buffer limited only by the size of heap. The xbuf implements indexOf and readUntil functions.

For short transactions, buffer space should not be an issue. In fact, it can be more economical than other methods that use larger fixed length buffers. Data is acked when retrieved by the caller, so there is some limited flow control to limit heap usage for larger transfers.

Request and response headers are handled in the typical fashion.

Chunked responses are recognized and handled transparently.

This library is based on, modified from:

  1. Bob Lemaire's asyncHTTPrequest Library
  2. Khoi Hoang's AsyncHTTPRequest_Generic Library

Currently Supported Boards

1. ESP32 including ESP32_S2 and ESP32_C3



Debug Terminal Output Samples

1. AsyncHTTPSRequest_ESP on ESP32_DEV

Following is the debug terminal when running example AsyncHTTPSRequest_ESP on ESP32_DEV to demonstrate the operation of SSL Async HTTPS request, using AsyncTCP_SSL Library.

Starting AsyncHTTPSRequest_ESP using ESP32_DEV
AsyncTCP_SSL v1.1.0
AsyncHTTPSRequest_Generic v1.0.0
Connecting to WiFi SSID: HueNet1
.......
AsyncHTTPSRequest @ IP : 192.168.2.78

**************************************
abbreviation: EDT
client_ip: aaa.bbb.ccc.ddd
datetime: 2021-10-21T16:05:03.170256-04:00
day_of_week: 4
day_of_year: 294
dst: true
dst_from: 2021-03-14T07:00:00+00:00
dst_offset: 3600
dst_until: 2021-11-07T06:00:00+00:00
raw_offset: -18000
timezone: America/Toronto
unixtime: 1634846703
utc_datetime: 2021-10-21T20:05:03.170256+00:00
utc_offset: -04:00
week_number: 42
**************************************
HHHHHH
**************************************
abbreviation: EDT
client_ip: aaa.bbb.ccc.ddd
datetime: 2021-10-21T16:06:00.828056-04:00
day_of_week: 4
day_of_year: 294
dst: true
dst_from: 2021-03-14T07:00:00+00:00
dst_offset: 3600
dst_until: 2021-11-07T06:00:00+00:00
raw_offset: -18000
timezone: America/Toronto
unixtime: 1634846760
utc_datetime: 2021-10-21T20:06:00.828056+00:00
utc_offset: -04:00
week_number: 42
**************************************

Releases v1.1.0

  1. Add support to ESP32-based WT32_ETH01 using LAN8720 using either ESP32 core v1.0.6- or core v2.0.0+
  2. Add example for WT32_ETH01

Debug Terminal Output Samples

1. AsyncHTTPSRequest_WT32_ETH01 on WT32_ETH01 using ESP32 core v2.0.0

Following is the debug terminal when running example AsyncHTTPSRequest_WT32_ETH01 on WT32_ETH01 to demonstrate the operation of SSL Async HTTPS request, using AsyncTCP_SSL Library and ESP32 core v2.0.0

Starting AsyncHTTPSRequest_WT32_ETH01 using ESP32_DEV with ETH_PHY_LAN8720
WebServer_WT32_ETH01 v1.3.0 for core v2.0.0+
AsyncTCP_SSL v1.1.0
AsyncHTTPSRequest_Generic v1.1.0
ETH MAC: A8:03:2A:A1:61:73, IPv4: 192.168.2.82, FULL_DUPLEX, 100Mbps

HTTP WebClient is @ IP : 192.168.2.82

**************************************
abbreviation: EDT
client_ip: 216.154.33.167
datetime: 2021-10-23T16:21:32.159175-04:00
day_of_week: 6
day_of_year: 296
dst: true
dst_from: 2021-03-14T07:00:00+00:00
dst_offset: 3600
dst_until: 2021-11-07T06:00:00+00:00
raw_offset: -18000
timezone: America/Toronto
unixtime: 1635020492
utc_datetime: 2021-10-23T20:21:32.159175+00:00
utc_offset: -04:00
week_number: 42
**************************************

2. AsyncHTTPSRequest_WT32_ETH01 on WT32_ETH01 using ESP32 core v1.0.6

Following is the debug terminal when running example AsyncHTTPSRequest_WT32_ETH01 on WT32_ETH01 to demonstrate the operation of SSL Async HTTPS request, using AsyncTCP_SSL Library and ESP32 core v1.0.6

Starting AsyncHTTPSRequest_WT32_ETH01 using ESP32_DEV with ETH_PHY_LAN8720
WebServer_WT32_ETH01 v1.3.0 for core v1.0.6-
AsyncTCP_SSL v1.1.0
AsyncHTTPSRequest_Generic v1.1.0
ETH MAC: A8:03:2A:A1:61:73, IPv4: 192.168.2.232, FULL_DUPLEX, 100Mbps

HTTP WebClient is @ IP : 192.168.2.232

**************************************
abbreviation: EDT
client_ip: 216.154.33.167
datetime: 2021-10-23T02:55:20.704254-04:00
day_of_week: 6
day_of_year: 296
dst: true
dst_from: 2021-03-14T07:00:00+00:00
dst_offset: 3600
dst_until: 2021-11-07T06:00:00+00:00
raw_offset: -18000
timezone: America/Toronto
unixtime: 1634972120
utc_datetime: 2021-10-23T06:55:20.704254+00:00
utc_offset: -04:00
week_number: 42
**************************************

New important feature

Now you can send HTTP and HTTPS requests to multiple addresses and receive responses from them.


Releases v2.0.0

  1. Breaking change to permit coexisting with AsyncHTTPRequest library to send and receive both HTTP and HTTPS.
  2. Add example AsyncHTTP_HTTPSRequest_ESP to demonstrate how to send HTTP and HTTPS requests to multiple addresses and receive responses from them.

Releases v1.4.1

  1. Add example AsyncHTTPSRequest_ESP_Multi to demonstrate how to send requests to multiple addresses and receive responses from them.

Releases v1.4.0

  1. Add support to new ESP32-S3
  2. Add LittleFS support to ESP32-C3
  3. Use ESP32-core's LittleFS library instead of Lorol's LITTLEFS library for v2.0.0+
  4. Add complex example AsyncHTTPSRequest_ESP_WiFiManager

Releases v1.3.0

  1. Reduce the breaking effect of v1.2.0 by enabling compatibility with old code to include only AsyncHTTPSRequest_Generic.h
  2. Modify to be compatible with AsyncTCP_SSL releases v1.2.0
  3. Add example multiFileProject to demo for multiple-file project.

Releases v1.2.0

  1. Fix multiple-definitions linker error and weird bug related to src_cpp. Check Different behaviour using the src_cpp or src_h lib #80
  2. Optimize library code by using reference-passing instead of value-passing
  3. Update all examples

Releases v1.1.1

Warning: Releases v1.1.1+ can be used and autodetect ESP32 core v2.0.0+ or v1.0.6- for WT32_ETH01
  1. Auto detect ESP32 core to use for WT32_ETH01
  2. Fix bug in WT32_ETH01 examples to reduce connection time

can it be used for esp8266?

Not yet. Just ESP32 and WT32_ETH01 now.
Possibly in the future, no time-frame yet.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.