@@ -359,14 +359,14 @@ void WebServer::_uploadWriteByte(uint8_t b){
359
359
_currentUpload->buf [_currentUpload->currentSize ++] = b;
360
360
}
361
361
362
- uint8_t WebServer::_uploadReadByte (WiFiClient& client){
362
+ int WebServer::_uploadReadByte (WiFiClient& client){
363
363
int res = client.read ();
364
364
if (res == -1 ){
365
365
while (!client.available () && client.connected ())
366
366
delay (2 );
367
367
res = client.read ();
368
368
}
369
- return ( uint8_t ) res;
369
+ return res;
370
370
}
371
371
372
372
bool WebServer::_parseForm (WiFiClient& client, String boundary, uint32_t len){
@@ -477,27 +477,28 @@ bool WebServer::_parseForm(WiFiClient& client, String boundary, uint32_t len){
477
477
if (_currentHandler && _currentHandler->canUpload (_currentUri))
478
478
_currentHandler->upload (*this , _currentUri, *_currentUpload);
479
479
_currentUpload->status = UPLOAD_FILE_WRITE;
480
- uint8_t argByte = _uploadReadByte (client) ;
480
+ int argByte;
481
481
readfile:
482
- while (argByte != 0x0D ){
483
- if (!client.connected ()) return _parseFormUploadAborted ();
484
- _uploadWriteByte (argByte);
482
+
483
+ do {
485
484
argByte = _uploadReadByte (client);
486
- }
485
+ if (argByte < 0 ) return _parseFormUploadAborted ();
486
+ _uploadWriteByte (argByte);
487
+ }while (argByte != 0x0D );
487
488
488
489
argByte = _uploadReadByte (client);
489
- if (!client. connected () ) return _parseFormUploadAborted ();
490
+ if (argByte < 0 ) return _parseFormUploadAborted ();
490
491
if (argByte == 0x0A ){
491
492
argByte = _uploadReadByte (client);
492
- if (!client. connected () ) return _parseFormUploadAborted ();
493
+ if (argByte < 0 ) return _parseFormUploadAborted ();
493
494
if ((char )argByte != ' -' ){
494
495
// continue reading the file
495
496
_uploadWriteByte (0x0D );
496
497
_uploadWriteByte (0x0A );
497
498
goto readfile;
498
499
} else {
499
500
argByte = _uploadReadByte (client);
500
- if (!client. connected () ) return _parseFormUploadAborted ();
501
+ if (argByte < 0 ) return _parseFormUploadAborted ();
501
502
if ((char )argByte != ' -' ){
502
503
// continue reading the file
503
504
_uploadWriteByte (0x0D );
0 commit comments