mirror of
https://github.com/me-no-dev/ESPAsyncWebServer.git
synced 2025-07-31 19:24:45 +02:00
updated slow sample
This commit is contained in:
@@ -503,18 +503,20 @@ void setup() {
|
||||
request->send(response);
|
||||
});
|
||||
|
||||
// time curl -N -v -X GET http://192.168.4.1/slow.html --output -
|
||||
// time curl -N -v -G -d 'd=3000' -d 'l=10000' http://192.168.4.1/slow.html --output -
|
||||
server.on("/slow.html", HTTP_GET, [](AsyncWebServerRequest* request) {
|
||||
request->client()->setRxTimeout(2000);
|
||||
AsyncWebServerResponse* response = request->beginChunkedResponse("text/html", [](uint8_t* buffer, size_t maxLen, size_t index) -> size_t {
|
||||
Serial.printf("%u\n", index);
|
||||
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("%" PRIu32 "\n", index);
|
||||
// finished ?
|
||||
if (index >= 160000)
|
||||
if (index >= l)
|
||||
return 0;
|
||||
|
||||
// slow down the task by 2 seconds
|
||||
// to simulate some heavy processing, like SD card reading
|
||||
delay(100);
|
||||
delay(d);
|
||||
|
||||
memset(buffer, characters[charactersIndex], 256);
|
||||
charactersIndex = (charactersIndex + 1) % sizeof(characters);
|
||||
|
Reference in New Issue
Block a user