Skip to content

Conversation

bdraco
Copy link
Member

@bdraco bdraco commented Jul 14, 2025

Update from upstream. This is a merge from https://github.com/ESP32Async/ESPAsyncWebServer latest with preserving the ESPHome fork message in README.md and library.json changes

Tested on Arduino and bk7200

diff --git a/esphome/components/async_tcp/__init__.py b/esphome/components/async_tcp/__init__.py
index 29097ce1b..4a469fa0e 100644
--- a/esphome/components/async_tcp/__init__.py
+++ b/esphome/components/async_tcp/__init__.py
@@ -31,7 +31,7 @@ CONFIG_SCHEMA = cv.All(
 async def to_code(config):
     if CORE.is_esp32 or CORE.is_libretiny:
         # https://github.com/ESP32Async/AsyncTCP
-        cg.add_library("ESP32Async/AsyncTCP", "3.4.4")
+        cg.add_library("ESP32Async/AsyncTCP", "3.4.5")
     elif CORE.is_esp8266:
         # https://github.com/ESP32Async/ESPAsyncTCP
         cg.add_library("ESP32Async/ESPAsyncTCP", "2.0.0")
diff --git a/esphome/components/web_server_base/__init__.py b/esphome/components/web_server_base/__init__.py
index b43fadefb..0981337bd 100644
--- a/esphome/components/web_server_base/__init__.py
+++ b/esphome/components/web_server_base/__init__.py
@@ -42,5 +42,5 @@ async def to_code(config):
         # https://github.com/ESP32Async/ESPAsyncWebServer/blob/main/library.json
         # Use fork with libretiny compatibility fix
         cg.add_library(
-            "https://github.com/bdraco/ESPAsyncWebServer.git#libretiny_Fix", None
+            "https://github.com/esphome/ESPAsyncWebServer.git#update_with_upstream", None
         )

mathieucarbou and others added 30 commits January 9, 2025 15:20
Introduce -D ASYNCWEBSERVER_USE_CHUNK_INFLIGHT=0|1 to be able to enabled/disable inflight in chunk response
mathieucarbou and others added 23 commits June 13, 2025 21:29
Fix compile on libretiny due to round macro conflict
- Now obey the spec
- Uses a static parse method
- Support move semantic
* ETag and caching for serving pre‐compressed files

This PR introduces ETag handling and caching improvements for serving pre‐compressed .gz files, enabling conditional GET responses to optimize bandwidth and server resource usage.
Adds ETag header generation based on the CRC32 checksum from the gzip trailer.
Implements conditional 304 responses in the send() method when the client's ETag matches the server's.
Enhances both asynchronous file response handling and web server request processing for .gz files.

* Add files via upload

* ci(pre-commit): Apply automatic fixes

* Make _getEtag a private method

Make private: static void _getEtag(uint8_t trailer[4], char *serverETag)

---------

Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
* set default value for '_onDisconnectfn'

* ci(pre-commit): Apply automatic fixes

---------

Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
* Support for pre-compressed and ETag in download 

When downloading file request:
1. **Gzipped file serving**:
   - Automatically detects and serves pre-compressed `.gz` files when uncompressed originals are missing
   - Properly sets `Content-Encoding: gzip` headers
   - Implements `If-None-Match` header comparison for 304 (Not Modified) responses (RFC 7232)
   - Implements `ETag` header using CRC-32 from gzip trailer (bytes 4-7 from end)
   - Optimize for speed
Changes affect:
void AsyncWebServerRequest::send(FS &fs, const String &path, const char *contentType, bool download, AwsTemplateProcessor callback) 
AsyncWebServerResponse *
  AsyncWebServerRequest::beginResponse(FS &fs, const String &path, const char *contentType, bool download, AwsTemplateProcessor callback) 
AsyncFileResponse::AsyncFileResponse(FS &fs, const String &path, const char *contentType, bool download, AwsTemplateProcessor callback)
  : AsyncAbstractResponse(callback)

* ci(pre-commit): Apply automatic fixes

* Update src/AsyncWebServerRequest.cpp

Co-authored-by: Copilot <[email protected]>

* Add files via upload

---------

Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
Co-authored-by: Copilot <[email protected]>
Optimize _setContentTypeFromPath method with a more efficient version (_setContentTypeFromPath_v3) that uses C-string comparison (strcmp) instead of String::endsWith.
This change improves performance and reduces memory usage,
Common web extensions are checked first to speed up typical lookups.

Version 1 (original):    16.9789 μs per call
Version 2 (strcmp):      6.7527 μs per call
…pe-detection

Optimize content type detection using C-strings
Merged latest changes from ESP32Async/ESPAsyncWebServer while preserving
ESPHome-specific metadata in library.json and README.md
ESPHome is no longer using forked versions of AsyncTCP and ESPAsyncTCP,
so update to use the official ESP32Async versions.
@mathieucarbou
Copy link

why not directly make use of https://github.com/ESP32Async/ESPAsyncWebServer ? That would be less confusing for users and would be easier for them to point to new versions or dev branches

@bdraco
Copy link
Member Author

bdraco commented Jul 14, 2025

We switched from this fork to going directly with released version of https://github.com/ESP32Async/ESPAsyncWebServer just recently in ESPHome. We are only considering to switch back to the fork because we need the libretiny fix for the ESPHome release coming in ~48 hours so we don't ship with esphome/issues#7230 broken. Than the plan is to switch back to the released version of https://github.com/ESP32Async/ESPAsyncWebServer in the future when the libretiny fix is generally available in a release and let the fork go dormant again.

@mathieucarbou
Copy link

mathieucarbou commented Jul 14, 2025

We switched from this fork to going directly with released version of https://github.com/ESP32Async/ESPAsyncWebServer just recently in ESPHome. We are only considering to switch back to the fork because we need the libretiny fix for the ESPHome release coming in ~48 hours so we don't ship with esphome/issues#7230 broken. Than the plan is to switch back to the released version of https://github.com/ESP32Async/ESPAsyncWebServer in the future when the libretiny fix is generally available in a release and let the fork go dormant again.

Ok if you had told me I would have issued a release immediately. I will do it now.

@mathieucarbou
Copy link

mathieucarbou commented Jul 14, 2025

v3.7.10 released, publish will be done in a few minutes for pio registry and esp-idf registry

@bdraco
Copy link
Member Author

bdraco commented Jul 14, 2025

Many thanks mathieucarbou 🙇

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.