From 85ea4e995a75abe061f6fc375ea0481084dddd43 Mon Sep 17 00:00:00 2001
From: schererleander
Date: Tue, 20 Jan 2026 08:34:54 +0100
Subject: initial commit
---
libraries/ESP_Async_WebServer/CMakeLists.txt | 9 +
libraries/ESP_Async_WebServer/CODE_OF_CONDUCT.md | 129 ++
libraries/ESP_Async_WebServer/LICENSE | 165 +++
libraries/ESP_Async_WebServer/README.md | 141 ++
libraries/ESP_Async_WebServer/data/README.md | 48 +
libraries/ESP_Async_WebServer/docs/logo.png | Bin 0 -> 490217 bytes
libraries/ESP_Async_WebServer/docs/logo.webp | Bin 0 -> 133742 bytes
.../docs/perf-c10-asynctcpsock.png | Bin 0 -> 317493 bytes
libraries/ESP_Async_WebServer/docs/perf-c10.png | Bin 0 -> 302299 bytes
.../AsyncResponseStream/AsyncResponseStream.ino | 47 +
.../ESP_Async_WebServer/examples/Auth/Auth.ino | 157 +++
.../ESP_Async_WebServer/examples/CORS/CORS.ino | 60 +
.../examples/CaptivePortal/CaptivePortal.ino | 60 +
.../examples/CatchAllHandler/CatchAllHandler.ino | 133 ++
.../examples/ChunkResponse/ChunkResponse.ino | 140 ++
.../ChunkRetryResponse/ChunkRetryResponse.ino | 216 ++++
.../examples/EndBegin/EndBegin.ino | 49 +
.../examples/Filters/Filters.ino | 136 ++
.../examples/FlashResponse/FlashResponse.ino | 107 ++
.../HeaderManipulation/HeaderManipulation.ino | 88 ++
.../examples/Headers/Headers.ino | 69 +
.../ESP_Async_WebServer/examples/Json/Json.ino | 90 ++
.../examples/Logging/Logging.ino | 49 +
.../examples/MessagePack/MessagePack.ino | 88 ++
.../examples/Middleware/Middleware.ino | 82 ++
.../ESP_Async_WebServer/examples/Params/Params.ino | 122 ++
.../PartitionDownloader/PartitionDownloader.ino | 130 ++
.../examples/PerfTests/PerfTests.ino | 243 ++++
.../examples/RateLimit/RateLimit.ino | 64 +
.../examples/Redirect/Redirect.ino | 48 +
.../RequestContinuation/RequestContinuation.ino | 91 ++
.../RequestContinuationComplete.ino | 165 +++
.../ResumableDownload/ResumableDownload.ino | 61 +
.../examples/Rewrite/Rewrite.ino | 52 +
.../examples/ServerSentEvents/ServerSentEvents.ino | 105 ++
.../ServerSentEvents_PR156.ino | 141 ++
.../examples/ServerState/ServerState.ino | 66 +
.../SkipServerMiddleware/SkipServerMiddleware.ino | 73 ++
.../SlowChunkResponse/SlowChunkResponse.ino | 152 +++
.../examples/StaticFile/StaticFile.ino | 144 +++
.../examples/Templates/Templates.ino | 99 ++
.../ESP_Async_WebServer/examples/Upload/Upload.ino | 171 +++
.../examples/WebSocket/WebSocket.ino | 115 ++
.../examples/WebSocketEasy/WebSocketEasy.ino | 124 ++
libraries/ESP_Async_WebServer/idf_component.yml | 37 +
.../idf_component_examples/catchall/CMakeLists.txt | 8 +
.../idf_component_examples/catchall/README.md | 1 +
.../catchall/main/CMakeLists.txt | 2 +
.../catchall/main/idf_component.yml | 6 +
.../idf_component_examples/catchall/main/main.cpp | 125 ++
.../catchall/sdkconfig.defaults | 12 +
.../serversentevents/CMakeLists.txt | 8 +
.../serversentevents/README.md | 1 +
.../serversentevents/main/CMakeLists.txt | 2 +
.../serversentevents/main/idf_component.yml | 6 +
.../serversentevents/main/main.cpp | 95 ++
.../serversentevents/sdkconfig.defaults | 12 +
.../websocket/CMakeLists.txt | 8 +
.../idf_component_examples/websocket/README.md | 1 +
.../websocket/main/CMakeLists.txt | 2 +
.../websocket/main/idf_component.yml | 6 +
.../idf_component_examples/websocket/main/main.cpp | 102 ++
.../websocket/sdkconfig.defaults | 12 +
libraries/ESP_Async_WebServer/library.json | 57 +
libraries/ESP_Async_WebServer/library.properties | 11 +
libraries/ESP_Async_WebServer/partitions-4MB.csv | 7 +
.../IncreaseMaxSockets/platformio.ini | 26 +
.../IncreaseMaxSockets/src/main.cpp | 142 ++
libraries/ESP_Async_WebServer/platformio.ini | 155 +++
.../pre-commit.requirements.txt | 1 +
.../ESP_Async_WebServer/src/AsyncEventSource.cpp | 507 ++++++++
.../ESP_Async_WebServer/src/AsyncEventSource.h | 320 +++++
libraries/ESP_Async_WebServer/src/AsyncJson.cpp | 167 +++
libraries/ESP_Async_WebServer/src/AsyncJson.h | 119 ++
.../ESP_Async_WebServer/src/AsyncMessagePack.cpp | 119 ++
.../ESP_Async_WebServer/src/AsyncMessagePack.h | 126 ++
.../ESP_Async_WebServer/src/AsyncWebHeader.cpp | 32 +
.../src/AsyncWebServerVersion.h | 40 +
.../ESP_Async_WebServer/src/AsyncWebSocket.cpp | 1364 ++++++++++++++++++++
libraries/ESP_Async_WebServer/src/AsyncWebSocket.h | 499 +++++++
.../src/BackPort_SHA1Builder.cpp | 284 ++++
.../ESP_Async_WebServer/src/BackPort_SHA1Builder.h | 44 +
libraries/ESP_Async_WebServer/src/ChunkPrint.cpp | 18 +
libraries/ESP_Async_WebServer/src/ChunkPrint.h | 23 +
.../ESP_Async_WebServer/src/ESPAsyncWebServer.h | 1217 +++++++++++++++++
libraries/ESP_Async_WebServer/src/Middleware.cpp | 287 ++++
.../ESP_Async_WebServer/src/WebAuthentication.cpp | 247 ++++
.../ESP_Async_WebServer/src/WebAuthentication.h | 23 +
libraries/ESP_Async_WebServer/src/WebHandlerImpl.h | 93 ++
libraries/ESP_Async_WebServer/src/WebHandlers.cpp | 326 +++++
libraries/ESP_Async_WebServer/src/WebRequest.cpp | 1185 +++++++++++++++++
.../ESP_Async_WebServer/src/WebResponseImpl.h | 180 +++
libraries/ESP_Async_WebServer/src/WebResponses.cpp | 859 ++++++++++++
libraries/ESP_Async_WebServer/src/WebServer.cpp | 187 +++
libraries/ESP_Async_WebServer/src/literals.h | 193 +++
95 files changed, 13533 insertions(+)
create mode 100644 libraries/ESP_Async_WebServer/CMakeLists.txt
create mode 100644 libraries/ESP_Async_WebServer/CODE_OF_CONDUCT.md
create mode 100644 libraries/ESP_Async_WebServer/LICENSE
create mode 100644 libraries/ESP_Async_WebServer/README.md
create mode 100644 libraries/ESP_Async_WebServer/data/README.md
create mode 100644 libraries/ESP_Async_WebServer/docs/logo.png
create mode 100644 libraries/ESP_Async_WebServer/docs/logo.webp
create mode 100644 libraries/ESP_Async_WebServer/docs/perf-c10-asynctcpsock.png
create mode 100644 libraries/ESP_Async_WebServer/docs/perf-c10.png
create mode 100644 libraries/ESP_Async_WebServer/examples/AsyncResponseStream/AsyncResponseStream.ino
create mode 100644 libraries/ESP_Async_WebServer/examples/Auth/Auth.ino
create mode 100644 libraries/ESP_Async_WebServer/examples/CORS/CORS.ino
create mode 100644 libraries/ESP_Async_WebServer/examples/CaptivePortal/CaptivePortal.ino
create mode 100644 libraries/ESP_Async_WebServer/examples/CatchAllHandler/CatchAllHandler.ino
create mode 100644 libraries/ESP_Async_WebServer/examples/ChunkResponse/ChunkResponse.ino
create mode 100644 libraries/ESP_Async_WebServer/examples/ChunkRetryResponse/ChunkRetryResponse.ino
create mode 100644 libraries/ESP_Async_WebServer/examples/EndBegin/EndBegin.ino
create mode 100644 libraries/ESP_Async_WebServer/examples/Filters/Filters.ino
create mode 100644 libraries/ESP_Async_WebServer/examples/FlashResponse/FlashResponse.ino
create mode 100644 libraries/ESP_Async_WebServer/examples/HeaderManipulation/HeaderManipulation.ino
create mode 100644 libraries/ESP_Async_WebServer/examples/Headers/Headers.ino
create mode 100644 libraries/ESP_Async_WebServer/examples/Json/Json.ino
create mode 100644 libraries/ESP_Async_WebServer/examples/Logging/Logging.ino
create mode 100644 libraries/ESP_Async_WebServer/examples/MessagePack/MessagePack.ino
create mode 100644 libraries/ESP_Async_WebServer/examples/Middleware/Middleware.ino
create mode 100644 libraries/ESP_Async_WebServer/examples/Params/Params.ino
create mode 100644 libraries/ESP_Async_WebServer/examples/PartitionDownloader/PartitionDownloader.ino
create mode 100644 libraries/ESP_Async_WebServer/examples/PerfTests/PerfTests.ino
create mode 100644 libraries/ESP_Async_WebServer/examples/RateLimit/RateLimit.ino
create mode 100644 libraries/ESP_Async_WebServer/examples/Redirect/Redirect.ino
create mode 100644 libraries/ESP_Async_WebServer/examples/RequestContinuation/RequestContinuation.ino
create mode 100644 libraries/ESP_Async_WebServer/examples/RequestContinuationComplete/RequestContinuationComplete.ino
create mode 100644 libraries/ESP_Async_WebServer/examples/ResumableDownload/ResumableDownload.ino
create mode 100644 libraries/ESP_Async_WebServer/examples/Rewrite/Rewrite.ino
create mode 100644 libraries/ESP_Async_WebServer/examples/ServerSentEvents/ServerSentEvents.ino
create mode 100644 libraries/ESP_Async_WebServer/examples/ServerSentEvents_PR156/ServerSentEvents_PR156.ino
create mode 100644 libraries/ESP_Async_WebServer/examples/ServerState/ServerState.ino
create mode 100644 libraries/ESP_Async_WebServer/examples/SkipServerMiddleware/SkipServerMiddleware.ino
create mode 100644 libraries/ESP_Async_WebServer/examples/SlowChunkResponse/SlowChunkResponse.ino
create mode 100644 libraries/ESP_Async_WebServer/examples/StaticFile/StaticFile.ino
create mode 100644 libraries/ESP_Async_WebServer/examples/Templates/Templates.ino
create mode 100644 libraries/ESP_Async_WebServer/examples/Upload/Upload.ino
create mode 100644 libraries/ESP_Async_WebServer/examples/WebSocket/WebSocket.ino
create mode 100644 libraries/ESP_Async_WebServer/examples/WebSocketEasy/WebSocketEasy.ino
create mode 100644 libraries/ESP_Async_WebServer/idf_component.yml
create mode 100644 libraries/ESP_Async_WebServer/idf_component_examples/catchall/CMakeLists.txt
create mode 100644 libraries/ESP_Async_WebServer/idf_component_examples/catchall/README.md
create mode 100644 libraries/ESP_Async_WebServer/idf_component_examples/catchall/main/CMakeLists.txt
create mode 100644 libraries/ESP_Async_WebServer/idf_component_examples/catchall/main/idf_component.yml
create mode 100644 libraries/ESP_Async_WebServer/idf_component_examples/catchall/main/main.cpp
create mode 100644 libraries/ESP_Async_WebServer/idf_component_examples/catchall/sdkconfig.defaults
create mode 100644 libraries/ESP_Async_WebServer/idf_component_examples/serversentevents/CMakeLists.txt
create mode 100644 libraries/ESP_Async_WebServer/idf_component_examples/serversentevents/README.md
create mode 100644 libraries/ESP_Async_WebServer/idf_component_examples/serversentevents/main/CMakeLists.txt
create mode 100644 libraries/ESP_Async_WebServer/idf_component_examples/serversentevents/main/idf_component.yml
create mode 100644 libraries/ESP_Async_WebServer/idf_component_examples/serversentevents/main/main.cpp
create mode 100644 libraries/ESP_Async_WebServer/idf_component_examples/serversentevents/sdkconfig.defaults
create mode 100644 libraries/ESP_Async_WebServer/idf_component_examples/websocket/CMakeLists.txt
create mode 100644 libraries/ESP_Async_WebServer/idf_component_examples/websocket/README.md
create mode 100644 libraries/ESP_Async_WebServer/idf_component_examples/websocket/main/CMakeLists.txt
create mode 100644 libraries/ESP_Async_WebServer/idf_component_examples/websocket/main/idf_component.yml
create mode 100644 libraries/ESP_Async_WebServer/idf_component_examples/websocket/main/main.cpp
create mode 100644 libraries/ESP_Async_WebServer/idf_component_examples/websocket/sdkconfig.defaults
create mode 100644 libraries/ESP_Async_WebServer/library.json
create mode 100644 libraries/ESP_Async_WebServer/library.properties
create mode 100644 libraries/ESP_Async_WebServer/partitions-4MB.csv
create mode 100644 libraries/ESP_Async_WebServer/pioarduino_examples/IncreaseMaxSockets/platformio.ini
create mode 100644 libraries/ESP_Async_WebServer/pioarduino_examples/IncreaseMaxSockets/src/main.cpp
create mode 100644 libraries/ESP_Async_WebServer/platformio.ini
create mode 100644 libraries/ESP_Async_WebServer/pre-commit.requirements.txt
create mode 100644 libraries/ESP_Async_WebServer/src/AsyncEventSource.cpp
create mode 100644 libraries/ESP_Async_WebServer/src/AsyncEventSource.h
create mode 100644 libraries/ESP_Async_WebServer/src/AsyncJson.cpp
create mode 100644 libraries/ESP_Async_WebServer/src/AsyncJson.h
create mode 100644 libraries/ESP_Async_WebServer/src/AsyncMessagePack.cpp
create mode 100644 libraries/ESP_Async_WebServer/src/AsyncMessagePack.h
create mode 100644 libraries/ESP_Async_WebServer/src/AsyncWebHeader.cpp
create mode 100644 libraries/ESP_Async_WebServer/src/AsyncWebServerVersion.h
create mode 100644 libraries/ESP_Async_WebServer/src/AsyncWebSocket.cpp
create mode 100644 libraries/ESP_Async_WebServer/src/AsyncWebSocket.h
create mode 100644 libraries/ESP_Async_WebServer/src/BackPort_SHA1Builder.cpp
create mode 100644 libraries/ESP_Async_WebServer/src/BackPort_SHA1Builder.h
create mode 100644 libraries/ESP_Async_WebServer/src/ChunkPrint.cpp
create mode 100644 libraries/ESP_Async_WebServer/src/ChunkPrint.h
create mode 100644 libraries/ESP_Async_WebServer/src/ESPAsyncWebServer.h
create mode 100644 libraries/ESP_Async_WebServer/src/Middleware.cpp
create mode 100644 libraries/ESP_Async_WebServer/src/WebAuthentication.cpp
create mode 100644 libraries/ESP_Async_WebServer/src/WebAuthentication.h
create mode 100644 libraries/ESP_Async_WebServer/src/WebHandlerImpl.h
create mode 100644 libraries/ESP_Async_WebServer/src/WebHandlers.cpp
create mode 100644 libraries/ESP_Async_WebServer/src/WebRequest.cpp
create mode 100644 libraries/ESP_Async_WebServer/src/WebResponseImpl.h
create mode 100644 libraries/ESP_Async_WebServer/src/WebResponses.cpp
create mode 100644 libraries/ESP_Async_WebServer/src/WebServer.cpp
create mode 100644 libraries/ESP_Async_WebServer/src/literals.h
(limited to 'libraries/ESP_Async_WebServer')
diff --git a/libraries/ESP_Async_WebServer/CMakeLists.txt b/libraries/ESP_Async_WebServer/CMakeLists.txt
new file mode 100644
index 0000000..ea7be08
--- /dev/null
+++ b/libraries/ESP_Async_WebServer/CMakeLists.txt
@@ -0,0 +1,9 @@
+set(COMPONENT_SRCDIRS
+ "src"
+)
+
+set(COMPONENT_ADD_INCLUDEDIRS
+ "src"
+)
+
+register_component()
diff --git a/libraries/ESP_Async_WebServer/CODE_OF_CONDUCT.md b/libraries/ESP_Async_WebServer/CODE_OF_CONDUCT.md
new file mode 100644
index 0000000..4fcdc2f
--- /dev/null
+++ b/libraries/ESP_Async_WebServer/CODE_OF_CONDUCT.md
@@ -0,0 +1,129 @@
+
+# Contributor Covenant Code of Conduct
+
+## Our Pledge
+
+We as members, contributors, and leaders pledge to make participation in our
+community a harassment-free experience for everyone, regardless of age, body
+size, visible or invisible disability, ethnicity, sex characteristics, gender
+identity and expression, level of experience, education, socioeconomic status,
+nationality, personal appearance, race, religion, or sexual identity
+and orientation.
+
+We pledge to act and interact in ways that contribute to an open, welcoming,
+diverse, inclusive, and healthy community.
+
+## Our Standards
+
+Examples of behavior that contributes to a positive environment for our
+community include:
+
+* Demonstrating empathy and kindness toward other people
+* Being respectful of differing opinions, viewpoints, and experiences
+* Giving and gracefully accepting constructive feedback
+* Accepting responsibility and apologizing to those affected by our mistakes,
+ and learning from the experience
+* Focusing on what is best not just for us as individuals, but for the
+ overall community
+
+Examples of unacceptable behavior include:
+
+* The use of sexualized language or imagery, and sexual attention or
+ advances of any kind
+* Trolling, insulting or derogatory comments, and personal or political attacks
+* Public or private harassment
+* Publishing others' private information, such as a physical or email
+ address, without their explicit permission
+* Other conduct which could reasonably be considered inappropriate in a
+ professional setting
+
+## Enforcement Responsibilities
+
+Community leaders are responsible for clarifying and enforcing our standards of
+acceptable behavior and will take appropriate and fair corrective action in
+response to any behavior that they deem inappropriate, threatening, offensive,
+or harmful.
+
+Community leaders have the right and responsibility to remove, edit, or reject
+comments, commits, code, wiki edits, issues, and other contributions that are
+not aligned to this Code of Conduct, and will communicate reasons for moderation
+decisions when appropriate.
+
+## Scope
+
+This Code of Conduct applies within all community spaces, and also applies when
+an individual is officially representing the community in public spaces.
+Examples of representing our community include using an official e-mail address,
+posting via an official social media account, or acting as an appointed
+representative at an online or offline event.
+
+## Enforcement
+
+Instances of abusive, harassing, or otherwise unacceptable behavior may be
+reported to the community leaders responsible for enforcement at
+https://sidweb.nl/cms3/en/contact.
+All complaints will be reviewed and investigated promptly and fairly.
+
+All community leaders are obligated to respect the privacy and security of the
+reporter of any incident.
+
+## Enforcement Guidelines
+
+Community leaders will follow these Community Impact Guidelines in determining
+the consequences for any action they deem in violation of this Code of Conduct:
+
+### 1. Correction
+
+**Community Impact**: Use of inappropriate language or other behavior deemed
+unprofessional or unwelcome in the community.
+
+**Consequence**: A private, written warning from community leaders, providing
+clarity around the nature of the violation and an explanation of why the
+behavior was inappropriate. A public apology may be requested.
+
+### 2. Warning
+
+**Community Impact**: A violation through a single incident or series
+of actions.
+
+**Consequence**: A warning with consequences for continued behavior. No
+interaction with the people involved, including unsolicited interaction with
+those enforcing the Code of Conduct, for a specified period of time. This
+includes avoiding interactions in community spaces as well as external channels
+like social media. Violating these terms may lead to a temporary or
+permanent ban.
+
+### 3. Temporary Ban
+
+**Community Impact**: A serious violation of community standards, including
+sustained inappropriate behavior.
+
+**Consequence**: A temporary ban from any sort of interaction or public
+communication with the community for a specified period of time. No public or
+private interaction with the people involved, including unsolicited interaction
+with those enforcing the Code of Conduct, is allowed during this period.
+Violating these terms may lead to a permanent ban.
+
+### 4. Permanent Ban
+
+**Community Impact**: Demonstrating a pattern of violation of community
+standards, including sustained inappropriate behavior, harassment of an
+individual, or aggression toward or disparagement of classes of individuals.
+
+**Consequence**: A permanent ban from any sort of public interaction within
+the community.
+
+## Attribution
+
+This Code of Conduct is adapted from the [Contributor Covenant][homepage],
+version 2.0, available at
+https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
+
+Community Impact Guidelines were inspired by [Mozilla's code of conduct
+enforcement ladder](https://github.com/mozilla/diversity).
+
+[homepage]: https://www.contributor-covenant.org
+
+For answers to common questions about this code of conduct, see the FAQ at
+https://www.contributor-covenant.org/faq. Translations are available at
+https://www.contributor-covenant.org/translations.
diff --git a/libraries/ESP_Async_WebServer/LICENSE b/libraries/ESP_Async_WebServer/LICENSE
new file mode 100644
index 0000000..153d416
--- /dev/null
+++ b/libraries/ESP_Async_WebServer/LICENSE
@@ -0,0 +1,165 @@
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc.
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+
+ This version of the GNU Lesser General Public License incorporates
+the terms and conditions of version 3 of the GNU General Public
+License, supplemented by the additional permissions listed below.
+
+ 0. Additional Definitions.
+
+ As used herein, "this License" refers to version 3 of the GNU Lesser
+General Public License, and the "GNU GPL" refers to version 3 of the GNU
+General Public License.
+
+ "The Library" refers to a covered work governed by this License,
+other than an Application or a Combined Work as defined below.
+
+ An "Application" is any work that makes use of an interface provided
+by the Library, but which is not otherwise based on the Library.
+Defining a subclass of a class defined by the Library is deemed a mode
+of using an interface provided by the Library.
+
+ A "Combined Work" is a work produced by combining or linking an
+Application with the Library. The particular version of the Library
+with which the Combined Work was made is also called the "Linked
+Version".
+
+ The "Minimal Corresponding Source" for a Combined Work means the
+Corresponding Source for the Combined Work, excluding any source code
+for portions of the Combined Work that, considered in isolation, are
+based on the Application, and not on the Linked Version.
+
+ The "Corresponding Application Code" for a Combined Work means the
+object code and/or source code for the Application, including any data
+and utility programs needed for reproducing the Combined Work from the
+Application, but excluding the System Libraries of the Combined Work.
+
+ 1. Exception to Section 3 of the GNU GPL.
+
+ You may convey a covered work under sections 3 and 4 of this License
+without being bound by section 3 of the GNU GPL.
+
+ 2. Conveying Modified Versions.
+
+ If you modify a copy of the Library, and, in your modifications, a
+facility refers to a function or data to be supplied by an Application
+that uses the facility (other than as an argument passed when the
+facility is invoked), then you may convey a copy of the modified
+version:
+
+ a) under this License, provided that you make a good faith effort to
+ ensure that, in the event an Application does not supply the
+ function or data, the facility still operates, and performs
+ whatever part of its purpose remains meaningful, or
+
+ b) under the GNU GPL, with none of the additional permissions of
+ this License applicable to that copy.
+
+ 3. Object Code Incorporating Material from Library Header Files.
+
+ The object code form of an Application may incorporate material from
+a header file that is part of the Library. You may convey such object
+code under terms of your choice, provided that, if the incorporated
+material is not limited to numerical parameters, data structure
+layouts and accessors, or small macros, inline functions and templates
+(ten or fewer lines in length), you do both of the following:
+
+ a) Give prominent notice with each copy of the object code that the
+ Library is used in it and that the Library and its use are
+ covered by this License.
+
+ b) Accompany the object code with a copy of the GNU GPL and this license
+ document.
+
+ 4. Combined Works.
+
+ You may convey a Combined Work under terms of your choice that,
+taken together, effectively do not restrict modification of the
+portions of the Library contained in the Combined Work and reverse
+engineering for debugging such modifications, if you also do each of
+the following:
+
+ a) Give prominent notice with each copy of the Combined Work that
+ the Library is used in it and that the Library and its use are
+ covered by this License.
+
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
+ document.
+
+ c) For a Combined Work that displays copyright notices during
+ execution, include the copyright notice for the Library among
+ these notices, as well as a reference directing the user to the
+ copies of the GNU GPL and this license document.
+
+ d) Do one of the following:
+
+ 0) Convey the Minimal Corresponding Source under the terms of this
+ License, and the Corresponding Application Code in a form
+ suitable for, and under terms that permit, the user to
+ recombine or relink the Application with a modified version of
+ the Linked Version to produce a modified Combined Work, in the
+ manner specified by section 6 of the GNU GPL for conveying
+ Corresponding Source.
+
+ 1) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (a) uses at run time
+ a copy of the Library already present on the user's computer
+ system, and (b) will operate properly with a modified version
+ of the Library that is interface-compatible with the Linked
+ Version.
+
+ e) Provide Installation Information, but only if you would otherwise
+ be required to provide such information under section 6 of the
+ GNU GPL, and only to the extent that such information is
+ necessary to install and execute a modified version of the
+ Combined Work produced by recombining or relinking the
+ Application with a modified version of the Linked Version. (If
+ you use option 4d0, the Installation Information must accompany
+ the Minimal Corresponding Source and Corresponding Application
+ Code. If you use option 4d1, you must provide the Installation
+ Information in the manner specified by section 6 of the GNU GPL
+ for conveying Corresponding Source.)
+
+ 5. Combined Libraries.
+
+ You may place library facilities that are a work based on the
+Library side by side in a single library together with other library
+facilities that are not Applications and are not covered by this
+License, and convey such a combined library under terms of your
+choice, if you do both of the following:
+
+ a) Accompany the combined library with a copy of the same work based
+ on the Library, uncombined with any other library facilities,
+ conveyed under the terms of this License.
+
+ b) Give prominent notice with the combined library that part of it
+ is a work based on the Library, and explaining where to find the
+ accompanying uncombined form of the same work.
+
+ 6. Revised Versions of the GNU Lesser General Public License.
+
+ The Free Software Foundation may publish revised and/or new versions
+of the GNU Lesser General Public License from time to time. Such new
+versions will be similar in spirit to the present version, but may
+differ in detail to address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Library as you received it specifies that a certain numbered version
+of the GNU Lesser General Public License "or any later version"
+applies to it, you have the option of following the terms and
+conditions either of that published version or of any later version
+published by the Free Software Foundation. If the Library as you
+received it does not specify a version number of the GNU Lesser
+General Public License, you may choose any version of the GNU Lesser
+General Public License ever published by the Free Software Foundation.
+
+ If the Library as you received it specifies that a proxy can decide
+whether future versions of the GNU Lesser General Public License shall
+apply, that proxy's public statement of acceptance of any version is
+permanent authorization for you to choose that version for the
+Library.
\ No newline at end of file
diff --git a/libraries/ESP_Async_WebServer/README.md b/libraries/ESP_Async_WebServer/README.md
new file mode 100644
index 0000000..9bb7575
--- /dev/null
+++ b/libraries/ESP_Async_WebServer/README.md
@@ -0,0 +1,141 @@
+
+
+# ESPAsyncWebServer
+
+[](https://GitHub.com/ESP32Async/ESPAsyncWebServer/releases/)
+[](https://registry.platformio.org/libraries/ESP32Async/ESPAsyncWebServer)
+
+[](https://opensource.org/license/lgpl-3-0/)
+[](code_of_conduct.md)
+
+[](https://GitHub.com/ESP32Async/ESPAsyncWebServer/commit/)
+[](https://gitpod.io/#https://github.com/ESP32Async/ESPAsyncWebServer)
+
+[](https://discord.gg/X7zpGdyUcY)
+
+[](https://github.com/ESP32Async/ESPAsyncWebServer/wiki)
+
+## Asynchronous HTTP and WebSocket Server Library for ESP32, ESP8266, RP2040 and RP2350
+
+Supports: WebSocket, SSE, Authentication, Arduino Json 7, File Upload, Static File serving, URL Rewrite, URL Redirect, etc.
+
+- [Documentation](#documentation)
+- [How to install](#how-to-install)
+- [Dependencies](#dependencies)
+ - [ESP32 / pioarduino](#esp32--pioarduino)
+ - [ESP8266 / pioarduino](#esp8266--pioarduino)
+ - [Unofficial dependencies](#unofficial-dependencies)
+
+## Documentation
+
+The complete [project documentation](https://github.com/ESP32Async/ESPAsyncWebServer/wiki) is available in the Wiki section.
+
+## How to install
+
+The library can be downloaded from the releases page at [https://github.com/ESP32Async/ESPAsyncWebServer/releases](https://github.com/ESP32Async/ESPAsyncWebServer/releases).
+
+It is also deployed in these registries:
+
+- Arduino Library Registry: [https://github.com/arduino/library-registry](https://github.com/arduino/library-registry)
+
+- ESP Component Registry [https://components.espressif.com/components/esp32async/espasyncwebserver](https://components.espressif.com/components/esp32async/espasyncwebserver)
+
+- PlatformIO Registry: [https://registry.platformio.org/libraries/esp32async/ESPAsyncWebServer](https://registry.platformio.org/libraries/esp32async/ESPAsyncWebServer)
+
+ - Use: `lib_deps=ESP32Async/ESPAsyncWebServer` to point to latest version
+ - Use: `lib_deps=ESP32Async/ESPAsyncWebServer @ ^` to point to latest version with the same major version
+ - Use: `lib_deps=ESP32Async/ESPAsyncWebServer @ ` to always point to the same version (reproductible build)
+
+## Dependencies
+
+### ESP32 / pioarduino
+
+```ini
+[env:stable]
+platform = https://github.com/pioarduino/platform-espressif32/releases/download/stable/platform-espressif32.zip
+lib_compat_mode = strict
+lib_ldf_mode = chain
+lib_deps =
+ ESP32Async/AsyncTCP
+ ESP32Async/ESPAsyncWebServer
+```
+
+### ESP8266 / pioarduino
+
+```ini
+[env:stable]
+platform = espressif8266
+lib_compat_mode = strict
+lib_ldf_mode = chain
+lib_deps =
+ ESP32Async/ESPAsyncTCP
+ ESP32Async/ESPAsyncWebServer
+```
+
+### Unofficial dependencies
+
+**AsyncTCPSock**
+
+AsyncTCPSock can be used instead of AsyncTCP by excluding AsyncTCP from the library dependencies and adding AsyncTCPSock instead:
+
+```ini
+lib_compat_mode = strict
+lib_ldf_mode = chain
+lib_deps =
+ https://github.com/ESP32Async/AsyncTCPSock/archive/refs/tags/v1.0.3-dev.zip
+ ESP32Async/ESPAsyncWebServer
+lib_ignore =
+ AsyncTCP
+ ESP32Async/AsyncTCP
+```
+
+**RPAsyncTCP**
+
+RPAsyncTCP replaces AsyncTCP to provide support for RP2040(+WiFi) and RP2350(+WiFi) boards. For example - Raspberry Pi Pico W and Raspberry Pi Pico 2W.
+
+```ini
+lib_compat_mode = strict
+lib_ldf_mode = chain
+platform = https://github.com/maxgerhardt/platform-raspberrypi.git
+board = rpipicow
+board_build.core = earlephilhower
+lib_deps =
+ ayushsharma82/RPAsyncTCP@^1.3.2
+ ESP32Async/ESPAsyncWebServer
+lib_ignore =
+ lwIP_ESPHost
+build_flags = ${env.build_flags}
+ -Wno-missing-field-initializers
+```
+
+## Important recommendations for build options
+
+Most of the crashes are caused by improper use or configuration of the AsyncTCP library used for the project.
+Here are some recommendations to avoid them and build-time flags you can change.
+
+`CONFIG_ASYNC_TCP_MAX_ACK_TIME` - defines a timeout for TCP connection to be considered alive when waiting for data.
+In some bad network conditions you might consider increasing it.
+
+`CONFIG_ASYNC_TCP_QUEUE_SIZE` - defines the length of the queue for events related to connections handling.
+Both the server and AsyncTCP library were optimized to control the queue automatically. Do NOT try blindly increasing the queue size, it does not help you in a way you might think it is. If you receive debug messages about queue throttling, try to optimize your server callbacks code to execute as fast as possible.
+Read #165 thread, it might give you some hints.
+
+`CONFIG_ASYNC_TCP_RUNNING_CORE` - CPU core thread affinity that runs the queue events handling and executes server callbacks. Default is ANY core, so it means that for dualcore SoCs both cores could handle server activities. If your server's code is too heavy and unoptimized or you see that sometimes
+server might affect other network activities, you might consider to bind it to the same core that runs Arduino code (1) to minimize affect on radio part. Otherwise you can leave the default to let RTOS decide where to run the thread based on priority
+
+`CONFIG_ASYNC_TCP_STACK_SIZE` - stack size for the thread that runs sever events and callbacks. Default is 16k that is a way too much waste for well-defined short async code or simple static file handling. You might want to cosider reducing it to 4-8k to same RAM usage. If you do not know what this is or not sure about your callback code demands - leave it as default, should be enough even for very hungry callbacks in most cases.
+
+> [!NOTE]
+> This relates to ESP32 only, ESP8266 uses different ESPAsyncTCP lib that does not has this build options
+
+I personally use the following configuration in my projects:
+
+```c++
+ -D CONFIG_ASYNC_TCP_MAX_ACK_TIME=5000 // (keep default)
+ -D CONFIG_ASYNC_TCP_PRIORITY=10 // (keep default)
+ -D CONFIG_ASYNC_TCP_QUEUE_SIZE=64 // (keep default)
+ -D CONFIG_ASYNC_TCP_RUNNING_CORE=1 // force async_tcp task to be on same core as Arduino app (default is any core)
+ -D CONFIG_ASYNC_TCP_STACK_SIZE=4096 // reduce the stack size (default is 16K)
+```
+
+If you need to serve chunk requests with a really low buffer (which should be avoided), you can set `-D ASYNCWEBSERVER_USE_CHUNK_INFLIGHT=0` to disable the in-flight control.
diff --git a/libraries/ESP_Async_WebServer/data/README.md b/libraries/ESP_Async_WebServer/data/README.md
new file mode 100644
index 0000000..96a2ee4
--- /dev/null
+++ b/libraries/ESP_Async_WebServer/data/README.md
@@ -0,0 +1,48 @@
+Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin euismod, purus a euismod
+rhoncus, urna ipsum cursus massa, eu dictum tellus justo ac justo. Quisque ullamcorper
+arcu nec tortor ullamcorper, vel fermentum justo fermentum. Vivamus sed velit ut elit
+accumsan congue ut ut enim. Ut eu justo eu lacus varius gravida ut a tellus. Nulla facilisi.
+Integer auctor consectetur ultricies. Fusce feugiat, mi sit amet bibendum viverra, orci leo
+dapibus elit, id varius sem dui id lacus.
+Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin euismod, purus a euismod
+rhoncus, urna ipsum cursus massa, eu dictum tellus justo ac justo. Quisque ullamcorper
+arcu nec tortor ullamcorper, vel fermentum justo fermentum. Vivamus sed velit ut elit
+accumsan congue ut ut enim. Ut eu justo eu lacus varius gravida ut a tellus. Nulla facilisi.
+Integer auctor consectetur ultricies. Fusce feugiat, mi sit amet bibendum viverra, orci leo
+dapibus elit, id varius sem dui id lacus.
+Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin euismod, purus a euismod
+rhoncus, urna ipsum cursus massa, eu dictum tellus justo ac justo. Quisque ullamcorper
+arcu nec tortor ullamcorper, vel fermentum justo fermentum. Vivamus sed velit ut elit
+accumsan congue ut ut enim. Ut eu justo eu lacus varius gravida ut a tellus. Nulla facilisi.
+Integer auctor consectetur ultricies. Fusce feugiat, mi sit amet bibendum viverra, orci leo
+dapibus elit, id varius sem dui id lacus.
+Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin euismod, purus a euismod
+rhoncus, urna ipsum cursus massa, eu dictum tellus justo ac justo. Quisque ullamcorper
+arcu nec tortor ullamcorper, vel fermentum justo fermentum. Vivamus sed velit ut elit
+accumsan congue ut ut enim. Ut eu justo eu lacus varius gravida ut a tellus. Nulla facilisi.
+Integer auctor consectetur ultricies. Fusce feugiat, mi sit amet bibendum viverra, orci leo
+dapibus elit, id varius sem dui id lacus.
+Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin euismod, purus a euismod
+rhoncus, urna ipsum cursus massa, eu dictum tellus justo ac justo. Quisque ullamcorper
+arcu nec tortor ullamcorper, vel fermentum justo fermentum. Vivamus sed velit ut elit
+accumsan congue ut ut enim. Ut eu justo eu lacus varius gravida ut a tellus. Nulla facilisi.
+Integer auctor consectetur ultricies. Fusce feugiat, mi sit amet bibendum viverra, orci leo
+dapibus elit, id varius sem dui id lacus.
+Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin euismod, purus a euismod
+rhoncus, urna ipsum cursus massa, eu dictum tellus justo ac justo. Quisque ullamcorper
+arcu nec tortor ullamcorper, vel fermentum justo fermentum. Vivamus sed velit ut elit
+accumsan congue ut ut enim. Ut eu justo eu lacus varius gravida ut a tellus. Nulla facilisi.
+Integer auctor consectetur ultricies. Fusce feugiat, mi sit amet bibendum viverra, orci leo
+dapibus elit, id varius sem dui id lacus.
+Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin euismod, purus a euismod
+rhoncus, urna ipsum cursus massa, eu dictum tellus justo ac justo. Quisque ullamcorper
+arcu nec tortor ullamcorper, vel fermentum justo fermentum. Vivamus sed velit ut elit
+accumsan congue ut ut enim. Ut eu justo eu lacus varius gravida ut a tellus. Nulla facilisi.
+Integer auctor consectetur ultricies. Fusce feugiat, mi sit amet bibendum viverra, orci leo
+dapibus elit, id varius sem dui id lacus.
+Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin euismod, purus a euismod
+rhoncus, urna ipsum cursus massa, eu dictum tellus justo ac justo. Quisque ullamcorper
+arcu nec tortor ullamcorper, vel fermentum justo fermentum. Vivamus sed velit ut elit
+accumsan congue ut ut enim. Ut eu justo eu lacus varius gravida ut a tellus. Nulla facilisi.
+Integer auctor consectetur ultricies. Fusce feugiat, mi sit amet bibendum viverra, orci leo
+dapibus elit, id varius sem dui id lacus.
diff --git a/libraries/ESP_Async_WebServer/docs/logo.png b/libraries/ESP_Async_WebServer/docs/logo.png
new file mode 100644
index 0000000..1995c88
Binary files /dev/null and b/libraries/ESP_Async_WebServer/docs/logo.png differ
diff --git a/libraries/ESP_Async_WebServer/docs/logo.webp b/libraries/ESP_Async_WebServer/docs/logo.webp
new file mode 100644
index 0000000..c70b842
Binary files /dev/null and b/libraries/ESP_Async_WebServer/docs/logo.webp differ
diff --git a/libraries/ESP_Async_WebServer/docs/perf-c10-asynctcpsock.png b/libraries/ESP_Async_WebServer/docs/perf-c10-asynctcpsock.png
new file mode 100644
index 0000000..b1d4d7a
Binary files /dev/null and b/libraries/ESP_Async_WebServer/docs/perf-c10-asynctcpsock.png differ
diff --git a/libraries/ESP_Async_WebServer/docs/perf-c10.png b/libraries/ESP_Async_WebServer/docs/perf-c10.png
new file mode 100644
index 0000000..e63e71a
Binary files /dev/null and b/libraries/ESP_Async_WebServer/docs/perf-c10.png differ
diff --git a/libraries/ESP_Async_WebServer/examples/AsyncResponseStream/AsyncResponseStream.ino b/libraries/ESP_Async_WebServer/examples/AsyncResponseStream/AsyncResponseStream.ino
new file mode 100644
index 0000000..62fa799
--- /dev/null
+++ b/libraries/ESP_Async_WebServer/examples/AsyncResponseStream/AsyncResponseStream.ino
@@ -0,0 +1,47 @@
+// SPDX-License-Identifier: LGPL-3.0-or-later
+// Copyright 2016-2025 Hristo Gochkov, Mathieu Carbou, Emil Muratov
+
+#include
+#ifdef ESP32
+#include
+#include
+#elif defined(ESP8266)
+#include
+#include
+#elif defined(TARGET_RP2040) || defined(TARGET_RP2350) || defined(PICO_RP2040) || defined(PICO_RP2350)
+#include
+#include
+#endif
+
+#include
+
+static AsyncWebServer server(80);
+
+void setup() {
+ Serial.begin(115200);
+
+#ifndef CONFIG_IDF_TARGET_ESP32H2
+ WiFi.mode(WIFI_AP);
+ WiFi.softAP("esp-captive");
+#endif
+
+ // Shows how to use AsyncResponseStream.
+ // The internal buffer will be allocated and data appended to it,
+ // until the response is sent, then this buffer is read and committed on the network.
+ //
+ // curl -v http://192.168.4.1/
+ //
+ server.on("/", HTTP_GET, [](AsyncWebServerRequest *request) {
+ AsyncResponseStream *response = request->beginResponseStream("plain/text", 40 * 1024);
+ for (int i = 0; i < 32 * 1024; i++) {
+ response->write('a');
+ }
+ request->send(response);
+ });
+
+ server.begin();
+}
+
+void loop() {
+ delay(100);
+}
diff --git a/libraries/ESP_Async_WebServer/examples/Auth/Auth.ino b/libraries/ESP_Async_WebServer/examples/Auth/Auth.ino
new file mode 100644
index 0000000..c3751e0
--- /dev/null
+++ b/libraries/ESP_Async_WebServer/examples/Auth/Auth.ino
@@ -0,0 +1,157 @@
+// SPDX-License-Identifier: LGPL-3.0-or-later
+// Copyright 2016-2025 Hristo Gochkov, Mathieu Carbou, Emil Muratov
+
+//
+// Authentication and authorization middlewares
+//
+
+#include
+#ifdef ESP32
+#include
+#include
+#elif defined(ESP8266)
+#include
+#include
+#elif defined(TARGET_RP2040) || defined(TARGET_RP2350) || defined(PICO_RP2040) || defined(PICO_RP2350)
+#include
+#include
+#endif
+
+#include
+
+static AsyncWebServer server(80);
+
+// basicAuth
+static AsyncAuthenticationMiddleware basicAuth;
+static AsyncAuthenticationMiddleware basicAuthHash;
+
+// simple digest authentication
+static AsyncAuthenticationMiddleware digestAuth;
+static AsyncAuthenticationMiddleware digestAuthHash;
+
+// complex authentication which adds request attributes for the next middlewares and handler
+static AsyncMiddlewareFunction complexAuth([](AsyncWebServerRequest *request, ArMiddlewareNext next) {
+ if (!request->authenticate("user", "password")) {
+ return request->requestAuthentication();
+ }
+
+ // add attributes to the request for the next middlewares and handler
+ request->setAttribute("user", "Mathieu");
+ request->setAttribute("role", "staff");
+ if (request->hasParam("token")) {
+ request->setAttribute("token", request->getParam("token")->value().c_str());
+ }
+
+ next();
+});
+
+static AsyncAuthorizationMiddleware authz([](AsyncWebServerRequest *request) {
+ return request->getAttribute("token") == "123";
+});
+
+void setup() {
+ Serial.begin(115200);
+
+#ifndef CONFIG_IDF_TARGET_ESP32H2
+ WiFi.mode(WIFI_AP);
+ WiFi.softAP("esp-captive");
+#endif
+
+ // basic authentication
+ basicAuth.setUsername("admin");
+ basicAuth.setPassword("admin");
+ basicAuth.setRealm("MyApp");
+ basicAuth.setAuthFailureMessage("Authentication failed");
+ basicAuth.setAuthType(AsyncAuthType::AUTH_BASIC);
+ basicAuth.generateHash(); // precompute hash (optional but recommended)
+
+ // basic authentication with hash
+ basicAuthHash.setUsername("admin");
+ basicAuthHash.setPasswordHash("YWRtaW46YWRtaW4="); // BASE64(admin:admin)
+ basicAuthHash.setRealm("MyApp");
+ basicAuthHash.setAuthFailureMessage("Authentication failed");
+ basicAuthHash.setAuthType(AsyncAuthType::AUTH_BASIC);
+
+ // digest authentication
+ digestAuth.setUsername("admin");
+ digestAuth.setPassword("admin");
+ digestAuth.setRealm("MyApp");
+ digestAuth.setAuthFailureMessage("Authentication failed");
+ digestAuth.setAuthType(AsyncAuthType::AUTH_DIGEST);
+ digestAuth.generateHash(); // precompute hash (optional but recommended)
+
+ // digest authentication with hash
+ digestAuthHash.setUsername("admin");
+ digestAuthHash.setPasswordHash("f499b71f9a36d838b79268e145e132f7"); // MD5(user:realm:pass)
+ digestAuthHash.setRealm("MyApp");
+ digestAuthHash.setAuthFailureMessage("Authentication failed");
+ digestAuthHash.setAuthType(AsyncAuthType::AUTH_DIGEST);
+
+ // basic authentication method
+ // curl -v -u admin:admin http://192.168.4.1/auth-basic
+ server
+ .on(
+ "/auth-basic", HTTP_GET,
+ [](AsyncWebServerRequest *request) {
+ request->send(200, "text/plain", "Hello, world!");
+ }
+ )
+ .addMiddleware(&basicAuth);
+
+ // basic authentication method with hash
+ // curl -v -u admin:admin http://192.168.4.1/auth-basic-hash
+ server
+ .on(
+ "/auth-basic-hash", HTTP_GET,
+ [](AsyncWebServerRequest *request) {
+ request->send(200, "text/plain", "Hello, world!");
+ }
+ )
+ .addMiddleware(&basicAuthHash);
+
+ // digest authentication
+ // curl -v -u admin:admin --digest http://192.168.4.1/auth-digest
+ server
+ .on(
+ "/auth-digest", HTTP_GET,
+ [](AsyncWebServerRequest *request) {
+ request->send(200, "text/plain", "Hello, world!");
+ }
+ )
+ .addMiddleware(&digestAuth);
+
+ // digest authentication with hash
+ // curl -v -u admin:admin --digest http://192.168.4.1/auth-digest-hash
+ server
+ .on(
+ "/auth-digest-hash", HTTP_GET,
+ [](AsyncWebServerRequest *request) {
+ request->send(200, "text/plain", "Hello, world!");
+ }
+ )
+ .addMiddleware(&digestAuthHash);
+
+ // test digest auth custom authorization middleware
+ // curl -v --digest -u user:password http://192.168.4.1/auth-custom?token=123 => OK
+ // curl -v --digest -u user:password http://192.168.4.1/auth-custom?token=456 => 403
+ // curl -v --digest -u user:FAILED http://192.168.4.1/auth-custom?token=456 => 401
+ server
+ .on(
+ "/auth-custom", HTTP_GET,
+ [](AsyncWebServerRequest *request) {
+ String buffer = "Hello ";
+ buffer.concat(request->getAttribute("user"));
+ buffer.concat(" with role: ");
+ buffer.concat(request->getAttribute("role"));
+ request->send(200, "text/plain", buffer);
+ }
+ )
+ .addMiddlewares({&complexAuth, &authz});
+
+ server.begin();
+}
+
+// not needed
+void loop() {
+ delay(100);
+}
diff --git a/libraries/ESP_Async_WebServer/examples/CORS/CORS.ino b/libraries/ESP_Async_WebServer/examples/CORS/CORS.ino
new file mode 100644
index 0000000..3be46fd
--- /dev/null
+++ b/libraries/ESP_Async_WebServer/examples/CORS/CORS.ino
@@ -0,0 +1,60 @@
+// SPDX-License-Identifier: LGPL-3.0-or-later
+// Copyright 2016-2025 Hristo Gochkov, Mathieu Carbou, Emil Muratov
+
+//
+// How to use CORS middleware
+//
+
+#include
+#ifdef ESP32
+#include
+#include
+#elif defined(ESP8266)
+#include
+#include
+#elif defined(TARGET_RP2040) || defined(TARGET_RP2350) || defined(PICO_RP2040) || defined(PICO_RP2350)
+#include
+#include
+#endif
+
+#include
+
+static AsyncWebServer server(80);
+static AsyncCorsMiddleware cors;
+
+void setup() {
+ Serial.begin(115200);
+
+#ifndef CONFIG_IDF_TARGET_ESP32H2
+ WiFi.mode(WIFI_AP);
+ WiFi.softAP("esp-captive");
+#endif
+
+ cors.setOrigin("http://192.168.4.1");
+ cors.setMethods("POST, GET, OPTIONS, DELETE");
+ cors.setHeaders("X-Custom-Header");
+ cors.setAllowCredentials(false);
+ cors.setMaxAge(600);
+
+ server.addMiddleware(&cors);
+
+ // Test CORS preflight request
+ // curl -v -X OPTIONS -H "origin: http://192.168.4.1" http://192.168.4.1/cors
+ //
+ // Test CORS request
+ // curl -v -H "origin: http://192.168.4.1" http://192.168.4.1/cors
+ //
+ // Test non-CORS request
+ // curl -v http://192.168.4.1/cors
+ //
+ server.on("/cors", HTTP_GET, [](AsyncWebServerRequest *request) {
+ request->send(200, "text/plain", "Hello, world!");
+ });
+
+ server.begin();
+}
+
+// not needed
+void loop() {
+ delay(100);
+}
diff --git a/libraries/ESP_Async_WebServer/examples/CaptivePortal/CaptivePortal.ino b/libraries/ESP_Async_WebServer/examples/CaptivePortal/CaptivePortal.ino
new file mode 100644
index 0000000..a872a9b
--- /dev/null
+++ b/libraries/ESP_Async_WebServer/examples/CaptivePortal/CaptivePortal.ino
@@ -0,0 +1,60 @@
+// SPDX-License-Identifier: LGPL-3.0-or-later
+// Copyright 2016-2025 Hristo Gochkov, Mathieu Carbou, Emil Muratov
+
+#include
+#ifdef ESP32
+#include
+#include
+#elif defined(ESP8266)
+#include
+#include
+#elif defined(TARGET_RP2040) || defined(TARGET_RP2350) || defined(PICO_RP2040) || defined(PICO_RP2350)
+#include
+#include
+#endif
+#include "ESPAsyncWebServer.h"
+
+static DNSServer dnsServer;
+static AsyncWebServer server(80);
+
+class CaptiveRequestHandler : public AsyncWebHandler {
+public:
+ bool canHandle(__unused AsyncWebServerRequest *request) const override {
+ return true;
+ }
+
+ void handleRequest(AsyncWebServerRequest *request) {
+ AsyncResponseStream *response = request->beginResponseStream("text/html");
+ response->print("Captive Portal");
+ response->print("This is our captive portal front page.
");
+ response->printf("You were trying to reach: http://%s%s
", request->host().c_str(), request->url().c_str());
+#ifndef CONFIG_IDF_TARGET_ESP32H2
+ response->printf("Try opening this link instead
", WiFi.softAPIP().toString().c_str());
+#endif
+ response->print("");
+ request->send(response);
+ }
+};
+
+void setup() {
+ Serial.begin(115200);
+ Serial.println();
+ Serial.println("Configuring access point...");
+
+#ifndef CONFIG_IDF_TARGET_ESP32H2
+ if (!WiFi.softAP("esp-captive")) {
+ Serial.println("Soft AP creation failed.");
+ while (1);
+ }
+
+ dnsServer.start(53, "*", WiFi.softAPIP());
+#endif
+
+ server.addHandler(new CaptiveRequestHandler()).setFilter(ON_AP_FILTER); // only when requested from AP
+ // more handlers...
+ server.begin();
+}
+
+void loop() {
+ dnsServer.processNextRequest();
+}
diff --git a/libraries/ESP_Async_WebServer/examples/CatchAllHandler/CatchAllHandler.ino b/libraries/ESP_Async_WebServer/examples/CatchAllHandler/CatchAllHandler.ino
new file mode 100644
index 0000000..42a3698
--- /dev/null
+++ b/libraries/ESP_Async_WebServer/examples/CatchAllHandler/CatchAllHandler.ino
@@ -0,0 +1,133 @@
+// SPDX-License-Identifier: LGPL-3.0-or-later
+// Copyright 2016-2025 Hristo Gochkov, Mathieu Carbou, Emil Muratov
+
+//
+// Shows how to catch all requests and send a 404 Not Found response
+//
+
+#include
+#ifdef ESP32
+#include
+#include
+#elif defined(ESP8266)
+#include
+#include
+#elif defined(TARGET_RP2040) || defined(TARGET_RP2350) || defined(PICO_RP2040) || defined(PICO_RP2350)
+#include
+#include
+#endif
+
+#include
+
+static AsyncWebServer server(80);
+
+static const char *htmlContent PROGMEM = R"(
+
+
+
+ Sample HTML
+
+
+ Hello, World!
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin euismod, purus a euismod
+ rhoncus, urna ipsum cursus massa, eu dictum tellus justo ac justo. Quisque ullamcorper
+ arcu nec tortor ullamcorper, vel fermentum justo fermentum. Vivamus sed velit ut elit
+ accumsan congue ut ut enim. Ut eu justo eu lacus varius gravida ut a tellus. Nulla facilisi.
+ Integer auctor consectetur ultricies. Fusce feugiat, mi sit amet bibendum viverra, orci leo
+ dapibus elit, id varius sem dui id lacus.
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin euismod, purus a euismod
+ rhoncus, urna ipsum cursus massa, eu dictum tellus justo ac justo. Quisque ullamcorper
+ arcu nec tortor ullamcorper, vel fermentum justo fermentum. Vivamus sed velit ut elit
+ accumsan congue ut ut enim. Ut eu justo eu lacus varius gravida ut a tellus. Nulla facilisi.
+ Integer auctor consectetur ultricies. Fusce feugiat, mi sit amet bibendum viverra, orci leo
+ dapibus elit, id varius sem dui id lacus.
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin euismod, purus a euismod
+ rhoncus, urna ipsum cursus massa, eu dictum tellus justo ac justo. Quisque ullamcorper
+ arcu nec tortor ullamcorper, vel fermentum justo fermentum. Vivamus sed velit ut elit
+ accumsan congue ut ut enim. Ut eu justo eu lacus varius gravida ut a tellus. Nulla facilisi.
+ Integer auctor consectetur ultricies. Fusce feugiat, mi sit amet bibendum viverra, orci leo
+ dapibus elit, id varius sem dui id lacus.
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin euismod, purus a euismod
+ rhoncus, urna ipsum cursus massa, eu dictum tellus justo ac justo. Quisque ullamcorper
+ arcu nec tortor ullamcorper, vel fermentum justo fermentum. Vivamus sed velit ut elit
+ accumsan congue ut ut enim. Ut eu justo eu lacus varius gravida ut a tellus. Nulla facilisi.
+ Integer auctor consectetur ultricies. Fusce feugiat, mi sit amet bibendum viverra, orci leo
+ dapibus elit, id varius sem dui id lacus.
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin euismod, purus a euismod
+ rhoncus, urna ipsum cursus massa, eu dictum tellus justo ac justo. Quisque ullamcorper
+ arcu nec tortor ullamcorper, vel fermentum justo fermentum. Vivamus sed velit ut elit
+ accumsan congue ut ut enim. Ut eu justo eu lacus varius gravida ut a tellus. Nulla facilisi.
+ Integer auctor consectetur ultricies. Fusce feugiat, mi sit amet bibendum viverra, orci leo
+ dapibus elit, id varius sem dui id lacus.
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin euismod, purus a euismod
+ rhoncus, urna ipsum cursus massa, eu dictum tellus justo ac justo. Quisque ullamcorper
+ arcu nec tortor ullamcorper, vel fermentum justo fermentum. Vivamus sed velit ut elit
+ accumsan congue ut ut enim. Ut eu justo eu lacus varius gravida ut a tellus. Nulla facilisi.
+ Integer auctor consectetur ultricies. Fusce feugiat, mi sit amet bibendum viverra, orci leo
+ dapibus elit, id varius sem dui id lacus.
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin euismod, purus a euismod
+ rhoncus, urna ipsum cursus massa, eu dictum tellus justo ac justo. Quisque ullamcorper
+ arcu nec tortor ullamcorper, vel fermentum justo fermentum. Vivamus sed velit ut elit
+ accumsan congue ut ut enim. Ut eu justo eu lacus varius gravida ut a tellus. Nulla facilisi.
+ Integer auctor consectetur ultricies. Fusce feugiat, mi sit amet bibendum viverra, orci leo
+ dapibus elit, id varius sem dui id lacus.
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin euismod, purus a euismod
+ rhoncus, urna ipsum cursus massa, eu dictum tellus justo ac justo. Quisque ullamcorper
+ arcu nec tortor ullamcorper, vel fermentum justo fermentum. Vivamus sed velit ut elit
+ accumsan congue ut ut enim. Ut eu justo eu lacus varius gravida ut a tellus. Nulla facilisi.
+ Integer auctor consectetur ultricies. Fusce feugiat, mi sit amet bibendum viverra, orci leo
+ dapibus elit, id varius sem dui id lacus.
+
+
+)";
+
+static const size_t htmlContentLength = strlen_P(htmlContent);
+
+void setup() {
+ Serial.begin(115200);
+
+#ifndef CONFIG_IDF_TARGET_ESP32H2
+ WiFi.mode(WIFI_AP);
+ WiFi.softAP("esp-captive");
+#endif
+
+ // curl -v http://192.168.4.1/
+ server.on("/", HTTP_GET, [](AsyncWebServerRequest *request) {
+ // need to cast to uint8_t*
+ // if you do not, the const char* will be copied in a temporary String buffer
+ request->send(200, "text/html", (uint8_t *)htmlContent, htmlContentLength);
+ });
+
+ // catch any request, and send a 404 Not Found response
+ // except for /game_log which is handled by onRequestBody
+ //
+ // curl -v http://192.168.4.1/foo
+ //
+ server.onNotFound([](AsyncWebServerRequest *request) {
+ if (request->url() == "/game_log") {
+ return; // response object already created by onRequestBody
+ }
+
+ request->send(404, "text/plain", "Not found");
+ });
+
+ // See: https://github.com/ESP32Async/ESPAsyncWebServer/issues/6
+ // catch any POST request and send a 200 OK response
+ //
+ // curl -v -X POST http://192.168.4.1/game_log -H "Content-Type: application/json" -d '{"game": "test"}'
+ //
+ server.onRequestBody([](AsyncWebServerRequest *request, uint8_t *data, size_t len, size_t index, size_t total) {
+ if (request->url() == "/game_log") {
+ request->send(200, "application/json", "{\"status\":\"OK\"}");
+ }
+ // note that there is no else here: the goal is only to prepare a response based on some body content
+ // onNotFound will always be called after this, and will not override the response object if `/game_log` is requested
+ });
+
+ server.begin();
+}
+
+// not needed
+void loop() {
+ delay(100);
+}
diff --git a/libraries/ESP_Async_WebServer/examples/ChunkResponse/ChunkResponse.ino b/libraries/ESP_Async_WebServer/examples/ChunkResponse/ChunkResponse.ino
new file mode 100644
index 0000000..e7d4838
--- /dev/null
+++ b/libraries/ESP_Async_WebServer/examples/ChunkResponse/ChunkResponse.ino
@@ -0,0 +1,140 @@
+// SPDX-License-Identifier: LGPL-3.0-or-later
+// Copyright 2016-2025 Hristo Gochkov, Mathieu Carbou, Emil Muratov
+
+//
+// Chunk response with caching example
+//
+
+#include
+#ifdef ESP32
+#include
+#include
+#elif defined(ESP8266)
+#include
+#include
+#elif defined(TARGET_RP2040) || defined(TARGET_RP2350) || defined(PICO_RP2040) || defined(PICO_RP2350)
+#include
+#include
+#endif
+
+#include
+
+static AsyncWebServer server(80);
+
+static const char *htmlContent PROGMEM = R"(
+
+
+
+ Sample HTML
+
+
+ Hello, World!
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin euismod, purus a euismod
+ rhoncus, urna ipsum cursus massa, eu dictum tellus justo ac justo. Quisque ullamcorper
+ arcu nec tortor ullamcorper, vel fermentum justo fermentum. Vivamus sed velit ut elit
+ accumsan congue ut ut enim. Ut eu justo eu lacus varius gravida ut a tellus. Nulla facilisi.
+ Integer auctor consectetur ultricies. Fusce feugiat, mi sit amet bibendum viverra, orci leo
+ dapibus elit, id varius sem dui id lacus.
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin euismod, purus a euismod
+ rhoncus, urna ipsum cursus massa, eu dictum tellus justo ac justo. Quisque ullamcorper
+ arcu nec tortor ullamcorper, vel fermentum justo fermentum. Vivamus sed velit ut elit
+ accumsan congue ut ut enim. Ut eu justo eu lacus varius gravida ut a tellus. Nulla facilisi.
+ Integer auctor consectetur ultricies. Fusce feugiat, mi sit amet bibendum viverra, orci leo
+ dapibus elit, id varius sem dui id lacus.
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin euismod, purus a euismod
+ rhoncus, urna ipsum cursus massa, eu dictum tellus justo ac justo. Quisque ullamcorper
+ arcu nec tortor ullamcorper, vel fermentum justo fermentum. Vivamus sed velit ut elit
+ accumsan congue ut ut enim. Ut eu justo eu lacus varius gravida ut a tellus. Nulla facilisi.
+ Integer auctor consectetur ultricies. Fusce feugiat, mi sit amet bibendum viverra, orci leo
+ dapibus elit, id varius sem dui id lacus.
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin euismod, purus a euismod
+ rhoncus, urna ipsum cursus massa, eu dictum tellus justo ac justo. Quisque ullamcorper
+ arcu nec tortor ullamcorper, vel fermentum justo fermentum. Vivamus sed velit ut elit
+ accumsan congue ut ut enim. Ut eu justo eu lacus varius gravida ut a tellus. Nulla facilisi.
+ Integer auctor consectetur ultricies. Fusce feugiat, mi sit amet bibendum viverra, orci leo
+ dapibus elit, id varius sem dui id lacus.
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin euismod, purus a euismod
+ rhoncus, urna ipsum cursus massa, eu dictum tellus justo ac justo. Quisque ullamcorper
+ arcu nec tortor ullamcorper, vel fermentum justo fermentum. Vivamus sed velit ut elit
+ accumsan congue ut ut enim. Ut eu justo eu lacus varius gravida ut a tellus. Nulla facilisi.
+ Integer auctor consectetur ultricies. Fusce feugiat, mi sit amet bibendum viverra, orci leo
+ dapibus elit, id varius sem dui id lacus.
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin euismod, purus a euismod
+ rhoncus, urna ipsum cursus massa, eu dictum tellus justo ac justo. Quisque ullamcorper
+ arcu nec tortor ullamcorper, vel fermentum justo fermentum. Vivamus sed velit ut elit
+ accumsan congue ut ut enim. Ut eu justo eu lacus varius gravida ut a tellus. Nulla facilisi.
+ Integer auctor consectetur ultricies. Fusce feugiat, mi sit amet bibendum viverra, orci leo
+ dapibus elit, id varius sem dui id lacus.
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin euismod, purus a euismod
+ rhoncus, urna ipsum cursus massa, eu dictum tellus justo ac justo. Quisque ullamcorper
+ arcu nec tortor ullamcorper, vel fermentum justo fermentum. Vivamus sed velit ut elit
+ accumsan congue ut ut enim. Ut eu justo eu lacus varius gravida ut a tellus. Nulla facilisi.
+ Integer auctor consectetur ultricies. Fusce feugiat, mi sit amet bibendum viverra, orci leo
+ dapibus elit, id varius sem dui id lacus.
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin euismod, purus a euismod
+ rhoncus, urna ipsum cursus massa, eu dictum tellus justo ac justo. Quisque ullamcorper
+ arcu nec tortor ullamcorper, vel fermentum justo fermentum. Vivamus sed velit ut elit
+ accumsan congue ut ut enim. Ut eu justo eu lacus varius gravida ut a tellus. Nulla facilisi.
+ Integer auctor consectetur ultricies. Fusce feugiat, mi sit amet bibendum viverra, orci leo
+ dapibus elit, id varius sem dui id lacus.
+
+
+)";
+
+static const size_t htmlContentLength = strlen_P(htmlContent);
+
+void setup() {
+ Serial.begin(115200);
+
+#ifndef CONFIG_IDF_TARGET_ESP32H2
+ WiFi.mode(WIFI_AP);
+ WiFi.softAP("esp-captive");
+#endif
+
+ // first time: serves the file and cache headers
+ // curl -N -v http://192.168.4.1/ --output -
+ //
+ // secodn time: serves 304
+ // curl -N -v -H "if-none-match: 4272" http://192.168.4.1/ --output -
+ //
+ server.on("/", HTTP_GET, [](AsyncWebServerRequest *request) {
+ String etag = String(htmlContentLength);
+
+ if (request->header(asyncsrv::T_INM) == etag) {
+ request->send(304);
+ return;
+ }
+
+ AsyncWebServerResponse *response = request->beginChunkedResponse("text/html", [](uint8_t *buffer, size_t maxLen, size_t index) -> size_t {
+ Serial.printf("%u / %u\n", index, htmlContentLength);
+
+ // finished ?
+ if (htmlContentLength <= index) {
+ Serial.println("finished");
+ return 0;
+ }
+
+ // serve a maximum of 256 or maxLen bytes of the remaining content
+ // this small number is specifically chosen to demonstrate the chunking
+ // DO NOT USE SUCH SMALL NUMBER IN PRODUCTION
+ // Reducing the chunk size will increase the response time, thus reducing the server's capacity in processing concurrent requests
+ const int chunkSize = min((size_t)256, min(maxLen, htmlContentLength - index));
+ Serial.printf("sending: %u\n", chunkSize);
+
+ memcpy(buffer, htmlContent + index, chunkSize);
+
+ return chunkSize;
+ });
+
+ response->addHeader(asyncsrv::T_Cache_Control, "public,max-age=60");
+ response->addHeader(asyncsrv::T_ETag, etag);
+
+ request->send(response);
+ });
+
+ server.begin();
+}
+
+void loop() {
+ delay(100);
+}
diff --git a/libraries/ESP_Async_WebServer/examples/ChunkRetryResponse/ChunkRetryResponse.ino b/libraries/ESP_Async_WebServer/examples/ChunkRetryResponse/ChunkRetryResponse.ino
new file mode 100644
index 0000000..48772cc
--- /dev/null
+++ b/libraries/ESP_Async_WebServer/examples/ChunkRetryResponse/ChunkRetryResponse.ino
@@ -0,0 +1,216 @@
+// SPDX-License-Identifier: LGPL-3.0-or-later
+// Copyright 2016-2025 Hristo Gochkov, Mathieu Carbou, Emil Muratov
+
+//
+// Shows how to wait in a chunk response for incoming data
+//
+
+#include
+#ifdef ESP32
+#include
+#include
+#elif defined(ESP8266)
+#include
+#include
+#elif defined(TARGET_RP2040) || defined(TARGET_RP2350) || defined(PICO_RP2040) || defined(PICO_RP2350)
+#include
+#include
+#endif
+
+#include
+
+#if __has_include("ArduinoJson.h")
+#include
+#include
+#include
+#endif
+
+static const char *htmlContent PROGMEM = R"(
+
+
+
+ Sample HTML
+
+
+ Hello, World!
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin euismod, purus a euismod
+ rhoncus, urna ipsum cursus massa, eu dictum tellus justo ac justo. Quisque ullamcorper
+ arcu nec tortor ullamcorper, vel fermentum justo fermentum. Vivamus sed velit ut elit
+ accumsan congue ut ut enim. Ut eu justo eu lacus varius gravida ut a tellus. Nulla facilisi.
+ Integer auctor consectetur ultricies. Fusce feugiat, mi sit amet bibendum viverra, orci leo
+ dapibus elit, id varius sem dui id lacus.
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin euismod, purus a euismod
+ rhoncus, urna ipsum cursus massa, eu dictum tellus justo ac justo. Quisque ullamcorper
+ arcu nec tortor ullamcorper, vel fermentum justo fermentum. Vivamus sed velit ut elit
+ accumsan congue ut ut enim. Ut eu justo eu lacus varius gravida ut a tellus. Nulla facilisi.
+ Integer auctor consectetur ultricies. Fusce feugiat, mi sit amet bibendum viverra, orci leo
+ dapibus elit, id varius sem dui id lacus.
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin euismod, purus a euismod
+ rhoncus, urna ipsum cursus massa, eu dictum tellus justo ac justo. Quisque ullamcorper
+ arcu nec tortor ullamcorper, vel fermentum justo fermentum. Vivamus sed velit ut elit
+ accumsan congue ut ut enim. Ut eu justo eu lacus varius gravida ut a tellus. Nulla facilisi.
+ Integer auctor consectetur ultricies. Fusce feugiat, mi sit amet bibendum viverra, orci leo
+ dapibus elit, id varius sem dui id lacus.
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin euismod, purus a euismod
+ rhoncus, urna ipsum cursus massa, eu dictum tellus justo ac justo. Quisque ullamcorper
+ arcu nec tortor ullamcorper, vel fermentum justo fermentum. Vivamus sed velit ut elit
+ accumsan congue ut ut enim. Ut eu justo eu lacus varius gravida ut a tellus. Nulla facilisi.
+ Integer auctor consectetur ultricies. Fusce feugiat, mi sit amet bibendum viverra, orci leo
+ dapibus elit, id varius sem dui id lacus.
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin euismod, purus a euismod
+ rhoncus, urna ipsum cursus massa, eu dictum tellus justo ac justo. Quisque ullamcorper
+ arcu nec tortor ullamcorper, vel fermentum justo fermentum. Vivamus sed velit ut elit
+ accumsan congue ut ut enim. Ut eu justo eu lacus varius gravida ut a tellus. Nulla facilisi.
+ Integer auctor consectetur ultricies. Fusce feugiat, mi sit amet bibendum viverra, orci leo
+ dapibus elit, id varius sem dui id lacus.
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin euismod, purus a euismod
+ rhoncus, urna ipsum cursus massa, eu dictum tellus justo ac justo. Quisque ullamcorper
+ arcu nec tortor ullamcorper, vel fermentum justo fermentum. Vivamus sed velit ut elit
+ accumsan congue ut ut enim. Ut eu justo eu lacus varius gravida ut a tellus. Nulla facilisi.
+ Integer auctor consectetur ultricies. Fusce feugiat, mi sit amet bibendum viverra, orci leo
+ dapibus elit, id varius sem dui id lacus.
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin euismod, purus a euismod
+ rhoncus, urna ipsum cursus massa, eu dictum tellus justo ac justo. Quisque ullamcorper
+ arcu nec tortor ullamcorper, vel fermentum justo fermentum. Vivamus sed velit ut elit
+ accumsan congue ut ut enim. Ut eu justo eu lacus varius gravida ut a tellus. Nulla facilisi.
+ Integer auctor consectetur ultricies. Fusce feugiat, mi sit amet bibendum viverra, orci leo
+ dapibus elit, id varius sem dui id lacus.
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin euismod, purus a euismod
+ rhoncus, urna ipsum cursus massa, eu dictum tellus justo ac justo. Quisque ullamcorper
+ arcu nec tortor ullamcorper, vel fermentum justo fermentum. Vivamus sed velit ut elit
+ accumsan congue ut ut enim. Ut eu justo eu lacus varius gravida ut a tellus. Nulla facilisi.
+ Integer auctor consectetur ultricies. Fusce feugiat, mi sit amet bibendum viverra, orci leo
+ dapibus elit, id varius sem dui id lacus.
+
+
+)";
+
+static const size_t htmlContentLength = strlen_P(htmlContent);
+
+static AsyncWebServer server(80);
+static AsyncLoggingMiddleware requestLogger;
+
+static String triggerUART;
+static int key = -1;
+
+void setup() {
+ Serial.begin(115200);
+
+#ifndef CONFIG_IDF_TARGET_ESP32H2
+ WiFi.mode(WIFI_AP);
+ WiFi.softAP("esp-captive");
+#endif
+
+ // adds some internal request logging for debugging
+ requestLogger.setEnabled(true);
+ requestLogger.setOutput(Serial);
+
+ server.addMiddleware(&requestLogger);
+
+#if __has_include("ArduinoJson.h")
+
+ //
+ // HOW TO RUN THIS EXAMPLE:
+ //
+ // 1. Trigger a request that will be blocked for a long time:
+ // > time curl -v -X POST http://192.168.4.1/api -H "Content-Type: application/json" -d '{"input": "Please type a key to continue in Serial console..."}' --output -
+ //
+ // 2. While waiting, in another terminal, run some concurrent requests:
+ // > time curl -v http://192.168.4.1/
+ //
+ // 3. Type a key in the Serial console to continue the processing within 30 seconds.
+ // This should unblock the first request.
+ //
+ server.on("/", HTTP_GET, [](AsyncWebServerRequest *request) {
+ // need to cast to uint8_t*
+ // if you do not, the const char* will be copied in a temporary String buffer
+ request->send(200, "text/html", (uint8_t *)htmlContent, htmlContentLength);
+ });
+
+ server.on(
+ "/api", HTTP_POST,
+ [](AsyncWebServerRequest *request) {
+ // request parsing has finished
+
+ // no data ?
+ if (!((String *)request->_tempObject)->length()) {
+ request->send(400);
+ return;
+ }
+
+ JsonDocument doc;
+
+ // deserialize and check for errors
+ if (deserializeJson(doc, *(String *)request->_tempObject)) {
+ request->send(400);
+ return;
+ }
+
+ // start UART com: UART will send the data to the Serial console and wait for the key press
+ triggerUART = doc["input"].as();
+ key = -1;
+
+ AsyncWebServerResponse *response = request->beginChunkedResponse("text/plain", [](uint8_t *buffer, size_t maxLen, size_t index) -> size_t {
+ // still waiting for UARY ?
+ if (triggerUART.length() && key == -1) {
+ return RESPONSE_TRY_AGAIN;
+ }
+
+ // finished ?
+ if (!triggerUART.length() && key == -1) {
+ return 0; // 0 means we are done
+ }
+
+ // log_d("UART answered!");
+
+ String answer = "You typed: ";
+ answer.concat((char)key);
+
+ // note: I did not check for maxLen, but you should (see ChunkResponse.ino)
+ memcpy(buffer, answer.c_str(), answer.length());
+
+ // finish!
+ triggerUART = emptyString;
+ key = -1;
+
+ return answer.length();
+ });
+
+ request->send(response);
+ },
+ NULL, // upload handler is not used so it should be NULL
+ [](AsyncWebServerRequest *request, uint8_t *data, size_t len, size_t index, size_t total) {
+ // log_d("Body: index: %u, len: %u, total: %u", index, len, total);
+
+ if (!index) {
+ // log_d("Start body parsing");
+ request->_tempObject = new String();
+ // cast request->_tempObject pointer to String and reserve total size
+ ((String *)request->_tempObject)->reserve(total);
+ // set timeout 30s
+ request->client()->setRxTimeout(30);
+ }
+
+ // log_d("Append body data");
+ ((String *)request->_tempObject)->concat((const char *)data, len);
+ }
+ );
+
+#endif
+
+ server.begin();
+}
+
+void loop() {
+ if (triggerUART.length() && key == -1) {
+ Serial.println(triggerUART);
+ // log_d("Waiting for UART input...");
+ while (!Serial.available()) {
+ delay(100);
+ }
+ key = Serial.read();
+ Serial.flush();
+ // log_d("UART input: %c", key);
+ triggerUART = emptyString;
+ }
+}
diff --git a/libraries/ESP_Async_WebServer/examples/EndBegin/EndBegin.ino b/libraries/ESP_Async_WebServer/examples/EndBegin/EndBegin.ino
new file mode 100644
index 0000000..acfc6ff
--- /dev/null
+++ b/libraries/ESP_Async_WebServer/examples/EndBegin/EndBegin.ino
@@ -0,0 +1,49 @@
+// SPDX-License-Identifier: LGPL-3.0-or-later
+// Copyright 2016-2025 Hristo Gochkov, Mathieu Carbou, Emil Muratov
+
+//
+// https://github.com/ESP32Async/ESPAsyncWebServer/discussions/23
+//
+
+#include
+#ifdef ESP32
+#include
+#include
+#elif defined(ESP8266)
+#include
+#include
+#elif defined(TARGET_RP2040) || defined(TARGET_RP2350) || defined(PICO_RP2040) || defined(PICO_RP2350)
+#include
+#include
+#endif
+
+#include
+
+static AsyncWebServer server(80);
+
+void setup() {
+ Serial.begin(115200);
+
+#ifndef CONFIG_IDF_TARGET_ESP32H2
+ WiFi.mode(WIFI_AP);
+ WiFi.softAP("esp-captive");
+#endif
+
+ server.on("/", HTTP_GET, [](AsyncWebServerRequest *request) {
+ request->send(200, "text/plain", "Hello, world");
+ });
+
+ server.begin();
+ Serial.println("begin() - run: curl -v http://192.168.4.1/ => should succeed");
+ delay(10000);
+
+ Serial.println("end()");
+ server.end();
+ server.begin();
+ Serial.println("begin() - run: curl -v http://192.168.4.1/ => should succeed");
+}
+
+// not needed
+void loop() {
+ delay(100);
+}
diff --git a/libraries/ESP_Async_WebServer/examples/Filters/Filters.ino b/libraries/ESP_Async_WebServer/examples/Filters/Filters.ino
new file mode 100644
index 0000000..519478c
--- /dev/null
+++ b/libraries/ESP_Async_WebServer/examples/Filters/Filters.ino
@@ -0,0 +1,136 @@
+// SPDX-License-Identifier: LGPL-3.0-or-later
+// Copyright 2016-2025 Hristo Gochkov, Mathieu Carbou, Emil Muratov
+
+//
+// Shows how to use setFilter to route requests to different handlers based on WiFi mode
+//
+
+#include
+#ifdef ESP32
+#include
+#include
+#elif defined(ESP8266)
+#include
+#include
+#elif defined(TARGET_RP2040) || defined(TARGET_RP2350) || defined(PICO_RP2040) || defined(PICO_RP2350)
+#include
+#include
+#endif
+#include "ESPAsyncWebServer.h"
+
+static DNSServer dnsServer;
+static AsyncWebServer server(80);
+
+class CaptiveRequestHandler : public AsyncWebHandler {
+public:
+ bool canHandle(__unused AsyncWebServerRequest *request) const override {
+ return true;
+ }
+
+ void handleRequest(AsyncWebServerRequest *request) override {
+ AsyncResponseStream *response = request->beginResponseStream("text/html");
+ response->print("Captive Portal");
+ response->print("This is out captive portal front page.
");
+ response->printf("You were trying to reach: http://%s%s
", request->host().c_str(), request->url().c_str());
+#ifndef CONFIG_IDF_TARGET_ESP32H2
+ response->printf("Try opening this link instead
", WiFi.softAPIP().toString().c_str());
+#endif
+ response->print("");
+ request->send(response);
+ }
+};
+
+bool hit1 = false;
+bool hit2 = false;
+
+void setup() {
+ Serial.begin(115200);
+
+ server
+ .on(
+ "/", HTTP_GET,
+ [](AsyncWebServerRequest *request) {
+ Serial.println("Captive portal request...");
+#ifndef CONFIG_IDF_TARGET_ESP32H2
+ Serial.println("WiFi.localIP(): " + WiFi.localIP().toString());
+#endif
+ Serial.println("request->client()->localIP(): " + request->client()->localIP().toString());
+#if ESP_IDF_VERSION_MAJOR >= 5
+#ifndef CONFIG_IDF_TARGET_ESP32H2
+ Serial.println("WiFi.type(): " + String((int)WiFi.localIP().type()));
+#endif
+ Serial.println("request->client()->type(): " + String((int)request->client()->localIP().type()));
+#endif
+#ifndef CONFIG_IDF_TARGET_ESP32H2
+ Serial.println(WiFi.localIP() == request->client()->localIP() ? "should be: ON_STA_FILTER" : "should be: ON_AP_FILTER");
+ Serial.println(WiFi.localIP() == request->client()->localIP());
+ Serial.println(WiFi.localIP().toString() == request->client()->localIP().toString());
+#endif
+ request->send(200, "text/plain", "This is the captive portal");
+ hit1 = true;
+ }
+ )
+ .setFilter(ON_AP_FILTER);
+
+ server
+ .on(
+ "/", HTTP_GET,
+ [](AsyncWebServerRequest *request) {
+ Serial.println("Website request...");
+#ifndef CONFIG_IDF_TARGET_ESP32H2
+ Serial.println("WiFi.localIP(): " + WiFi.localIP().toString());
+#endif
+ Serial.println("request->client()->localIP(): " + request->client()->localIP().toString());
+#if ESP_IDF_VERSION_MAJOR >= 5
+#ifndef CONFIG_IDF_TARGET_ESP32H2
+ Serial.println("WiFi.type(): " + String((int)WiFi.localIP().type()));
+#endif
+ Serial.println("request->client()->type(): " + String((int)request->client()->localIP().type()));
+#endif
+#ifndef CONFIG_IDF_TARGET_ESP32H2
+ Serial.println(WiFi.localIP() == request->client()->localIP() ? "should be: ON_STA_FILTER" : "should be: ON_AP_FILTER");
+ Serial.println(WiFi.localIP() == request->client()->localIP());
+ Serial.println(WiFi.localIP().toString() == request->client()->localIP().toString());
+#endif
+ request->send(200, "text/plain", "This is the website");
+ hit2 = true;
+ }
+ )
+ .setFilter(ON_STA_FILTER);
+
+ // assert(WiFi.softAP("esp-captive-portal"));
+ // dnsServer.start(53, "*", WiFi.softAPIP());
+ // server.begin();
+ // Serial.println("Captive portal started!");
+
+ // while (!hit1) {
+ // dnsServer.processNextRequest();
+ // yield();
+ // }
+ // delay(1000); // Wait for the client to process the response
+
+ // Serial.println("Captive portal opened, stopping it and connecting to WiFi...");
+ // dnsServer.stop();
+ // WiFi.softAPdisconnect();
+
+#ifndef CONFIG_IDF_TARGET_ESP32H2
+ WiFi.persistent(false);
+ WiFi.begin("IoT");
+ while (WiFi.status() != WL_CONNECTED) {
+ delay(500);
+ }
+ Serial.println("Connected to WiFi with IP address: " + WiFi.localIP().toString());
+#endif
+
+ server.begin();
+
+ // while (!hit2) {
+ // delay(10);
+ // }
+ // delay(1000); // Wait for the client to process the response
+ // ESP.restart();
+}
+
+void loop() {
+ delay(100);
+}
diff --git a/libraries/ESP_Async_WebServer/examples/FlashResponse/FlashResponse.ino b/libraries/ESP_Async_WebServer/examples/FlashResponse/FlashResponse.ino
new file mode 100644
index 0000000..6948cd2
--- /dev/null
+++ b/libraries/ESP_Async_WebServer/examples/FlashResponse/FlashResponse.ino
@@ -0,0 +1,107 @@
+// SPDX-License-Identifier: LGPL-3.0-or-later
+// Copyright 2016-2025 Hristo Gochkov, Mathieu Carbou, Emil Muratov
+
+//
+// Shows how to serve a large HTML page from flash memory without copying it to heap in a temporary buffer
+//
+
+#include
+#ifdef ESP32
+#include
+#include
+#elif defined(ESP8266)
+#include
+#include
+#elif defined(TARGET_RP2040) || defined(TARGET_RP2350) || defined(PICO_RP2040) || defined(PICO_RP2350)
+#include
+#include
+#endif
+
+#include
+
+static AsyncWebServer server(80);
+
+static const char *htmlContent PROGMEM = R"(
+
+
+
+ Sample HTML
+
+
+ Hello, World!
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin euismod, purus a euismod
+ rhoncus, urna ipsum cursus massa, eu dictum tellus justo ac justo. Quisque ullamcorper
+ arcu nec tortor ullamcorper, vel fermentum justo fermentum. Vivamus sed velit ut elit
+ accumsan congue ut ut enim. Ut eu justo eu lacus varius gravida ut a tellus. Nulla facilisi.
+ Integer auctor consectetur ultricies. Fusce feugiat, mi sit amet bibendum viverra, orci leo
+ dapibus elit, id varius sem dui id lacus.
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin euismod, purus a euismod
+ rhoncus, urna ipsum cursus massa, eu dictum tellus justo ac justo. Quisque ullamcorper
+ arcu nec tortor ullamcorper, vel fermentum justo fermentum. Vivamus sed velit ut elit
+ accumsan congue ut ut enim. Ut eu justo eu lacus varius gravida ut a tellus. Nulla facilisi.
+ Integer auctor consectetur ultricies. Fusce feugiat, mi sit amet bibendum viverra, orci leo
+ dapibus elit, id varius sem dui id lacus.
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin euismod, purus a euismod
+ rhoncus, urna ipsum cursus massa, eu dictum tellus justo ac justo. Quisque ullamcorper
+ arcu nec tortor ullamcorper, vel fermentum justo fermentum. Vivamus sed velit ut elit
+ accumsan congue ut ut enim. Ut eu justo eu lacus varius gravida ut a tellus. Nulla facilisi.
+ Integer auctor consectetur ultricies. Fusce feugiat, mi sit amet bibendum viverra, orci leo
+ dapibus elit, id varius sem dui id lacus.
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin euismod, purus a euismod
+ rhoncus, urna ipsum cursus massa, eu dictum tellus justo ac justo. Quisque ullamcorper
+ arcu nec tortor ullamcorper, vel fermentum justo fermentum. Vivamus sed velit ut elit
+ accumsan congue ut ut enim. Ut eu justo eu lacus varius gravida ut a tellus. Nulla facilisi.
+ Integer auctor consectetur ultricies. Fusce feugiat, mi sit amet bibendum viverra, orci leo
+ dapibus elit, id varius sem dui id lacus.
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin euismod, purus a euismod
+ rhoncus, urna ipsum cursus massa, eu dictum tellus justo ac justo. Quisque ullamcorper
+ arcu nec tortor ullamcorper, vel fermentum justo fermentum. Vivamus sed velit ut elit
+ accumsan congue ut ut enim. Ut eu justo eu lacus varius gravida ut a tellus. Nulla facilisi.
+ Integer auctor consectetur ultricies. Fusce feugiat, mi sit amet bibendum viverra, orci leo
+ dapibus elit, id varius sem dui id lacus.
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin euismod, purus a euismod
+ rhoncus, urna ipsum cursus massa, eu dictum tellus justo ac justo. Quisque ullamcorper
+ arcu nec tortor ullamcorper, vel fermentum justo fermentum. Vivamus sed velit ut elit
+ accumsan congue ut ut enim. Ut eu justo eu lacus varius gravida ut a tellus. Nulla facilisi.
+ Integer auctor consectetur ultricies. Fusce feugiat, mi sit amet bibendum viverra, orci leo
+ dapibus elit, id varius sem dui id lacus.
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin euismod, purus a euismod
+ rhoncus, urna ipsum cursus massa, eu dictum tellus justo ac justo. Quisque ullamcorper
+ arcu nec tortor ullamcorper, vel fermentum justo fermentum. Vivamus sed velit ut elit
+ accumsan congue ut ut enim. Ut eu justo eu lacus varius gravida ut a tellus. Nulla facilisi.
+ Integer auctor consectetur ultricies. Fusce feugiat, mi sit amet bibendum viverra, orci leo
+ dapibus elit, id varius sem dui id lacus.
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin euismod, purus a euismod
+ rhoncus, urna ipsum cursus massa, eu dictum tellus justo ac justo. Quisque ullamcorper
+ arcu nec tortor ullamcorper, vel fermentum justo fermentum. Vivamus sed velit ut elit
+ accumsan congue ut ut enim. Ut eu justo eu lacus varius gravida ut a tellus. Nulla facilisi.
+ Integer auctor consectetur ultricies. Fusce feugiat, mi sit amet bibendum viverra, orci leo
+ dapibus elit, id varius sem dui id lacus.
+
+
+)";
+
+static const size_t htmlContentLength = strlen_P(htmlContent);
+
+void setup() {
+ Serial.begin(115200);
+
+#ifndef CONFIG_IDF_TARGET_ESP32H2
+ WiFi.mode(WIFI_AP);
+ WiFi.softAP("esp-captive");
+#endif
+
+ // curl -v http://192.168.4.1/
+ server.on("/", HTTP_GET, [](AsyncWebServerRequest *request) {
+ // need to cast to uint8_t*
+ // if you do not, the const char* will be copied in a temporary String buffer
+ request->send(200, "text/html", (uint8_t *)htmlContent, htmlContentLength);
+ });
+
+ server.begin();
+}
+
+// not needed
+void loop() {
+ delay(100);
+}
diff --git a/libraries/ESP_Async_WebServer/examples/HeaderManipulation/HeaderManipulation.ino b/libraries/ESP_Async_WebServer/examples/HeaderManipulation/HeaderManipulation.ino
new file mode 100644
index 0000000..4fe34dc
--- /dev/null
+++ b/libraries/ESP_Async_WebServer/examples/HeaderManipulation/HeaderManipulation.ino
@@ -0,0 +1,88 @@
+// SPDX-License-Identifier: LGPL-3.0-or-later
+// Copyright 2016-2025 Hristo Gochkov, Mathieu Carbou, Emil Muratov
+
+//
+// Show how to manipulate headers in the request / response
+//
+
+#include
+#ifdef ESP32
+#include
+#include
+#elif defined(ESP8266)
+#include
+#include
+#elif defined(TARGET_RP2040) || defined(TARGET_RP2350) || defined(PICO_RP2040) || defined(PICO_RP2350)
+#include
+#include
+#endif
+
+#include
+
+static AsyncWebServer server(80);
+
+// request logger
+static AsyncLoggingMiddleware requestLogger;
+
+// filter out specific headers from the incoming request
+static AsyncHeaderFilterMiddleware headerFilter;
+
+// remove all headers from the incoming request except the ones provided in the constructor
+AsyncHeaderFreeMiddleware headerFree;
+
+void setup() {
+ Serial.begin(115200);
+
+#ifndef CONFIG_IDF_TARGET_ESP32H2
+ WiFi.mode(WIFI_AP);
+ WiFi.softAP("esp-captive");
+#endif
+
+ requestLogger.setEnabled(true);
+ requestLogger.setOutput(Serial);
+
+ headerFilter.filter("X-Remove-Me");
+
+ headerFree.keep("X-Keep-Me");
+ headerFree.keep("host");
+
+ server.addMiddlewares({&requestLogger, &headerFilter});
+
+ // x-remove-me header will be removed
+ //
+ // curl -v -H "X-Header: Foo" -H "x-remove-me: value" http://192.168.4.1/remove
+ //
+ server.on("/remove", HTTP_GET, [](AsyncWebServerRequest *request) {
+ // print all headers
+ for (size_t i = 0; i < request->headers(); i++) {
+ const AsyncWebHeader *h = request->getHeader(i);
+ Serial.printf("Header[%s]: %s\n", h->name().c_str(), h->value().c_str());
+ }
+ request->send(200, "text/plain", "Hello, world!");
+ });
+
+ // Only headers x-keep-me and host will be kept
+ //
+ // curl -v -H "x-keep-me: value" -H "x-remove-me: value" http://192.168.4.1/keep
+ //
+ server
+ .on(
+ "/keep", HTTP_GET,
+ [](AsyncWebServerRequest *request) {
+ // print all headers
+ for (size_t i = 0; i < request->headers(); i++) {
+ const AsyncWebHeader *h = request->getHeader(i);
+ Serial.printf("Header[%s]: %s\n", h->name().c_str(), h->value().c_str());
+ }
+ request->send(200, "text/plain", "Hello, world!");
+ }
+ )
+ .addMiddleware(&headerFree);
+
+ server.begin();
+}
+
+// not needed
+void loop() {
+ delay(100);
+}
diff --git a/libraries/ESP_Async_WebServer/examples/Headers/Headers.ino b/libraries/ESP_Async_WebServer/examples/Headers/Headers.ino
new file mode 100644
index 0000000..e07c515
--- /dev/null
+++ b/libraries/ESP_Async_WebServer/examples/Headers/Headers.ino
@@ -0,0 +1,69 @@
+// SPDX-License-Identifier: LGPL-3.0-or-later
+// Copyright 2016-2025 Hristo Gochkov, Mathieu Carbou, Emil Muratov
+
+//
+// Query and send headers
+//
+
+#include
+#ifdef ESP32
+#include
+#include
+#elif defined(ESP8266)
+#include
+#include
+#elif defined(TARGET_RP2040) || defined(TARGET_RP2350) || defined(PICO_RP2040) || defined(PICO_RP2350)
+#include
+#include
+#endif
+
+#include
+
+static AsyncWebServer server(80);
+
+void setup() {
+ Serial.begin(115200);
+
+#ifndef CONFIG_IDF_TARGET_ESP32H2
+ WiFi.mode(WIFI_AP);
+ WiFi.softAP("esp-captive");
+#endif
+
+ //
+ // curl -v http://192.168.4.1
+ //
+ server.on("/", HTTP_GET, [](AsyncWebServerRequest *request) {
+ //List all collected headers
+ int headers = request->headers();
+ int i;
+ for (i = 0; i < headers; i++) {
+ const AsyncWebHeader *h = request->getHeader(i);
+ Serial.printf("HEADER[%s]: %s\n", h->name().c_str(), h->value().c_str());
+ }
+
+ AsyncWebServerResponse *response = request->beginResponse(200, "text/plain", "Hello World!");
+
+ //Add header to the response
+ response->addHeader("Server", "ESP Async Web Server");
+
+ //Add multiple headers with the same name
+ response->addHeader("Set-Cookie", "sessionId=38afes7a8", false);
+ response->addHeader("Set-Cookie", "id=a3fWa; Max-Age=2592000", false);
+ response->addHeader("Set-Cookie", "qwerty=219ffwef9w0f; Domain=example.com", false);
+
+ //Remove specific header
+ response->removeHeader("Set-Cookie", "sessionId=38afes7a8");
+
+ //Remove all headers with the same name
+ response->removeHeader("Set-Cookie");
+
+ request->send(response);
+ });
+
+ server.begin();
+}
+
+void loop() {
+ //Sleep in the loop task to not keep the CPU busy
+ delay(1000);
+}
diff --git a/libraries/ESP_Async_WebServer/examples/Json/Json.ino b/libraries/ESP_Async_WebServer/examples/Json/Json.ino
new file mode 100644
index 0000000..0ea8892
--- /dev/null
+++ b/libraries/ESP_Async_WebServer/examples/Json/Json.ino
@@ -0,0 +1,90 @@
+// SPDX-License-Identifier: LGPL-3.0-or-later
+// Copyright 2016-2025 Hristo Gochkov, Mathieu Carbou, Emil Muratov
+
+//
+// Shows how to send and receive Json data
+//
+
+#include
+#ifdef ESP32
+#include
+#include
+#elif defined(ESP8266)
+#include
+#include
+#elif defined(TARGET_RP2040) || defined(TARGET_RP2350) || defined(PICO_RP2040) || defined(PICO_RP2350)
+#include
+#include
+#endif
+
+#include
+
+#if __has_include("ArduinoJson.h")
+#include
+#include
+#include
+#endif
+
+static AsyncWebServer server(80);
+
+#if __has_include("ArduinoJson.h")
+static AsyncCallbackJsonWebHandler *handler = new AsyncCallbackJsonWebHandler("/json2");
+#endif
+
+void setup() {
+ Serial.begin(115200);
+
+#ifndef CONFIG_IDF_TARGET_ESP32H2
+ WiFi.mode(WIFI_AP);
+ WiFi.softAP("esp-captive");
+#endif
+
+#if __has_include("ArduinoJson.h")
+ //
+ // sends JSON using AsyncJsonResponse
+ //
+ // curl -v http://192.168.4.1/json1
+ //
+ server.on("/json1", HTTP_GET, [](AsyncWebServerRequest *request) {
+ AsyncJsonResponse *response = new AsyncJsonResponse();
+ JsonObject root = response->getRoot().to();
+ root["hello"] = "world";
+ response->setLength();
+ request->send(response);
+ });
+
+ // Send JSON using AsyncResponseStream
+ //
+ // curl -v http://192.168.4.1/json2
+ //
+ server.on("/json2", HTTP_GET, [](AsyncWebServerRequest *request) {
+ AsyncResponseStream *response = request->beginResponseStream("application/json");
+ JsonDocument doc;
+ JsonObject root = doc.to();
+ root["foo"] = "bar";
+ serializeJson(root, *response);
+ request->send(response);
+ });
+
+ // curl -v -X POST -H 'Content-Type: application/json' -d '{"name":"You"}' http://192.168.4.1/json2
+ // curl -v -X PUT -H 'Content-Type: application/json' -d '{"name":"You"}' http://192.168.4.1/json2
+ handler->setMethod(HTTP_POST | HTTP_PUT);
+ handler->onRequest([](AsyncWebServerRequest *request, JsonVariant &json) {
+ serializeJson(json, Serial);
+ AsyncJsonResponse *response = new AsyncJsonResponse();
+ JsonObject root = response->getRoot().to();
+ root["hello"] = json.as()["name"];
+ response->setLength();
+ request->send(response);
+ });
+
+ server.addHandler(handler);
+#endif
+
+ server.begin();
+}
+
+// not needed
+void loop() {
+ delay(100);
+}
diff --git a/libraries/ESP_Async_WebServer/examples/Logging/Logging.ino b/libraries/ESP_Async_WebServer/examples/Logging/Logging.ino
new file mode 100644
index 0000000..6485185
--- /dev/null
+++ b/libraries/ESP_Async_WebServer/examples/Logging/Logging.ino
@@ -0,0 +1,49 @@
+// SPDX-License-Identifier: LGPL-3.0-or-later
+// Copyright 2016-2025 Hristo Gochkov, Mathieu Carbou, Emil Muratov
+
+//
+// Show how to log the incoming request and response as a curl-like syntax
+//
+
+#include
+#ifdef ESP32
+#include
+#include
+#elif defined(ESP8266)
+#include
+#include
+#elif defined(TARGET_RP2040) || defined(TARGET_RP2350) || defined(PICO_RP2040) || defined(PICO_RP2350)
+#include
+#include
+#endif
+
+#include
+
+static AsyncWebServer server(80);
+static AsyncLoggingMiddleware requestLogger;
+
+void setup() {
+ Serial.begin(115200);
+
+#ifndef CONFIG_IDF_TARGET_ESP32H2
+ WiFi.mode(WIFI_AP);
+ WiFi.softAP("esp-captive");
+#endif
+
+ requestLogger.setEnabled(true);
+ requestLogger.setOutput(Serial);
+
+ server.addMiddleware(&requestLogger);
+
+ // curl -v -H "X-Header:Foo" http://192.168.4.1/
+ server.on("/", HTTP_GET, [](AsyncWebServerRequest *request) {
+ request->send(200, "text/plain", "Hello, world!");
+ });
+
+ server.begin();
+}
+
+// not needed
+void loop() {
+ delay(100);
+}
diff --git a/libraries/ESP_Async_WebServer/examples/MessagePack/MessagePack.ino b/libraries/ESP_Async_WebServer/examples/MessagePack/MessagePack.ino
new file mode 100644
index 0000000..4fea247
--- /dev/null
+++ b/libraries/ESP_Async_WebServer/examples/MessagePack/MessagePack.ino
@@ -0,0 +1,88 @@
+// SPDX-License-Identifier: LGPL-3.0-or-later
+// Copyright 2016-2025 Hristo Gochkov, Mathieu Carbou, Emil Muratov
+
+//
+// Shows how to send and receive Message Pack data
+//
+
+#include
+#ifdef ESP32
+#include
+#include
+#elif defined(ESP8266)
+#include
+#include
+#elif defined(TARGET_RP2040) || defined(TARGET_RP2350) || defined(PICO_RP2040) || defined(PICO_RP2350)
+#include
+#include
+#endif
+
+#include
+
+#if __has_include("ArduinoJson.h")
+#include
+#include
+#include
+#endif
+
+static AsyncWebServer server(80);
+
+#if __has_include("ArduinoJson.h")
+static AsyncCallbackMessagePackWebHandler *handler = new AsyncCallbackMessagePackWebHandler("/msgpack2");
+#endif
+
+void setup() {
+ Serial.begin(115200);
+
+#ifndef CONFIG_IDF_TARGET_ESP32H2
+ WiFi.mode(WIFI_AP);
+ WiFi.softAP("esp-captive");
+#endif
+
+#if __has_include("ArduinoJson.h")
+ //
+ // sends MessagePack using AsyncMessagePackResponse
+ //
+ // curl -v http://192.168.4.1/msgpack1
+ //
+ server.on("/msgpack1", HTTP_GET, [](AsyncWebServerRequest *request) {
+ AsyncMessagePackResponse *response = new AsyncMessagePackResponse();
+ JsonObject root = response->getRoot().to();
+ root["hello"] = "world";
+ response->setLength();
+ request->send(response);
+ });
+
+ // Send MessagePack using AsyncResponseStream
+ //
+ // curl -v http://192.168.4.1/msgpack2
+ //
+ server.on("/msgpack2", HTTP_GET, [](AsyncWebServerRequest *request) {
+ AsyncResponseStream *response = request->beginResponseStream("application/msgpack");
+ JsonDocument doc;
+ JsonObject root = doc.to();
+ root["foo"] = "bar";
+ serializeMsgPack(root, *response);
+ request->send(response);
+ });
+
+ handler->setMethod(HTTP_POST | HTTP_PUT);
+ handler->onRequest([](AsyncWebServerRequest *request, JsonVariant &json) {
+ serializeJson(json, Serial);
+ AsyncMessagePackResponse *response = new AsyncMessagePackResponse();
+ JsonObject root = response->getRoot().to();
+ root["hello"] = json.as()["name"];
+ response->setLength();
+ request->send(response);
+ });
+
+ server.addHandler(handler);
+#endif
+
+ server.begin();
+}
+
+// not needed
+void loop() {
+ delay(100);
+}
diff --git a/libraries/ESP_Async_WebServer/examples/Middleware/Middleware.ino b/libraries/ESP_Async_WebServer/examples/Middleware/Middleware.ino
new file mode 100644
index 0000000..c52f949
--- /dev/null
+++ b/libraries/ESP_Async_WebServer/examples/Middleware/Middleware.ino
@@ -0,0 +1,82 @@
+// SPDX-License-Identifier: LGPL-3.0-or-later
+// Copyright 2016-2025 Hristo Gochkov, Mathieu Carbou, Emil Muratov
+
+//
+// Show how to sue Middleware
+//
+
+#include
+#ifdef ESP32
+#include
+#include
+#elif defined(ESP8266)
+#include
+#include
+#elif defined(TARGET_RP2040) || defined(TARGET_RP2350) || defined(PICO_RP2040) || defined(PICO_RP2350)
+#include
+#include
+#endif
+
+#include
+
+static AsyncWebServer server(80);
+
+// New middleware classes can be created!
+class MyMiddleware : public AsyncMiddleware {
+public:
+ void run(AsyncWebServerRequest *request, ArMiddlewareNext next) override {
+ Serial.printf("Before handler: %s %s\n", request->methodToString(), request->url().c_str());
+ next(); // continue middleware chain
+ Serial.printf("After handler: response code=%d\n", request->getResponse()->code());
+ }
+};
+
+void setup() {
+ Serial.begin(115200);
+
+#ifndef CONFIG_IDF_TARGET_ESP32H2
+ WiFi.mode(WIFI_AP);
+ WiFi.softAP("esp-captive");
+#endif
+
+ // add a global middleware to the server
+ server.addMiddleware(new MyMiddleware());
+
+ // Test with:
+ //
+ // - curl -v http://192.168.4.1/ => 200 OK
+ // - curl -v http://192.168.4.1/?user=anon => 403 Forbidden
+ // - curl -v http://192.168.4.1/?user=foo => 200 OK
+ // - curl -v http://192.168.4.1/?user=error => 400 ERROR
+ //
+ AsyncCallbackWebHandler &handler = server.on("/", HTTP_GET, [](AsyncWebServerRequest *request) {
+ Serial.printf("In Handler: %s %s\n", request->methodToString(), request->url().c_str());
+ request->send(200, "text/plain", "Hello, world!");
+ });
+
+ // add a middleware to this handler only to send 403 if the user is anon
+ handler.addMiddleware([](AsyncWebServerRequest *request, ArMiddlewareNext next) {
+ Serial.println("Checking user=anon");
+ if (request->hasParam("user") && request->getParam("user")->value() == "anon") {
+ request->send(403, "text/plain", "Forbidden");
+ } else {
+ next();
+ }
+ });
+
+ // add a middleware to this handler that will replace the previously created response by another one
+ handler.addMiddleware([](AsyncWebServerRequest *request, ArMiddlewareNext next) {
+ next();
+ Serial.println("Checking user=error");
+ if (request->hasParam("user") && request->getParam("user")->value() == "error") {
+ request->send(400, "text/plain", "ERROR");
+ }
+ });
+
+ server.begin();
+}
+
+// not needed
+void loop() {
+ delay(100);
+}
diff --git a/libraries/ESP_Async_WebServer/examples/Params/Params.ino b/libraries/ESP_Async_WebServer/examples/Params/Params.ino
new file mode 100644
index 0000000..2c438a5
--- /dev/null
+++ b/libraries/ESP_Async_WebServer/examples/Params/Params.ino
@@ -0,0 +1,122 @@
+// SPDX-License-Identifier: LGPL-3.0-or-later
+// Copyright 2016-2025 Hristo Gochkov, Mathieu Carbou, Emil Muratov
+
+//
+// Query parameters and body parameters
+//
+
+#include
+#ifdef ESP32
+#include
+#include
+#elif defined(ESP8266)
+#include
+#include
+#elif defined(TARGET_RP2040) || defined(TARGET_RP2350) || defined(PICO_RP2040) || defined(PICO_RP2350)
+#include
+#include
+#endif
+
+#include
+
+static AsyncWebServer server(80);
+
+static const char *htmlContent PROGMEM = R"(
+
+
+
+ POST Request with Multiple Parameters
+
+
+
+
+
+)";
+
+static const size_t htmlContentLength = strlen_P(htmlContent);
+
+void setup() {
+ Serial.begin(115200);
+
+#ifndef CONFIG_IDF_TARGET_ESP32H2
+ WiFi.mode(WIFI_AP);
+ WiFi.softAP("esp-captive");
+#endif
+
+ // Get query parameters
+ //
+ // curl -v http://192.168.4.1/?who=Bob
+ //
+ server.on("/", HTTP_GET, [](AsyncWebServerRequest *request) {
+ if (request->hasParam("who")) {
+ Serial.printf("Who? %s\n", request->getParam("who")->value().c_str());
+ }
+
+ request->send(200, "text/html", (uint8_t *)htmlContent, htmlContentLength);
+ });
+
+ // Get form body parameters
+ //
+ // curl -v -H "Content-Type: application/x-www-form-urlencoded" -d "who=Carl" -d "param=value" http://192.168.4.1/
+ //
+ server.on("/", HTTP_POST, [](AsyncWebServerRequest *request) {
+ // display params
+ size_t count = request->params();
+ for (size_t i = 0; i < count; i++) {
+ const AsyncWebParameter *p = request->getParam(i);
+ Serial.printf("PARAM[%u]: %s = %s\n", i, p->name().c_str(), p->value().c_str());
+ }
+
+ // get who param
+ String who;
+ if (request->hasParam("who", true)) {
+ who = request->getParam("who", true)->value();
+ } else {
+ who = "No message sent";
+ }
+ request->send(200, "text/plain", "Hello " + who + "!");
+ });
+
+ server.begin();
+}
+
+// not needed
+void loop() {
+ delay(100);
+}
diff --git a/libraries/ESP_Async_WebServer/examples/PartitionDownloader/PartitionDownloader.ino b/libraries/ESP_Async_WebServer/examples/PartitionDownloader/PartitionDownloader.ino
new file mode 100644
index 0000000..3c76366
--- /dev/null
+++ b/libraries/ESP_Async_WebServer/examples/PartitionDownloader/PartitionDownloader.ino
@@ -0,0 +1,130 @@
+// SPDX-License-Identifier: LGPL-3.0-or-later
+// Copyright 2016-2025 Hristo Gochkov, Mathieu Carbou, Emil Muratov
+
+//
+// - Download ESP32 partition by name and/or type and/or subtype
+// - Support encrypted and non-encrypted partitions
+//
+
+#include
+#ifdef ESP32
+#include
+#include
+#elif defined(ESP8266)
+#include
+#include
+#elif defined(TARGET_RP2040) || defined(TARGET_RP2350) || defined(PICO_RP2040) || defined(PICO_RP2350)
+#include
+#include
+#endif
+
+#include
+#include
+
+#ifndef ESP32
+// this example is only for the ESP32
+void setup() {}
+void loop() {}
+#else
+
+#include
+
+static AsyncWebServer server(80);
+
+void setup() {
+ Serial.begin(115200);
+
+#ifndef CONFIG_IDF_TARGET_ESP32H2
+ WiFi.mode(WIFI_AP);
+ WiFi.softAP("esp-captive");
+#endif
+
+ LittleFS.begin(true);
+
+ // To upload the FS partition, run:
+ // > pio run -e arduino-3 -t buildfs
+ // > pio run -e arduino-3 -t uploadfs
+ //
+ // Examples:
+ //
+ // - Download the partition named "spiffs": http://192.168.4.1/partition?label=spiffs
+ // - Download the partition named "spiffs" with type "data": http://192.168.4.1/partition?label=spiffs&type=1
+ // - Download the partition named "spiffs" with type "data" and subtype "spiffs": http://192.168.4.1/partition?label=spiffs&type=1&subtype=130
+ // - Download the partition with subtype "nvs": http://192.168.4.1/partition?type=1&subtype=2
+ //
+ // "type" and "subtype" IDs can be found in esp_partition.h header file.
+ //
+ // Add "&raw=false" parameter to download the partition unencrypted (for encrypted partitions).
+ // By default, the raw partition is downloaded, so if a partition is encrypted, the encrypted data will be downloaded.
+ //
+ // To browse a downloaded LittleFS partition, you can use https://tniessen.github.io/littlefs-disk-img-viewer/ (block size is 4096)
+ //
+ server.on("/partition", HTTP_GET, [](AsyncWebServerRequest *request) {
+ const AsyncWebParameter *pLabel = request->getParam("label");
+ const AsyncWebParameter *pType = request->getParam("type");
+ const AsyncWebParameter *pSubtype = request->getParam("subtype");
+ const AsyncWebParameter *pRaw = request->getParam("raw");
+
+ if (!pLabel && !pType && !pSubtype) {
+ request->send(400, "text/plain", "Bad request: missing parameter");
+ return;
+ }
+
+ esp_partition_type_t type = ESP_PARTITION_TYPE_ANY;
+ esp_partition_subtype_t subtype = ESP_PARTITION_SUBTYPE_ANY;
+ const char *label = nullptr;
+ bool raw = true;
+
+ if (pLabel) {
+ label = pLabel->value().c_str();
+ }
+
+ if (pType) {
+ type = (esp_partition_type_t)pType->value().toInt();
+ }
+
+ if (pSubtype) {
+ subtype = (esp_partition_subtype_t)pSubtype->value().toInt();
+ }
+
+ if (pRaw && pRaw->value() == "false") {
+ raw = false;
+ }
+
+ const esp_partition_t *partition = esp_partition_find_first(type, subtype, label);
+
+ if (!partition) {
+ request->send(404, "text/plain", "Partition not found");
+ return;
+ }
+
+ AsyncWebServerResponse *response =
+ request->beginChunkedResponse("application/octet-stream", [partition, raw](uint8_t *buffer, size_t maxLen, size_t index) -> size_t {
+ const size_t remaining = partition->size - index;
+ if (!remaining) {
+ return 0;
+ }
+ const size_t len = std::min(maxLen, remaining);
+ if (raw && esp_partition_read_raw(partition, index, buffer, len) == ESP_OK) {
+ return len;
+ }
+ if (!raw && esp_partition_read(partition, index, buffer, len) == ESP_OK) {
+ return len;
+ }
+ return 0;
+ });
+
+ response->addHeader("Content-Disposition", "attachment; filename=" + String(partition->label) + ".bin");
+ response->setContentLength(partition->size);
+
+ request->send(response);
+ });
+
+ server.begin();
+}
+
+void loop() {
+ delay(100);
+}
+
+#endif
diff --git a/libraries/ESP_Async_WebServer/examples/PerfTests/PerfTests.ino b/libraries/ESP_Async_WebServer/examples/PerfTests/PerfTests.ino
new file mode 100644
index 0000000..6467d2c
--- /dev/null
+++ b/libraries/ESP_Async_WebServer/examples/PerfTests/PerfTests.ino
@@ -0,0 +1,243 @@
+// SPDX-License-Identifier: LGPL-3.0-or-later
+// Copyright 2016-2025 Hristo Gochkov, Mathieu Carbou, Emil Muratov
+
+//
+// Perf tests
+//
+
+#include
+#ifdef ESP32
+#include
+#include
+#elif defined(ESP8266)
+#include
+#include
+#elif defined(TARGET_RP2040) || defined(TARGET_RP2350) || defined(PICO_RP2040) || defined(PICO_RP2350)
+#include
+#include
+#endif
+
+#include
+
+static const char *htmlContent PROGMEM = R"(
+
+
+
+ Sample HTML
+
+
+ Hello, World!
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin euismod, purus a euismod
+ rhoncus, urna ipsum cursus massa, eu dictum tellus justo ac justo. Quisque ullamcorper
+ arcu nec tortor ullamcorper, vel fermentum justo fermentum. Vivamus sed velit ut elit
+ accumsan congue ut ut enim. Ut eu justo eu lacus varius gravida ut a tellus. Nulla facilisi.
+ Integer auctor consectetur ultricies. Fusce feugiat, mi sit amet bibendum viverra, orci leo
+ dapibus elit, id varius sem dui id lacus.
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin euismod, purus a euismod
+ rhoncus, urna ipsum cursus massa, eu dictum tellus justo ac justo. Quisque ullamcorper
+ arcu nec tortor ullamcorper, vel fermentum justo fermentum. Vivamus sed velit ut elit
+ accumsan congue ut ut enim. Ut eu justo eu lacus varius gravida ut a tellus. Nulla facilisi.
+ Integer auctor consectetur ultricies. Fusce feugiat, mi sit amet bibendum viverra, orci leo
+ dapibus elit, id varius sem dui id lacus.
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin euismod, purus a euismod
+ rhoncus, urna ipsum cursus massa, eu dictum tellus justo ac justo. Quisque ullamcorper
+ arcu nec tortor ullamcorper, vel fermentum justo fermentum. Vivamus sed velit ut elit
+ accumsan congue ut ut enim. Ut eu justo eu lacus varius gravida ut a tellus. Nulla facilisi.
+ Integer auctor consectetur ultricies. Fusce feugiat, mi sit amet bibendum viverra, orci leo
+ dapibus elit, id varius sem dui id lacus.
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin euismod, purus a euismod
+ rhoncus, urna ipsum cursus massa, eu dictum tellus justo ac justo. Quisque ullamcorper
+ arcu nec tortor ullamcorper, vel fermentum justo fermentum. Vivamus sed velit ut elit
+ accumsan congue ut ut enim. Ut eu justo eu lacus varius gravida ut a tellus. Nulla facilisi.
+ Integer auctor consectetur ultricies. Fusce feugiat, mi sit amet bibendum viverra, orci leo
+ dapibus elit, id varius sem dui id lacus.
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin euismod, purus a euismod
+ rhoncus, urna ipsum cursus massa, eu dictum tellus justo ac justo. Quisque ullamcorper
+ arcu nec tortor ullamcorper, vel fermentum justo fermentum. Vivamus sed velit ut elit
+ accumsan congue ut ut enim. Ut eu justo eu lacus varius gravida ut a tellus. Nulla facilisi.
+ Integer auctor consectetur ultricies. Fusce feugiat, mi sit amet bibendum viverra, orci leo
+ dapibus elit, id varius sem dui id lacus.
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin euismod, purus a euismod
+ rhoncus, urna ipsum cursus massa, eu dictum tellus justo ac justo. Quisque ullamcorper
+ arcu nec tortor ullamcorper, vel fermentum justo fermentum. Vivamus sed velit ut elit
+ accumsan congue ut ut enim. Ut eu justo eu lacus varius gravida ut a tellus. Nulla facilisi.
+ Integer auctor consectetur ultricies. Fusce feugiat, mi sit amet bibendum viverra, orci leo
+ dapibus elit, id varius sem dui id lacus.
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin euismod, purus a euismod
+ rhoncus, urna ipsum cursus massa, eu dictum tellus justo ac justo. Quisque ullamcorper
+ arcu nec tortor ullamcorper, vel fermentum justo fermentum. Vivamus sed velit ut elit
+ accumsan congue ut ut enim. Ut eu justo eu lacus varius gravida ut a tellus. Nulla facilisi.
+ Integer auctor consectetur ultricies. Fusce feugiat, mi sit amet bibendum viverra, orci leo
+ dapibus elit, id varius sem dui id lacus.
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin euismod, purus a euismod
+ rhoncus, urna ipsum cursus massa, eu dictum tellus justo ac justo. Quisque ullamcorper
+ arcu nec tortor ullamcorper, vel fermentum justo fermentum. Vivamus sed velit ut elit
+ accumsan congue ut ut enim. Ut eu justo eu lacus varius gravida ut a tellus. Nulla facilisi.
+ Integer auctor consectetur ultricies. Fusce feugiat, mi sit amet bibendum viverra, orci leo
+ dapibus elit, id varius sem dui id lacus.
+
+
+)";
+
+static const size_t htmlContentLength = strlen_P(htmlContent);
+static constexpr char characters[] = "0123456789ABCDEF";
+static size_t charactersIndex = 0;
+
+static AsyncWebServer server(80);
+static AsyncEventSource events("/events");
+
+static volatile size_t requests = 0;
+
+void setup() {
+ Serial.begin(115200);
+
+#ifndef CONFIG_IDF_TARGET_ESP32H2
+ WiFi.mode(WIFI_AP);
+ WiFi.softAP("esp-captive");
+#endif
+
+ // Pauses in the request parsing phase
+ //
+ // autocannon -c 32 -w 32 -a 96 -t 30 --renderStatusCodes -m POST -H "Content-Type: application/json" -b '{"foo": "bar"}' http://192.168.4.1/delay
+ //
+ // curl -v -X POST -H "Content-Type: application/json" -d '{"game": "test"}' http://192.168.4.1/delay
+ //
+ server.onNotFound([](AsyncWebServerRequest *request) {
+ requests = requests + 1;
+ if (request->url() == "/delay") {
+ request->send(200, "application/json", "{\"status\":\"OK\"}");
+ } else {
+ request->send(404, "text/plain", "Not found");
+ }
+ });
+ server.onRequestBody([](AsyncWebServerRequest *request, uint8_t *data, size_t len, size_t index, size_t total) {
+ if (request->url() == "/delay") {
+ delay(3000);
+ }
+ });
+
+ // HTTP endpoint
+ //
+ // > brew install autocannon
+ // > autocannon -c 10 -w 10 -d 20 http://192.168.4.1
+ // > autocannon -c 16 -w 16 -d 20 http://192.168.4.1
+ //
+ server.on("/", HTTP_GET, [](AsyncWebServerRequest *request) {
+ // need to cast to uint8_t*
+ // if you do not, the const char* will be copied in a temporary String buffer
+ requests = requests + 1;
+ request->send(200, "text/html", (uint8_t *)htmlContent, htmlContentLength);
+ });
+
+ // IMPORTANT - DO NOT WRITE SUCH CODE IN PRODUCTON !
+ //
+ // This example simulates the slowdown that can happen when:
+ // - downloading a huge file from sdcard
+ // - doing some file listing on SDCard because it is horribly slow to get a file listing with file stats on SDCard.
+ // So in both cases, ESP would deadlock or TWDT would trigger.
+ //
+ // This example simulats that by slowing down the chunk callback:
+ // - d=2000 is the delay in ms in the callback
+ // - l=10000 is the length of the response
+ //
+ // time curl -N -v -G -d 'd=2000' -d 'l=10000' http://192.168.4.1/slow.html --output -
+ //
+ server.on("/slow.html", HTTP_GET, [](AsyncWebServerRequest *request) {
+ requests = requests + 1;
+ uint32_t d = request->getParam("d")->value().toInt();
+ uint32_t l = request->getParam("l")->value().toInt();
+ Serial.printf("d = %" PRIu32 ", l = %" PRIu32 "\n", d, l);
+ AsyncWebServerResponse *response = request->beginChunkedResponse("text/html", [d, l](uint8_t *buffer, size_t maxLen, size_t index) -> size_t {
+ Serial.printf("%u\n", index);
+ // finished ?
+ if (index >= l) {
+ return 0;
+ }
+
+ // slow down the task to simulate some heavy processing, like SD card reading
+ delay(d);
+
+ memset(buffer, characters[charactersIndex], 256);
+ charactersIndex = (charactersIndex + 1) % sizeof(characters);
+ return 256;
+ });
+
+ request->send(response);
+ });
+
+ // SSS endpoint
+ //
+ // launch 16 concurrent workers for 30 seconds
+ // > for i in {1..10}; do ( count=$(gtimeout 30 curl -s -N -H "Accept: text/event-stream" http://192.168.4.1/events 2>&1 | grep -c "^data:"); echo "Total: $count events, $(echo "$count / 4" | bc -l) events / second" ) & done;
+ // > for i in {1..16}; do ( count=$(gtimeout 30 curl -s -N -H "Accept: text/event-stream" http://192.168.4.1/events 2>&1 | grep -c "^data:"); echo "Total: $count events, $(echo "$count / 4" | bc -l) events / second" ) & done;
+ //
+ // With AsyncTCP, with 16 workers: a lot of "Event message queue overflow: discard message", no crash
+ //
+ // Total: 1711 events, 427.75 events / second
+ // Total: 1711 events, 427.75 events / second
+ // Total: 1626 events, 406.50 events / second
+ // Total: 1562 events, 390.50 events / second
+ // Total: 1706 events, 426.50 events / second
+ // Total: 1659 events, 414.75 events / second
+ // Total: 1624 events, 406.00 events / second
+ // Total: 1706 events, 426.50 events / second
+ // Total: 1487 events, 371.75 events / second
+ // Total: 1573 events, 393.25 events / second
+ // Total: 1569 events, 392.25 events / second
+ // Total: 1559 events, 389.75 events / second
+ // Total: 1560 events, 390.00 events / second
+ // Total: 1562 events, 390.50 events / second
+ // Total: 1626 events, 406.50 events / second
+ //
+ // With AsyncTCP, with 10 workers:
+ //
+ // Total: 2038 events, 509.50 events / second
+ // Total: 2120 events, 530.00 events / second
+ // Total: 2119 events, 529.75 events / second
+ // Total: 2038 events, 509.50 events / second
+ // Total: 2037 events, 509.25 events / second
+ // Total: 2119 events, 529.75 events / second
+ // Total: 2119 events, 529.75 events / second
+ // Total: 2120 events, 530.00 events / second
+ // Total: 2038 events, 509.50 events / second
+ // Total: 2038 events, 509.50 events / second
+ //
+ // With AsyncTCPSock, with 16 workers: ESP32 CRASH !!!
+ //
+ // With AsyncTCPSock, with 10 workers:
+ //
+ // Total: 1242 events, 310.50 events / second
+ // Total: 1242 events, 310.50 events / second
+ // Total: 1242 events, 310.50 events / second
+ // Total: 1242 events, 310.50 events / second
+ // Total: 1181 events, 295.25 events / second
+ // Total: 1182 events, 295.50 events / second
+ // Total: 1240 events, 310.00 events / second
+ // Total: 1181 events, 295.25 events / second
+ // Total: 1181 events, 295.25 events / second
+ // Total: 1183 events, 295.75 events / second
+ //
+ server.addHandler(&events);
+
+ server.begin();
+}
+
+static uint32_t lastSSE = 0;
+static uint32_t deltaSSE = 10;
+
+static uint32_t lastHeap = 0;
+
+void loop() {
+ uint32_t now = millis();
+ if (now - lastSSE >= deltaSSE) {
+ events.send(String("ping-") + now, "heartbeat", now);
+ lastSSE = millis();
+ }
+
+#ifdef ESP32
+ if (now - lastHeap >= 2000) {
+ Serial.printf("Uptime: %3lu s, requests: %3u, Free heap: %" PRIu32 "\n", millis() / 1000, requests, ESP.getFreeHeap());
+ lastHeap = now;
+ }
+#endif
+}
diff --git a/libraries/ESP_Async_WebServer/examples/RateLimit/RateLimit.ino b/libraries/ESP_Async_WebServer/examples/RateLimit/RateLimit.ino
new file mode 100644
index 0000000..89d6090
--- /dev/null
+++ b/libraries/ESP_Async_WebServer/examples/RateLimit/RateLimit.ino
@@ -0,0 +1,64 @@
+// SPDX-License-Identifier: LGPL-3.0-or-later
+// Copyright 2016-2025 Hristo Gochkov, Mathieu Carbou, Emil Muratov
+
+//
+// Show how to rate limit the server or some endpoints
+//
+
+#include
+#ifdef ESP32
+#include
+#include
+#elif defined(ESP8266)
+#include
+#include
+#elif defined(TARGET_RP2040) || defined(TARGET_RP2350) || defined(PICO_RP2040) || defined(PICO_RP2350)
+#include
+#include
+#endif
+
+#include
+
+static AsyncWebServer server(80);
+static AsyncRateLimitMiddleware rateLimit;
+
+void setup() {
+ Serial.begin(115200);
+
+#ifndef CONFIG_IDF_TARGET_ESP32H2
+ WiFi.mode(WIFI_AP);
+ WiFi.softAP("esp-captive");
+#endif
+
+ // maximum 5 requests per 10 seconds
+ rateLimit.setMaxRequests(5);
+ rateLimit.setWindowSize(10);
+
+ // run quickly several times:
+ //
+ // curl -v http://192.168.4.1/
+ //
+ server.on("/", HTTP_GET, [](AsyncWebServerRequest *request) {
+ request->send(200, "text/plain", "Hello, world!");
+ });
+
+ // run quickly several times:
+ //
+ // curl -v http://192.168.4.1/rate-limited
+ //
+ server
+ .on(
+ "/rate-limited", HTTP_GET,
+ [](AsyncWebServerRequest *request) {
+ request->send(200, "text/plain", "Hello, world!");
+ }
+ )
+ .addMiddleware(&rateLimit); // only rate limit this endpoint, but could be applied globally to the server
+
+ server.begin();
+}
+
+// not needed
+void loop() {
+ delay(100);
+}
diff --git a/libraries/ESP_Async_WebServer/examples/Redirect/Redirect.ino b/libraries/ESP_Async_WebServer/examples/Redirect/Redirect.ino
new file mode 100644
index 0000000..ce1b9fb
--- /dev/null
+++ b/libraries/ESP_Async_WebServer/examples/Redirect/Redirect.ino
@@ -0,0 +1,48 @@
+// SPDX-License-Identifier: LGPL-3.0-or-later
+// Copyright 2016-2025 Hristo Gochkov, Mathieu Carbou, Emil Muratov
+
+//
+// Shows how to redirect
+//
+
+#include
+#ifdef ESP32
+#include
+#include
+#elif defined(ESP8266)
+#include
+#include
+#elif defined(TARGET_RP2040) || defined(TARGET_RP2350) || defined(PICO_RP2040) || defined(PICO_RP2350)
+#include
+#include
+#endif
+
+#include
+
+static AsyncWebServer server(80);
+
+void setup() {
+ Serial.begin(115200);
+
+#ifndef CONFIG_IDF_TARGET_ESP32H2
+ WiFi.mode(WIFI_AP);
+ WiFi.softAP("esp-captive");
+#endif
+
+ // curl -v http://192.168.4.1/
+ server.on("/", HTTP_GET, [](AsyncWebServerRequest *request) {
+ request->redirect("/index.txt");
+ });
+
+ // curl -v http://192.168.4.1/index.txt
+ server.on("/index.txt", HTTP_GET, [](AsyncWebServerRequest *request) {
+ request->send(200, "text/plain", "Hello, world!");
+ });
+
+ server.begin();
+}
+
+// not needed
+void loop() {
+ delay(100);
+}
diff --git a/libraries/ESP_Async_WebServer/examples/RequestContinuation/RequestContinuation.ino b/libraries/ESP_Async_WebServer/examples/RequestContinuation/RequestContinuation.ino
new file mode 100644
index 0000000..0584cf1
--- /dev/null
+++ b/libraries/ESP_Async_WebServer/examples/RequestContinuation/RequestContinuation.ino
@@ -0,0 +1,91 @@
+// SPDX-License-Identifier: LGPL-3.0-or-later
+// Copyright 2016-2025 Hristo Gochkov, Mathieu Carbou, Emil Muratov
+
+//
+// Shows how to use request continuation to pause a request for a long processing task, and be able to resume it later.
+//
+
+#include
+#ifdef ESP32
+#include
+#include
+#elif defined(ESP8266)
+#include
+#include
+#elif defined(TARGET_RP2040) || defined(TARGET_RP2350) || defined(PICO_RP2040) || defined(PICO_RP2350)
+#include
+#include
+#endif
+
+#include
+#include
+#include
+
+static AsyncWebServer server(80);
+
+// request handler that is saved from the paused request to communicate with Serial
+static String message;
+static AsyncWebServerRequestPtr serialRequest;
+
+// request handler that is saved from the paused request to communicate with GPIO
+static uint8_t pin = 35;
+static AsyncWebServerRequestPtr gpioRequest;
+
+void setup() {
+ Serial.begin(115200);
+
+#ifndef CONFIG_IDF_TARGET_ESP32H2
+ WiFi.mode(WIFI_AP);
+ WiFi.softAP("esp-captive");
+#endif
+
+ // Post a message that will be sent to the Serial console, and pause the request until the user types a key
+ //
+ // curl -v -X POST -H "Content-Type: application/x-www-form-urlencoded" -d "question=Name%3F%20" http://192.168.4.1/serial
+ //
+ // curl output should show "Answer: [y/n]" as the response
+ server.on("/serial", HTTP_POST, [](AsyncWebServerRequest *request) {
+ message = request->getParam("question", true)->value();
+ serialRequest = request->pause();
+ });
+
+ // Wait for a GPIO to be high
+ //
+ // curl -v http://192.168.4.1/gpio
+ //
+ // curl output should show "GPIO is high!" as the response
+ server.on("/gpio", HTTP_GET, [](AsyncWebServerRequest *request) {
+ gpioRequest = request->pause();
+ });
+
+ pinMode(pin, INPUT);
+
+ server.begin();
+}
+
+void loop() {
+ delay(500);
+
+ // Check for a high voltage on the RX1 pin
+ if (digitalRead(pin) == HIGH) {
+ if (auto request = gpioRequest.lock()) {
+ request->send(200, "text/plain", "GPIO is high!");
+ }
+ }
+
+ // check for an incoming message from the Serial console
+ if (message.length()) {
+ Serial.printf("%s", message.c_str());
+ // drops buffer
+ while (Serial.available()) {
+ Serial.read();
+ }
+ Serial.setTimeout(10000);
+ String response = Serial.readStringUntil('\n'); // waits for a key to be pressed
+ Serial.println();
+ message = emptyString;
+ if (auto request = serialRequest.lock()) {
+ request->send(200, "text/plain", "Answer: " + response);
+ }
+ }
+}
diff --git a/libraries/ESP_Async_WebServer/examples/RequestContinuationComplete/RequestContinuationComplete.ino b/libraries/ESP_Async_WebServer/examples/RequestContinuationComplete/RequestContinuationComplete.ino
new file mode 100644
index 0000000..ccd16fd
--- /dev/null
+++ b/libraries/ESP_Async_WebServer/examples/RequestContinuationComplete/RequestContinuationComplete.ino
@@ -0,0 +1,165 @@
+// SPDX-License-Identifier: LGPL-3.0-or-later
+// Copyright 2016-2025 Hristo Gochkov, Mathieu Carbou, Emil Muratov
+
+//
+// Shows how to use request continuation to pause a request for a long processing task, and be able to resume it later.
+//
+
+#include
+#ifdef ESP32
+#include
+#include
+#elif defined(ESP8266)
+#include
+#include
+#elif defined(TARGET_RP2040) || defined(TARGET_RP2350) || defined(PICO_RP2040) || defined(PICO_RP2350)
+#include
+#include
+#endif
+
+#include
+
+#include
+#include
+#include
+
+static AsyncWebServer server(80);
+
+// ===============================================================
+// The code below is used to simulate some long running operations
+// ===============================================================
+
+typedef struct {
+ size_t id;
+ AsyncWebServerRequestPtr requestPtr;
+ uint8_t data;
+} LongRunningOperation;
+
+static std::list> longRunningOperations;
+static size_t longRunningOperationsCount = 0;
+#ifdef ESP32
+static std::mutex longRunningOperationsMutex;
+#endif
+
+static void startLongRunningOperation(AsyncWebServerRequestPtr &&requestPtr) {
+#ifdef ESP32
+ std::lock_guard lock(longRunningOperationsMutex);
+#endif
+
+ // LongRunningOperation *op = new LongRunningOperation();
+ std::unique_ptr op(new LongRunningOperation());
+ op->id = ++longRunningOperationsCount;
+ op->data = 10;
+
+ // you need to hold the AsyncWebServerRequestPtr returned by pause();
+ // This object is authorized to leave the scope of the request handler.
+ op->requestPtr = std::move(requestPtr);
+
+ Serial.printf("[%u] Start long running operation for %" PRIu8 " seconds...\n", op->id, op->data);
+ longRunningOperations.push_back(std::move(op));
+}
+
+static bool processLongRunningOperation(LongRunningOperation *op) {
+ // request was deleted ?
+ if (op->requestPtr.expired()) {
+ Serial.printf("[%u] Request was deleted - stopping long running operation\n", op->id);
+ return true; // operation finished
+ }
+
+ // processing the operation
+ Serial.printf("[%u] Long running operation processing... %" PRIu8 " seconds left\n", op->id, op->data);
+
+ // check if we have finished ?
+ op->data--;
+ if (op->data) {
+ // not finished yet
+ return false;
+ }
+
+ // Try to get access to the request pointer if it is still exist.
+ // If there has been a disconnection during that time, the pointer won't be valid anymore
+ if (auto request = op->requestPtr.lock()) {
+ Serial.printf("[%u] Long running operation finished! Sending back response...\n", op->id);
+ request->send(200, "text/plain", String(op->id) + " ");
+
+ } else {
+ Serial.printf("[%u] Long running operation finished, but request was deleted!\n", op->id);
+ }
+
+ return true; // operation finished
+}
+
+/// ==========================================================
+
+void setup() {
+ Serial.begin(115200);
+
+#ifndef CONFIG_IDF_TARGET_ESP32H2
+ WiFi.mode(WIFI_AP);
+ WiFi.softAP("esp-captive");
+#endif
+
+ // Add a middleware to see how pausing a request affects the middleware chain
+ server.addMiddleware([](AsyncWebServerRequest *request, ArMiddlewareNext next) {
+ Serial.printf("Middleware chain start\n");
+
+ // continue to the next middleware, and at the end the request handler
+ next();
+
+ // we can check the request pause state after the handler was executed
+ if (request->isPaused()) {
+ Serial.printf("Request was paused!\n");
+ }
+
+ Serial.printf("Middleware chain ends\n");
+ });
+
+ // HOW TO RUN THIS EXAMPLE:
+ //
+ // 1. Open several terminals to trigger some requests concurrently that will be paused with:
+ // > time curl -v http://192.168.4.1/
+ //
+ // 2. Look at the output of the Serial console to see how the middleware chain is executed
+ // and to see the long running operations being processed and resume the requests.
+ //
+ // 3. You can try close your curl command to cancel the request and check that the request is deleted.
+ // Note: in case the network is disconnected, the request will be deleted.
+ //
+ server.on("/", HTTP_GET, [](AsyncWebServerRequest *request) {
+ // Print a message in case the request is disconnected (network disconnection, client close, etc.)
+ request->onDisconnect([]() {
+ Serial.printf("Request was disconnected!\n");
+ });
+
+ // Instruct ESPAsyncWebServer to pause the request and get a AsyncWebServerRequestPtr to be able to access the request later.
+ // The AsyncWebServerRequestPtr is the ONLY object authorized to leave the scope of the request handler.
+ // The Middleware chain will continue to run until the end after this handler exit, but the request will be paused and will not
+ // be sent to the client until send() is called later.
+ Serial.printf("Pausing request...\n");
+ AsyncWebServerRequestPtr requestPtr = request->pause();
+
+ // start our long operation...
+ startLongRunningOperation(std::move(requestPtr));
+ });
+
+ server.begin();
+}
+
+static uint32_t lastTime = 0;
+
+void loop() {
+ if (millis() - lastTime >= 1000) {
+
+#ifdef ESP32
+ Serial.printf("Free heap: %" PRIu32 "\n", ESP.getFreeHeap());
+ std::lock_guard lock(longRunningOperationsMutex);
+#endif
+
+ // process all long running operations
+ longRunningOperations.remove_if([](const std::unique_ptr &op) {
+ return processLongRunningOperation(op.get());
+ });
+
+ lastTime = millis();
+ }
+}
diff --git a/libraries/ESP_Async_WebServer/examples/ResumableDownload/ResumableDownload.ino b/libraries/ESP_Async_WebServer/examples/ResumableDownload/ResumableDownload.ino
new file mode 100644
index 0000000..373ca24
--- /dev/null
+++ b/libraries/ESP_Async_WebServer/examples/ResumableDownload/ResumableDownload.ino
@@ -0,0 +1,61 @@
+// SPDX-License-Identifier: LGPL-3.0-or-later
+// Copyright 2016-2025 Hristo Gochkov, Mathieu Carbou, Emil Muratov
+
+//
+// Make sure resumable downloads can be implemented (HEAD request / response and Range header)
+//
+
+#include
+#ifdef ESP32
+#include
+#include
+#elif defined(ESP8266)
+#include
+#include
+#elif defined(TARGET_RP2040) || defined(TARGET_RP2350) || defined(PICO_RP2040) || defined(PICO_RP2350)
+#include
+#include
+#endif
+
+#include
+
+static AsyncWebServer server(80);
+
+void setup() {
+ Serial.begin(115200);
+
+#ifndef CONFIG_IDF_TARGET_ESP32H2
+ WiFi.mode(WIFI_AP);
+ WiFi.softAP("esp-captive");
+#endif
+
+ /*
+ ❯ curl -I -X HEAD http://192.168.4.1/download
+ HTTP/1.1 200 OK
+ Content-Length: 1024
+ Content-Type: application/octet-stream
+ Connection: close
+ Accept-Ranges: bytes
+ */
+ // Ref: https://github.com/mathieucarbou/ESPAsyncWebServer/pull/80
+ server.on("/download", HTTP_HEAD | HTTP_GET, [](AsyncWebServerRequest *request) {
+ if (request->method() == HTTP_HEAD) {
+ AsyncWebServerResponse *response = request->beginResponse(200, "application/octet-stream");
+ response->addHeader(asyncsrv::T_Accept_Ranges, "bytes");
+ response->addHeader(asyncsrv::T_Content_Length, 10);
+ response->setContentLength(1024); // make sure we can overrides previously set content length
+ response->addHeader(asyncsrv::T_Content_Type, "foo");
+ response->setContentType("application/octet-stream"); // make sure we can overrides previously set content type
+ // ...
+ request->send(response);
+ } else {
+ // ...
+ }
+ });
+
+ server.begin();
+}
+
+void loop() {
+ delay(100);
+}
diff --git a/libraries/ESP_Async_WebServer/examples/Rewrite/Rewrite.ino b/libraries/ESP_Async_WebServer/examples/Rewrite/Rewrite.ino
new file mode 100644
index 0000000..6981b11
--- /dev/null
+++ b/libraries/ESP_Async_WebServer/examples/Rewrite/Rewrite.ino
@@ -0,0 +1,52 @@
+// SPDX-License-Identifier: LGPL-3.0-or-later
+// Copyright 2016-2025 Hristo Gochkov, Mathieu Carbou, Emil Muratov
+
+//
+// Shows how to rewrite URLs
+//
+
+#include
+#ifdef ESP32
+#include
+#include
+#elif defined(ESP8266)
+#include
+#include
+#elif defined(TARGET_RP2040) || defined(TARGET_RP2350) || defined(PICO_RP2040) || defined(PICO_RP2350)
+#include
+#include
+#endif
+
+#include
+
+static AsyncWebServer server(80);
+
+void setup() {
+ Serial.begin(115200);
+
+#ifndef CONFIG_IDF_TARGET_ESP32H2
+ WiFi.mode(WIFI_AP);
+ WiFi.softAP("esp-captive");
+#endif
+
+ // curl -v http://192.168.4.1/index.txt
+ server.on("/index.txt", HTTP_GET, [](AsyncWebServerRequest *request) {
+ request->send(200, "text/plain", "Hello, world!");
+ });
+
+ // curl -v http://192.168.4.1/index.txt
+ server.on("/index.html", HTTP_GET, [](AsyncWebServerRequest *request) {
+ request->send(200, "text/html", "Hello, world!
");
+ });
+
+ // curl -v http://192.168.4.1/
+ server.rewrite("/", "/index.html");
+ server.rewrite("/index.txt", "/index.html"); // will hide the .txt file
+
+ server.begin();
+}
+
+// not needed
+void loop() {
+ delay(100);
+}
diff --git a/libraries/ESP_Async_WebServer/examples/ServerSentEvents/ServerSentEvents.ino b/libraries/ESP_Async_WebServer/examples/ServerSentEvents/ServerSentEvents.ino
new file mode 100644
index 0000000..91e2c1d
--- /dev/null
+++ b/libraries/ESP_Async_WebServer/examples/ServerSentEvents/ServerSentEvents.ino
@@ -0,0 +1,105 @@
+// SPDX-License-Identifier: LGPL-3.0-or-later
+// Copyright 2016-2025 Hristo Gochkov, Mathieu Carbou, Emil Muratov
+
+//
+// SSE example
+//
+
+#include
+#ifdef ESP32
+#include
+#include
+#elif defined(ESP8266)
+#include
+#include
+#elif defined(TARGET_RP2040) || defined(TARGET_RP2350) || defined(PICO_RP2040) || defined(PICO_RP2350)
+#include
+#include
+#endif
+
+#include
+
+static const char *htmlContent PROGMEM = R"(
+
+
+
+ Server-Sent Events
+
+
+
+ Open your browser console!
+
+
+)";
+
+static const size_t htmlContentLength = strlen_P(htmlContent);
+
+static AsyncWebServer server(80);
+static AsyncEventSource events("/events");
+
+void setup() {
+ Serial.begin(115200);
+
+#ifndef CONFIG_IDF_TARGET_ESP32H2
+ WiFi.mode(WIFI_AP);
+ WiFi.softAP("esp-captive");
+#endif
+
+ // curl -v http://192.168.4.1/
+ server.on("/", HTTP_GET, [](AsyncWebServerRequest *request) {
+ // need to cast to uint8_t*
+ // if you do not, the const char* will be copied in a temporary String buffer
+ request->send(200, "text/html", (uint8_t *)htmlContent, htmlContentLength);
+ });
+
+ events.onConnect([](AsyncEventSourceClient *client) {
+ Serial.printf("SSE Client connected! ID: %" PRIu32 "\n", client->lastId());
+ client->send("hello!", NULL, millis(), 1000);
+ });
+
+ events.onDisconnect([](AsyncEventSourceClient *client) {
+ Serial.printf("SSE Client disconnected! ID: %" PRIu32 "\n", client->lastId());
+ });
+
+ server.addHandler(&events);
+
+ server.begin();
+}
+
+static uint32_t lastSSE = 0;
+static uint32_t deltaSSE = 3000;
+
+static uint32_t lastHeap = 0;
+
+void loop() {
+ uint32_t now = millis();
+ if (now - lastSSE >= deltaSSE) {
+ events.send(String("ping-") + now, "heartbeat", now);
+ lastSSE = millis();
+ }
+
+#ifdef ESP32
+ if (now - lastHeap >= 2000) {
+ Serial.printf("Free heap: %" PRIu32 "\n", ESP.getFreeHeap());
+ lastHeap = now;
+ }
+#endif
+}
diff --git a/libraries/ESP_Async_WebServer/examples/ServerSentEvents_PR156/ServerSentEvents_PR156.ino b/libraries/ESP_Async_WebServer/examples/ServerSentEvents_PR156/ServerSentEvents_PR156.ino
new file mode 100644
index 0000000..928c9ad
--- /dev/null
+++ b/libraries/ESP_Async_WebServer/examples/ServerSentEvents_PR156/ServerSentEvents_PR156.ino
@@ -0,0 +1,141 @@
+// SPDX-License-Identifier: LGPL-3.0-or-later
+// Copyright 2016-2025 Hristo Gochkov, Mathieu Carbou, Emil Muratov
+
+//
+// SSE example
+//
+
+#include
+#ifdef ESP32
+#include
+#include
+#elif defined(ESP8266)
+#include
+#include
+#elif defined(TARGET_RP2040) || defined(TARGET_RP2350) || defined(PICO_RP2040) || defined(PICO_RP2350)
+#include
+#include
+#endif
+
+#include
+
+static const char *htmlContent PROGMEM = R"(
+
+
+
+ Server-Sent Events
+
+
+
+ Open your browser console!
+
+
+)";
+
+static const size_t htmlContentLength = strlen_P(htmlContent);
+
+static AsyncWebServer server(80);
+static AsyncEventSource events("/events");
+
+static volatile size_t connectionCount = 0;
+static volatile uint32_t timestampConnected = 0;
+static constexpr uint32_t timeoutClose = 15000;
+
+void setup() {
+ Serial.begin(115200);
+
+#ifndef CONFIG_IDF_TARGET_ESP32H2
+ WiFi.mode(WIFI_AP);
+ WiFi.softAP("esp-captive");
+#endif
+
+ // curl -v http://192.168.4.1/
+ server.on("/", HTTP_GET, [](AsyncWebServerRequest *request) {
+ // need to cast to uint8_t*
+ // if you do not, the const char* will be copied in a temporary String buffer
+ request->send(200, "text/html", (uint8_t *)htmlContent, htmlContentLength);
+ });
+
+ events.onConnect([](AsyncEventSourceClient *client) {
+ /**
+ * @brief: Purpose for a test case: count() function
+ * Task watchdog shall be triggered due to a self-deadlock by mutex handling of the AsyncEventSource.
+ *
+ * E (61642) task_wdt: Task watchdog got triggered. The following tasks did not reset the watchdog in time:
+ * E (61642) task_wdt: - async_tcp (CPU 0/1)
+ *
+ * Resolve: using recursive_mutex insteads of mutex.
+ */
+ connectionCount = events.count();
+
+ timestampConnected = millis();
+ Serial.printf("SSE Client connected! ID: %" PRIu32 "\n", client->lastId());
+ client->send("hello!", NULL, millis(), 1000);
+ Serial.printf("Number of connected clients: %u\n", connectionCount);
+ });
+
+ events.onDisconnect([](AsyncEventSourceClient *client) {
+ connectionCount = events.count();
+ Serial.printf("SSE Client disconnected! ID: %" PRIu32 "\n", client->lastId());
+ Serial.printf("Number of connected clients: %u\n", connectionCount);
+ });
+
+ server.addHandler(&events);
+
+ server.begin();
+}
+
+static constexpr uint32_t deltaSSE = 3000;
+static uint32_t lastSSE = 0;
+static uint32_t lastHeap = 0;
+
+void loop() {
+ uint32_t now = millis();
+ if (connectionCount > 0) {
+ if (now - lastSSE >= deltaSSE) {
+ events.send(String("ping-") + now, "heartbeat", now);
+ lastSSE = millis();
+ }
+
+ /**
+ * @brief: Purpose for a test case: close() function
+ * Task watchdog shall be triggered due to a self-deadlock by mutex handling of the AsyncEventSource.
+ *
+ * E (61642) task_wdt: Task watchdog got triggered. The following tasks did not reset the watchdog in time:
+ * E (61642) task_wdt: - async_tcp (CPU 0/1)
+ *
+ * Resolve: using recursive_mutex insteads of mutex.
+ */
+ if (now - timestampConnected >= timeoutClose) {
+ Serial.printf("SSE Clients close\n");
+ events.close();
+ }
+ }
+
+#ifdef ESP32
+ if (now - lastHeap >= 2000) {
+ Serial.printf("Free heap: %" PRIu32 "\n", ESP.getFreeHeap());
+ lastHeap = now;
+ }
+#endif
+}
diff --git a/libraries/ESP_Async_WebServer/examples/ServerState/ServerState.ino b/libraries/ESP_Async_WebServer/examples/ServerState/ServerState.ino
new file mode 100644
index 0000000..8501758
--- /dev/null
+++ b/libraries/ESP_Async_WebServer/examples/ServerState/ServerState.ino
@@ -0,0 +1,66 @@
+// SPDX-License-Identifier: LGPL-3.0-or-later
+// Copyright 2016-2025 Hristo Gochkov, Mathieu Carbou, Emil Muratov
+
+//
+// Server state example
+//
+
+#include
+#ifdef ESP32
+#include
+#include
+#elif defined(ESP8266)
+#include
+#include
+#elif defined(TARGET_RP2040) || defined(TARGET_RP2350) || defined(PICO_RP2040) || defined(PICO_RP2350)
+#include
+#include
+#endif
+
+#include
+
+static AsyncWebServer server1(80);
+static AsyncWebServer server2(80);
+
+void setup() {
+ Serial.begin(115200);
+
+#ifndef CONFIG_IDF_TARGET_ESP32H2
+ WiFi.mode(WIFI_AP);
+ WiFi.softAP("esp-captive");
+#endif
+
+ // server state returns one of the tcp_state enum values:
+ // enum tcp_state {
+ // CLOSED = 0,
+ // LISTEN = 1,
+ // SYN_SENT = 2,
+ // SYN_RCVD = 3,
+ // ESTABLISHED = 4,
+ // FIN_WAIT_1 = 5,
+ // FIN_WAIT_2 = 6,
+ // CLOSE_WAIT = 7,
+ // CLOSING = 8,
+ // LAST_ACK = 9,
+ // TIME_WAIT = 10
+ // };
+
+ assert(server1.state() == tcp_state::CLOSED);
+ assert(server2.state() == tcp_state::CLOSED);
+
+ server1.begin();
+
+ assert(server1.state() == tcp_state::LISTEN);
+ assert(server2.state() == tcp_state::CLOSED);
+
+ server2.begin();
+
+ assert(server1.state() == tcp_state::LISTEN);
+ assert(server2.state() == tcp_state::CLOSED);
+
+ Serial.println("Done!");
+}
+
+void loop() {
+ delay(100);
+}
diff --git a/libraries/ESP_Async_WebServer/examples/SkipServerMiddleware/SkipServerMiddleware.ino b/libraries/ESP_Async_WebServer/examples/SkipServerMiddleware/SkipServerMiddleware.ino
new file mode 100644
index 0000000..d232c71
--- /dev/null
+++ b/libraries/ESP_Async_WebServer/examples/SkipServerMiddleware/SkipServerMiddleware.ino
@@ -0,0 +1,73 @@
+// SPDX-License-Identifier: LGPL-3.0-or-later
+// Copyright 2016-2025 Hristo Gochkov, Mathieu Carbou, Emil Muratov
+
+//
+// Authentication and authorization middlewares
+//
+
+#include