Skip to content

Commit c442a9c

Browse files
Merge branch 'main' into main
2 parents 1a4fac3 + 87eb31c commit c442a9c

File tree

8 files changed

+193
-12
lines changed

8 files changed

+193
-12
lines changed

.github/workflows/build-arduino.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
run: arduino-cli lib install ArduinoJson
3333

3434
- name: Install AsyncTCP (ESP32)
35-
run: ARDUINO_LIBRARY_ENABLE_UNSAFE_INSTALL=true arduino-cli lib install --git-url https://github.com/ESP32Async/AsyncTCP#v3.3.5
35+
run: ARDUINO_LIBRARY_ENABLE_UNSAFE_INSTALL=true arduino-cli lib install --git-url https://github.com/ESP32Async/AsyncTCP#v3.3.6
3636

3737
- name: Checkout
3838
uses: actions/checkout@v4
@@ -63,7 +63,7 @@ jobs:
6363
run: arduino-cli lib install ArduinoJson
6464

6565
- name: Install AsyncTCP (ESP32)
66-
run: ARDUINO_LIBRARY_ENABLE_UNSAFE_INSTALL=true arduino-cli lib install --git-url https://github.com/ESP32Async/AsyncTCP#v3.3.5
66+
run: ARDUINO_LIBRARY_ENABLE_UNSAFE_INSTALL=true arduino-cli lib install --git-url https://github.com/ESP32Async/AsyncTCP#v3.3.6
6767

6868
- name: Checkout
6969
uses: actions/checkout@v4

data/README.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin euismod, purus a euismod
2+
rhoncus, urna ipsum cursus massa, eu dictum tellus justo ac justo. Quisque ullamcorper
3+
arcu nec tortor ullamcorper, vel fermentum justo fermentum. Vivamus sed velit ut elit
4+
accumsan congue ut ut enim. Ut eu justo eu lacus varius gravida ut a tellus. Nulla facilisi.
5+
Integer auctor consectetur ultricies. Fusce feugiat, mi sit amet bibendum viverra, orci leo
6+
dapibus elit, id varius sem dui id lacus.</p>
7+
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin euismod, purus a euismod
8+
rhoncus, urna ipsum cursus massa, eu dictum tellus justo ac justo. Quisque ullamcorper
9+
arcu nec tortor ullamcorper, vel fermentum justo fermentum. Vivamus sed velit ut elit
10+
accumsan congue ut ut enim. Ut eu justo eu lacus varius gravida ut a tellus. Nulla facilisi.
11+
Integer auctor consectetur ultricies. Fusce feugiat, mi sit amet bibendum viverra, orci leo
12+
dapibus elit, id varius sem dui id lacus.</p>
13+
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin euismod, purus a euismod
14+
rhoncus, urna ipsum cursus massa, eu dictum tellus justo ac justo. Quisque ullamcorper
15+
arcu nec tortor ullamcorper, vel fermentum justo fermentum. Vivamus sed velit ut elit
16+
accumsan congue ut ut enim. Ut eu justo eu lacus varius gravida ut a tellus. Nulla facilisi.
17+
Integer auctor consectetur ultricies. Fusce feugiat, mi sit amet bibendum viverra, orci leo
18+
dapibus elit, id varius sem dui id lacus.</p>
19+
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin euismod, purus a euismod
20+
rhoncus, urna ipsum cursus massa, eu dictum tellus justo ac justo. Quisque ullamcorper
21+
arcu nec tortor ullamcorper, vel fermentum justo fermentum. Vivamus sed velit ut elit
22+
accumsan congue ut ut enim. Ut eu justo eu lacus varius gravida ut a tellus. Nulla facilisi.
23+
Integer auctor consectetur ultricies. Fusce feugiat, mi sit amet bibendum viverra, orci leo
24+
dapibus elit, id varius sem dui id lacus.</p>
25+
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin euismod, purus a euismod
26+
rhoncus, urna ipsum cursus massa, eu dictum tellus justo ac justo. Quisque ullamcorper
27+
arcu nec tortor ullamcorper, vel fermentum justo fermentum. Vivamus sed velit ut elit
28+
accumsan congue ut ut enim. Ut eu justo eu lacus varius gravida ut a tellus. Nulla facilisi.
29+
Integer auctor consectetur ultricies. Fusce feugiat, mi sit amet bibendum viverra, orci leo
30+
dapibus elit, id varius sem dui id lacus.</p>
31+
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin euismod, purus a euismod
32+
rhoncus, urna ipsum cursus massa, eu dictum tellus justo ac justo. Quisque ullamcorper
33+
arcu nec tortor ullamcorper, vel fermentum justo fermentum. Vivamus sed velit ut elit
34+
accumsan congue ut ut enim. Ut eu justo eu lacus varius gravida ut a tellus. Nulla facilisi.
35+
Integer auctor consectetur ultricies. Fusce feugiat, mi sit amet bibendum viverra, orci leo
36+
dapibus elit, id varius sem dui id lacus.</p>
37+
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin euismod, purus a euismod
38+
rhoncus, urna ipsum cursus massa, eu dictum tellus justo ac justo. Quisque ullamcorper
39+
arcu nec tortor ullamcorper, vel fermentum justo fermentum. Vivamus sed velit ut elit
40+
accumsan congue ut ut enim. Ut eu justo eu lacus varius gravida ut a tellus. Nulla facilisi.
41+
Integer auctor consectetur ultricies. Fusce feugiat, mi sit amet bibendum viverra, orci leo
42+
dapibus elit, id varius sem dui id lacus.</p>
43+
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin euismod, purus a euismod
44+
rhoncus, urna ipsum cursus massa, eu dictum tellus justo ac justo. Quisque ullamcorper
45+
arcu nec tortor ullamcorper, vel fermentum justo fermentum. Vivamus sed velit ut elit
46+
accumsan congue ut ut enim. Ut eu justo eu lacus varius gravida ut a tellus. Nulla facilisi.
47+
Integer auctor consectetur ultricies. Fusce feugiat, mi sit amet bibendum viverra, orci leo
48+
dapibus elit, id varius sem dui id lacus.
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
// SPDX-License-Identifier: LGPL-3.0-or-later
2+
// Copyright 2016-2025 Hristo Gochkov, Mathieu Carbou, Emil Muratov
3+
4+
//
5+
// - Download ESP32 partition by name and/or type and/or subtype
6+
// - Support encrypted and non-encrypted partitions
7+
//
8+
9+
#include <Arduino.h>
10+
#ifdef ESP32
11+
#include <AsyncTCP.h>
12+
#include <WiFi.h>
13+
#elif defined(ESP8266)
14+
#include <ESP8266WiFi.h>
15+
#include <ESPAsyncTCP.h>
16+
#elif defined(TARGET_RP2040) || defined(TARGET_RP2350) || defined(PICO_RP2040) || defined(PICO_RP2350)
17+
#include <RPAsyncTCP.h>
18+
#include <WiFi.h>
19+
#endif
20+
21+
#include <ESPAsyncWebServer.h>
22+
#include <LittleFS.h>
23+
24+
#ifndef ESP32
25+
// this example is only for the ESP32
26+
void setup() {}
27+
void loop() {}
28+
#else
29+
30+
#include <esp_partition.h>
31+
32+
static AsyncWebServer server(80);
33+
34+
void setup() {
35+
Serial.begin(115200);
36+
37+
#ifndef CONFIG_IDF_TARGET_ESP32H2
38+
WiFi.mode(WIFI_AP);
39+
WiFi.softAP("esp-captive");
40+
#endif
41+
42+
LittleFS.begin(true);
43+
44+
// To upload the FS partition, run:
45+
// > pio run -e arduino-3 -t buildfs
46+
// > pio run -e arduino-3 -t uploadfs
47+
//
48+
// Examples:
49+
//
50+
// - Download the partition named "spiffs": http://192.168.4.1/partition?label=spiffs
51+
// - Download the partition named "spiffs" with type "data": http://192.168.4.1/partition?label=spiffs&type=1
52+
// - Download the partition named "spiffs" with type "data" and subtype "spiffs": http://192.168.4.1/partition?label=spiffs&type=1&subtype=130
53+
// - Download the partition with subtype "nvs": http://192.168.4.1/partition?type=1&subtype=2
54+
//
55+
// "type" and "subtype" IDs can be found in esp_partition.h header file.
56+
//
57+
// Add "&raw=false" parameter to download the partition unencrypted (for encrypted partitions).
58+
// By default, the raw partition is downloaded, so if a partition is encrypted, the encrypted data will be downloaded.
59+
//
60+
// To browse a downloaded LittleFS partition, you can use https://tniessen.github.io/littlefs-disk-img-viewer/ (block size is 4096)
61+
//
62+
server.on("/partition", HTTP_GET, [](AsyncWebServerRequest *request) {
63+
const AsyncWebParameter *pLabel = request->getParam("label");
64+
const AsyncWebParameter *pType = request->getParam("type");
65+
const AsyncWebParameter *pSubtype = request->getParam("subtype");
66+
const AsyncWebParameter *pRaw = request->getParam("raw");
67+
68+
if (!pLabel && !pType && !pSubtype) {
69+
request->send(400, "text/plain", "Bad request: missing parameter");
70+
return;
71+
}
72+
73+
esp_partition_type_t type = ESP_PARTITION_TYPE_ANY;
74+
esp_partition_subtype_t subtype = ESP_PARTITION_SUBTYPE_ANY;
75+
const char *label = nullptr;
76+
bool raw = true;
77+
78+
if (pLabel) {
79+
label = pLabel->value().c_str();
80+
}
81+
82+
if (pType) {
83+
type = (esp_partition_type_t)pType->value().toInt();
84+
}
85+
86+
if (pSubtype) {
87+
subtype = (esp_partition_subtype_t)pSubtype->value().toInt();
88+
}
89+
90+
if (pRaw && pRaw->value() == "false") {
91+
raw = false;
92+
}
93+
94+
const esp_partition_t *partition = esp_partition_find_first(type, subtype, label);
95+
96+
if (!partition) {
97+
request->send(404, "text/plain", "Partition not found");
98+
return;
99+
}
100+
101+
AsyncWebServerResponse *response =
102+
request->beginChunkedResponse("application/octet-stream", [partition, raw](uint8_t *buffer, size_t maxLen, size_t index) -> size_t {
103+
const size_t remaining = partition->size - index;
104+
if (!remaining) {
105+
return 0;
106+
}
107+
const size_t len = std::min(maxLen, remaining);
108+
if (raw && esp_partition_read_raw(partition, index, buffer, len) == ESP_OK) {
109+
return len;
110+
}
111+
if (!raw && esp_partition_read(partition, index, buffer, len) == ESP_OK) {
112+
return len;
113+
}
114+
return 0;
115+
});
116+
117+
response->addHeader("Content-Disposition", "attachment; filename=" + String(partition->label) + ".bin");
118+
response->setContentLength(partition->size);
119+
120+
request->send(response);
121+
});
122+
123+
server.begin();
124+
}
125+
126+
void loop() {
127+
delay(100);
128+
}
129+
130+
#endif

idf_component.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ files:
2626
- "pre-commit.requirements.txt"
2727
dependencies:
2828
esp32async/asynctcp:
29-
version: "^3.3.5"
29+
version: "^3.3.6"
3030
require: public
3131
bblanchon/arduinojson:
32-
version: "^7.3.0"
32+
version: "^7.3.1"
3333
require: public
3434
examples:
3535
- path: ./idf_component_examples/catchall

library.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
{
2525
"owner": "ESP32Async",
2626
"name": "AsyncTCP",
27-
"version": "^3.3.5",
27+
"version": "^3.3.6",
2828
"platforms": "espressif32"
2929
},
3030
{

pioarduino_examples/IncreaseMaxSockets/platformio.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ monitor_filters = esp32_exception_decoder, log2file
1717
lib_compat_mode = strict
1818
lib_ldf_mode = chain
1919
lib_deps =
20-
ESP32Async/AsyncTCP @ 3.3.5
20+
ESP32Async/AsyncTCP @ 3.3.6
2121
ESP32Async/ESpAsyncWebServer @ 3.7.0
2222

2323
custom_sdkconfig = CONFIG_LWIP_MAX_ACTIVE_TCP=32

platformio.ini

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ lib_dir = .
1616
; src_dir = examples/MessagePack
1717
; src_dir = examples/Middleware
1818
; src_dir = examples/Params
19+
; src_dir = examples/PartitionDownloader
1920
src_dir = examples/PerfTests
2021
; src_dir = examples/RateLimit
2122
; src_dir = examples/Redirect
@@ -53,8 +54,8 @@ monitor_filters = esp32_exception_decoder, log2file
5354
lib_compat_mode = strict
5455
lib_ldf_mode = chain
5556
lib_deps =
56-
bblanchon/ArduinoJson @ 7.3.0
57-
ESP32Async/AsyncTCP @ 3.3.5
57+
bblanchon/ArduinoJson @ 7.3.1
58+
ESP32Async/AsyncTCP @ 3.3.6
5859
board_build.partitions = partitions-4MB.csv
5960
board_build.filesystem = littlefs
6061

@@ -68,7 +69,7 @@ platform = https://github.com/pioarduino/platform-espressif32/releases/download/
6869

6970
[env:arduino-3-no-json]
7071
lib_deps =
71-
ESP32Async/AsyncTCP @ 3.3.5
72+
ESP32Async/AsyncTCP @ 3.3.6
7273

7374
[env:arduino-3-latest-asynctcp]
7475
lib_deps =
@@ -88,7 +89,7 @@ platform = espressif8266
8889
; board = huzzah
8990
board = d1_mini
9091
lib_deps =
91-
bblanchon/ArduinoJson @ 7.3.0
92+
bblanchon/ArduinoJson @ 7.3.1
9293
ESP32Async/ESPAsyncTCP @ 2.0.0
9394

9495
[env:raspberrypi]
@@ -119,7 +120,7 @@ board = ${sysenv.PIO_BOARD}
119120
[env:ci-arduino-3-no-json]
120121
board = ${sysenv.PIO_BOARD}
121122
lib_deps =
122-
ESP32Async/AsyncTCP @ 3.3.5
123+
ESP32Async/AsyncTCP @ 3.3.6
123124

124125
[env:ci-arduino-3-latest-asynctcp]
125126
lib_deps =
@@ -134,7 +135,7 @@ build_flags = ${env.build_flags}
134135
platform = espressif8266
135136
board = ${sysenv.PIO_BOARD}
136137
lib_deps =
137-
bblanchon/ArduinoJson @ 7.3.0
138+
bblanchon/ArduinoJson @ 7.3.1
138139
ESP32Async/ESPAsyncTCP @ 2.0.0
139140

140141
[env:ci-raspberrypi]

src/WebRequest.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,8 @@ void AsyncWebServerRequest::_onData(void *buf, size_t len) {
167167
// A handler should be already attached at this point in _parseLine function.
168168
// If handler does nothing (_onRequest is NULL), we don't need to really parse the body.
169169
const bool needParse = _handler && !_handler->isRequestHandlerTrivial();
170+
// Discard any bytes after content length; handlers may overrun their buffers
171+
len = std::min(len, _contentLength - _parsedLength);
170172
if (_isMultipart) {
171173
if (needParse) {
172174
size_t i;

0 commit comments

Comments
 (0)