Skip to content

Commit 16f7d34

Browse files
authored
Replace _uploadReadByte() in WebServer/Parsing.cpp with ESP8266 implementation.
1 parent bd941e3 commit 16f7d34

File tree

1 file changed

+6
-34
lines changed

1 file changed

+6
-34
lines changed

Diff for: libraries/WebServer/src/Parsing.cpp

+6-34
Original file line numberDiff line numberDiff line change
@@ -309,42 +309,14 @@ void WebServer::_uploadWriteByte(uint8_t b){
309309
_currentUpload->buf[_currentUpload->currentSize++] = b;
310310
}
311311

312-
int WebServer::_uploadReadByte(WiFiClient& client){
312+
int WebServer::_uploadReadByte(WiFiClient& client) {
313313
int res = client.read();
314-
if(res < 0) {
315-
// keep trying until you either read a valid byte or timeout
316-
unsigned long startMillis = millis();
317-
long timeoutIntervalMillis = client.getTimeout();
318-
boolean timedOut = false;
319-
for(;;) {
320-
if (!client.connected()) return -1;
321-
// loosely modeled after blinkWithoutDelay pattern
322-
while(!timedOut && !client.available() && client.connected()){
323-
delay(2);
324-
timedOut = millis() - startMillis >= timeoutIntervalMillis;
325-
}
326314

327-
res = client.read();
328-
if(res >= 0) {
329-
return res; // exit on a valid read
330-
}
331-
// NOTE: it is possible to get here and have all of the following
332-
// assertions hold true
333-
//
334-
// -- client.available() > 0
335-
// -- client.connected == true
336-
// -- res == -1
337-
//
338-
// a simple retry strategy overcomes this which is to say the
339-
// assertion is not permanent, but the reason that this works
340-
// is elusive, and possibly indicative of a more subtle underlying
341-
// issue
342-
343-
timedOut = millis() - startMillis >= timeoutIntervalMillis;
344-
if(timedOut) {
345-
return res; // exit on a timeout
346-
}
347-
}
315+
if (res < 0) {
316+
while(!client.available() && client.connected())
317+
delay(2);
318+
319+
res = client.read();
348320
}
349321

350322
return res;

0 commit comments

Comments
 (0)