Seeed_Arduino_rpcWiFi icon indicating copy to clipboard operation
Seeed_Arduino_rpcWiFi copied to clipboard

Chunked mode not correctly finalizing

Open XXL-Wing opened this issue 2 years ago • 0 comments

When you use chunked mode to send a bigger amount of data, the sequence shall be as follows (according to examples): server.setContentLength(CONTENT_LENGTH_UNKNOWN); server.send(200, "application/json", ""); for(int i = 0; i < somestringultrabig.length(); i+=1000) { server.sendContent(somestringultrabig.substring(i,i+999)); } server.sendContent(""); The last call should finalize the transfer and close the transmission. Reality shows that browsers run into a timeout or report an error, e.g. Chrome displays a net::ERR_CONNECTION_RESET 200 (OK). Testing tools that take it seriously spin forever. So closing the connection in chunked mode does not work. Additionally if you provide big Strings to sendContent this also does not work, you need to take the route as described above.

To Reproduce Create a demo program like above use browser to retrieve the data (chrome shows error, and HTTPie spins forever)

Expected behavior Transmission can correctly be closed without the client encountering an error situation

Desktop (please complete the following information):

  • OS: Debian Linux
  • Browser: tested with chrome and HTTPie

XXL-Wing avatar May 28 '23 15:05 XXL-Wing