ESPAsyncWebServer icon indicating copy to clipboard operation
ESPAsyncWebServer copied to clipboard

Buffer chunked response

Open ddprog opened this issue 1 year ago • 0 comments

Hello. I would like to understand the chunked response. I use the code from the example, the function returns the size of the buffer (in bytes).

AsyncWebServerResponse *response = request->beginChunkedResponse("text/plain", [](uint8_t *buffer, size_t maxLen, size_t index) -> size_t {
  //Write up to "maxLen" bytes into "buffer" and return the amount written.
  //index equals the amount of bytes that have been already sent
  //You will be asked for more data until 0 is returned
  //Keep in mind that you can not delay or yield waiting for more data!
  return mySource.read(buffer, maxLen);
});
response->addHeader("Server","ESP Async Web Server");
request->send(response);

If it is filled almost completely, the controller reboots - tcpasync did not reset the watchdog timer in time. If you put about 1/10 of that size into the buffer, then everything is fine. The question is - how much should be given to the buffer?

ddprog avatar Feb 05 '24 07:02 ddprog