Skip to content
This repository was archived by the owner on Jan 21, 2025. It is now read-only.

Commit 25742e1

Browse files
committed
updated slow sample
1 parent 3866d0b commit 25742e1

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

examples/SimpleServer/SimpleServer.ino

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -503,18 +503,20 @@ void setup() {
503503
request->send(response);
504504
});
505505

506-
// time curl -N -v -X GET http://192.168.4.1/slow.html --output -
506+
// time curl -N -v -G -d 'd=3000' -d 'l=10000' http://192.168.4.1/slow.html --output -
507507
server.on("/slow.html", HTTP_GET, [](AsyncWebServerRequest* request) {
508-
request->client()->setRxTimeout(2000);
509-
AsyncWebServerResponse* response = request->beginChunkedResponse("text/html", [](uint8_t* buffer, size_t maxLen, size_t index) -> size_t {
510-
Serial.printf("%u\n", index);
508+
uint32_t d = request->getParam("d")->value().toInt();
509+
uint32_t l = request->getParam("l")->value().toInt();
510+
Serial.printf("d = %" PRIu32 ", l = %" PRIu32 "\n", d, l);
511+
AsyncWebServerResponse* response = request->beginChunkedResponse("text/html", [d, l](uint8_t* buffer, size_t maxLen, size_t index) -> size_t {
512+
Serial.printf("%" PRIu32 "\n", index);
511513
// finished ?
512-
if (index >= 160000)
514+
if (index >= l)
513515
return 0;
514516

515517
// slow down the task by 2 seconds
516518
// to simulate some heavy processing, like SD card reading
517-
delay(100);
519+
delay(d);
518520

519521
memset(buffer, characters[charactersIndex], 256);
520522
charactersIndex = (charactersIndex + 1) % sizeof(characters);

0 commit comments

Comments
 (0)