mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-19 23:22:16 +03:00
slow client/network read fix
This commit is contained in:
parent
502c45c157
commit
41bd7af07e
@ -144,15 +144,16 @@ bool ESP8266WebServer::_parseRequest(WiFiClient& client) {
|
|||||||
{
|
{
|
||||||
//some clients send headers first and data after (like we do)
|
//some clients send headers first and data after (like we do)
|
||||||
//give them a chance
|
//give them a chance
|
||||||
int tries = 100;//100ms max wait
|
int tries = 1000;//1000ms max wait
|
||||||
while(!client.available() && tries--)delay(1);
|
size_t newLen;
|
||||||
size_t newLen = client.available();
|
while( !(newLen = client.available()) && tries--) delay(1);
|
||||||
if (!newLen) break;
|
if (!newLen) break;
|
||||||
plainBuf = (plainBuf == nullptr) ? (char *) malloc(newLen + 1) : (char *) realloc(plainBuf, plainLen + newLen + 1);
|
plainBuf = (plainBuf == nullptr) ? (char *) malloc(newLen + 1) : (char *) realloc(plainBuf, plainLen + newLen + 1);
|
||||||
client.readBytes(&plainBuf[plainLen], newLen);
|
client.readBytes(&plainBuf[plainLen], newLen);
|
||||||
plainLen += newLen;
|
plainLen += newLen;
|
||||||
plainBuf[plainLen] = '\0';
|
plainBuf[plainLen] = '\0';
|
||||||
} while (plainLen < contentLength);
|
} while (plainLen < contentLength);
|
||||||
|
if (plainBuf == nullptr) return false;
|
||||||
#ifdef DEBUG_ESP_HTTP_SERVER
|
#ifdef DEBUG_ESP_HTTP_SERVER
|
||||||
DEBUG_OUTPUT.print("Plain: ");
|
DEBUG_OUTPUT.print("Plain: ");
|
||||||
DEBUG_OUTPUT.println(plainBuf);
|
DEBUG_OUTPUT.println(plainBuf);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user