File tree Expand file tree Collapse file tree 1 file changed +15
-8
lines changed
libraries/ESP8266WebServer/src Expand file tree Collapse file tree 1 file changed +15
-8
lines changed Original file line number Diff line number Diff line change @@ -138,14 +138,21 @@ bool ESP8266WebServer::_parseRequest(WiFiClient& client) {
138
138
139
139
if (!isForm){
140
140
if (searchStr != " " ) searchStr += ' &' ;
141
- // some clients send headers first and data after (like we do)
142
- // give them a chance
143
- int tries = 100 ;// 100ms max wait
144
- while (!client.available () && tries--)delay (1 );
145
- size_t plainLen = client.available ();
146
- char *plainBuf = (char *)malloc (plainLen+1 );
147
- client.readBytes (plainBuf, plainLen);
148
- plainBuf[plainLen] = ' \0 ' ;
141
+ char *plainBuf = NULL ;
142
+ size_t plainLen = 0 ;
143
+ while ( (plainLen == 0 ) || (plainLen < contentLength))
144
+ {
145
+ // some clients send headers first and data after (like we do)
146
+ // give them a chance
147
+ int tries = 100 ;// 100ms max wait
148
+ while (!client.available () && tries--)delay (1 );
149
+ size_t newLen = client.available ();
150
+ if (!newLen) break ;
151
+ plainBuf = (plainBuf == NULL ) ? (char *) malloc (newLen + 1 ) : (char *) realloc (plainBuf, plainLen + newLen + 1 );
152
+ client.readBytes (&plainBuf[plainLen], newLen);
153
+ plainLen += newLen;
154
+ plainBuf[plainLen] = ' \0 ' ;
155
+ }
149
156
#ifdef DEBUG_ESP_HTTP_SERVER
150
157
DEBUG_OUTPUT.print (" Plain: " );
151
158
DEBUG_OUTPUT.println (plainBuf);
You can’t perform that action at this time.
0 commit comments