Skip to content

Commit 41bd7af

Browse files
author
Peter
committed
slow client/network read fix
1 parent 502c45c commit 41bd7af

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

libraries/ESP8266WebServer/src/Parsing.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -144,15 +144,16 @@ bool ESP8266WebServer::_parseRequest(WiFiClient& client) {
144144
{
145145
//some clients send headers first and data after (like we do)
146146
//give them a chance
147-
int tries = 100;//100ms max wait
148-
while(!client.available() && tries--)delay(1);
149-
size_t newLen = client.available();
147+
int tries = 1000;//1000ms max wait
148+
size_t newLen;
149+
while( !(newLen = client.available()) && tries--) delay(1);
150150
if (!newLen) break;
151151
plainBuf = (plainBuf == nullptr) ? (char *) malloc(newLen + 1) : (char *) realloc(plainBuf, plainLen + newLen + 1);
152152
client.readBytes(&plainBuf[plainLen], newLen);
153153
plainLen += newLen;
154154
plainBuf[plainLen] = '\0';
155155
} while (plainLen < contentLength);
156+
if (plainBuf == nullptr) return false;
156157
#ifdef DEBUG_ESP_HTTP_SERVER
157158
DEBUG_OUTPUT.print("Plain: ");
158159
DEBUG_OUTPUT.println(plainBuf);

0 commit comments

Comments
 (0)