diff --git a/libraries/WebServer/src/Parsing.cpp b/libraries/WebServer/src/Parsing.cpp index 1db2aef5541..ef455c8ab65 100644 --- a/libraries/WebServer/src/Parsing.cpp +++ b/libraries/WebServer/src/Parsing.cpp @@ -303,7 +303,6 @@ void WebServer::_uploadWriteByte(uint8_t b){ } int WebServer::_uploadReadByte(WiFiClient& client){ - if (!client.connected()) return -1; int res = client.read(); if(res < 0) { // keep trying until you either read a valid byte or timeout @@ -311,6 +310,7 @@ int WebServer::_uploadReadByte(WiFiClient& client){ long timeoutIntervalMillis = client.getTimeout(); boolean timedOut = false; for(;;) { + if (!client.connected()) return -1; // loosely modeled after blinkWithoutDelay pattern while(!timedOut && !client.available() && client.connected()){ delay(2);