@@ -44,9 +44,8 @@ static bool readBytesWithTimeout(typename ServerType::ClientType& client, size_t
44
44
template <typename ServerType>
45
45
typename ESP8266WebServerTemplate<ServerType>::ClientFuture ESP8266WebServerTemplate<ServerType>::_parseRequest(ClientType& client) {
46
46
// Read the first line of HTTP request
47
- String req = client.readStringUntil ( ' \r ' );
47
+ String req = client.readStreamStringUntil ( " \r\n " );
48
48
DBGWS (" request: %s\n " , req.c_str ());
49
- client.readStringUntil (' \n ' );
50
49
// reset header value
51
50
for (int i = 0 ; i < _headerKeysCount; ++i) {
52
51
_currentHeaders[i].value .clear ();
@@ -122,8 +121,7 @@ typename ESP8266WebServerTemplate<ServerType>::ClientFuture ESP8266WebServerTemp
122
121
uint32_t contentLength = 0 ;
123
122
// parse headers
124
123
while (1 ){
125
- req = client.readStringUntil (' \r ' );
126
- client.readStringUntil (' \n ' );
124
+ req = client.readStreamStringUntil (" \r\n " );
127
125
if (req.isEmpty ()) break ; // no more headers
128
126
int headerDiv = req.indexOf (' :' );
129
127
if (headerDiv == -1 ){
@@ -198,8 +196,7 @@ typename ESP8266WebServerTemplate<ServerType>::ClientFuture ESP8266WebServerTemp
198
196
String headerValue;
199
197
// parse headers
200
198
while (1 ){
201
- req = client.readStringUntil (' \r ' );
202
- client.readStringUntil (' \n ' );
199
+ req = client.readStreamStringUntil (" \r\n " );
203
200
if (req.isEmpty ()) break ;// no moar headers
204
201
int headerDiv = req.indexOf (' :' );
205
202
if (headerDiv == -1 ){
@@ -351,11 +348,10 @@ bool ESP8266WebServerTemplate<ServerType>::_parseForm(ClientType& client, const
351
348
String line;
352
349
int retry = 0 ;
353
350
do {
354
- line = client.readStringUntil ( ' \r ' );
351
+ line = client.readStreamStringUntil ( " \r\n " );
355
352
++retry;
356
353
} while (line.length () == 0 && retry < 3 );
357
354
358
- client.readStringUntil (' \n ' );
359
355
// start reading the form
360
356
if (line == (" --" +boundary)){
361
357
if (_postArgs) delete[] _postArgs;
@@ -368,8 +364,7 @@ bool ESP8266WebServerTemplate<ServerType>::_parseForm(ClientType& client, const
368
364
String argFilename;
369
365
bool argIsFile = false ;
370
366
371
- line = client.readStringUntil (' \r ' );
372
- client.readStringUntil (' \n ' );
367
+ line = client.readStreamStringUntil (" \r\n " );
373
368
if (line.length () > 19 && line.substring (0 , 19 ).equalsIgnoreCase (F (" Content-Disposition" ))){
374
369
int nameStart = line.indexOf (' =' );
375
370
if (nameStart != -1 ){
@@ -389,19 +384,16 @@ bool ESP8266WebServerTemplate<ServerType>::_parseForm(ClientType& client, const
389
384
DBGWS (" PostArg Name: %s\n " , argName.c_str ());
390
385
using namespace mime ;
391
386
argType = FPSTR (mimeTable[txt].mimeType );
392
- line = client.readStringUntil (' \r ' );
393
- client.readStringUntil (' \n ' );
387
+ line = client.readStreamStringUntil (" \r\n " );
394
388
if (line.length () > 12 && line.substring (0 , 12 ).equalsIgnoreCase (FPSTR (Content_Type))){
395
389
argType = line.substring (line.indexOf (' :' )+2 );
396
390
// skip next line
397
- client.readStringUntil (' \r ' );
398
- client.readStringUntil (' \n ' );
391
+ client.readStringUntil (" \r\n " );
399
392
}
400
393
DBGWS (" PostArg Type: %s\n " , argType.c_str ());
401
394
if (!argIsFile){
402
395
while (1 ){
403
- line = client.readStringUntil (' \r ' );
404
- client.readStringUntil (' \n ' );
396
+ line = client.readStreamStringUntil (" \r\n " );
405
397
if (line.startsWith (" --" +boundary)) break ;
406
398
if (argValue.length () > 0 ) argValue += ' \n ' ;
407
399
argValue += line;
@@ -475,8 +467,7 @@ bool ESP8266WebServerTemplate<ServerType>::_parseForm(ClientType& client, const
475
467
_currentUpload->type .c_str (),
476
468
(int )_currentUpload->totalSize );
477
469
if (!client.connected ()) return _parseFormUploadAborted ();
478
- line = client.readStringUntil (' \r ' );
479
- client.readStringUntil (' \n ' );
470
+ line = client.readStreamStringUntil (" \r\n " );
480
471
if (line == " --" ) { // extra two dashes mean we reached the end of all form fields
481
472
DBGWS (" Done Parsing POST\n " );
482
473
break ;
0 commit comments