From 02e51728c4f66d997dbe8c8948e377ccba36dd3e Mon Sep 17 00:00:00 2001 From: Victor Aprea Date: Tue, 9 Jul 2019 12:27:24 -0400 Subject: [PATCH] Fix Timeout Bug in WebServer (#2938) --- .../HTTPUpdate/examples/httpUpdateSecure/httpUpdateSecure.ino | 2 +- libraries/WebServer/src/WebServer.cpp | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/libraries/HTTPUpdate/examples/httpUpdateSecure/httpUpdateSecure.ino b/libraries/HTTPUpdate/examples/httpUpdateSecure/httpUpdateSecure.ino index e7e93eea..5daa2a4f 100644 --- a/libraries/HTTPUpdate/examples/httpUpdateSecure/httpUpdateSecure.ino +++ b/libraries/HTTPUpdate/examples/httpUpdateSecure/httpUpdateSecure.ino @@ -96,7 +96,7 @@ void loop() { client.setCACert(rootCACertificate); // Reading data over SSL may be slow, use an adequate timeout - client.setTimeout(12000); + client.setTimeout(12000 / 1000); // timeout argument is defined in seconds for setTimeout // The line below is optional. It can be used to blink the LED on the board during flashing // The LED will be on during download of one buffer of data from the network. The LED will diff --git a/libraries/WebServer/src/WebServer.cpp b/libraries/WebServer/src/WebServer.cpp index fc31e6a6..90416f90 100644 --- a/libraries/WebServer/src/WebServer.cpp +++ b/libraries/WebServer/src/WebServer.cpp @@ -302,7 +302,9 @@ void WebServer::handleClient() { // Wait for data from client to become available if (_currentClient.available()) { if (_parseRequest(_currentClient)) { - _currentClient.setTimeout(HTTP_MAX_SEND_WAIT); + // because HTTP_MAX_SEND_WAIT is expressed in milliseconds, + // it must be divided by 1000 + _currentClient.setTimeout(HTTP_MAX_SEND_WAIT / 1000); _contentLength = CONTENT_LENGTH_NOT_SET; _handleRequest();