Convert resursive call to iterations, reduce stack usage (#120)
This commit is contained in:
parent
1d66bbfc77
commit
213387b88f
|
@ -96,6 +96,8 @@ AsyncWebServerRequest::~AsyncWebServerRequest(){
|
|||
}
|
||||
|
||||
void AsyncWebServerRequest::_onData(void *buf, size_t len){
|
||||
while (true) {
|
||||
|
||||
if(_parseState < PARSE_REQ_BODY){
|
||||
// Find new line in buf
|
||||
char *str = (char*)buf;
|
||||
|
@ -112,7 +114,12 @@ void AsyncWebServerRequest::_onData(void *buf, size_t len){
|
|||
_temp.concat(str);
|
||||
_temp.trim();
|
||||
_parseLine();
|
||||
if (++i < len) _onData(str+i, len-i); // Still have more buffer to process
|
||||
if (++i < len) {
|
||||
// Still have more buffer to process
|
||||
buf = str+i;
|
||||
len-= i;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
} else if(_parseState == PARSE_REQ_BODY){
|
||||
if(_isMultipart){
|
||||
|
@ -153,6 +160,9 @@ void AsyncWebServerRequest::_onData(void *buf, size_t len){
|
|||
else send(501);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void AsyncWebServerRequest::_onPoll(){
|
||||
|
|
Loading…
Reference in New Issue