forked from me-no-dev/ESPAsyncWebServer
Atempt at fixing large uploads
Fixing: https://github.com/me-no-dev/ESPAsyncWebServer/issues/29
This commit is contained in:
@@ -316,7 +316,8 @@ void AsyncWebServerRequest::_parsePlainPostChar(uint8_t data){
|
|||||||
|
|
||||||
void AsyncWebServerRequest::_handleUploadByte(uint8_t data, bool last){
|
void AsyncWebServerRequest::_handleUploadByte(uint8_t data, bool last){
|
||||||
_itemBuffer[_itemBufferIndex++] = data;
|
_itemBuffer[_itemBufferIndex++] = data;
|
||||||
if(last){
|
|
||||||
|
if(last || _itemBufferIndex = 1460){
|
||||||
if(_handler)
|
if(_handler)
|
||||||
_handler->handleUpload(this, _itemFilename, _itemSize - _itemBufferIndex, _itemBuffer, _itemBufferIndex, false);
|
_handler->handleUpload(this, _itemFilename, _itemSize - _itemBufferIndex, _itemBuffer, _itemBufferIndex, false);
|
||||||
_itemBufferIndex = 0;
|
_itemBufferIndex = 0;
|
||||||
@@ -348,7 +349,13 @@ void AsyncWebServerRequest::_parseMultipartPostByte(uint8_t data, bool last){
|
|||||||
_itemType = String();
|
_itemType = String();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(_multiParseState == EXPECT_BOUNDARY){
|
if(_multiParseState == WAIT_FOR_RETURN1){
|
||||||
|
if(data != '\r'){
|
||||||
|
itemWriteByte(data);
|
||||||
|
} else {
|
||||||
|
_multiParseState = EXPECT_FEED1;
|
||||||
|
}
|
||||||
|
} else if(_multiParseState == EXPECT_BOUNDARY){
|
||||||
if(_parsedLength < 2 && data != '-'){
|
if(_parsedLength < 2 && data != '-'){
|
||||||
_multiParseState = PARSE_ERROR;
|
_multiParseState = PARSE_ERROR;
|
||||||
return;
|
return;
|
||||||
@@ -407,16 +414,14 @@ void AsyncWebServerRequest::_parseMultipartPostByte(uint8_t data, bool last){
|
|||||||
if(_itemBuffer)
|
if(_itemBuffer)
|
||||||
free(_itemBuffer);
|
free(_itemBuffer);
|
||||||
_itemBuffer = (uint8_t*)malloc(1460);
|
_itemBuffer = (uint8_t*)malloc(1460);
|
||||||
|
if(_itemBuffer == NULL){
|
||||||
|
_multiParseState = PARSE_ERROR;
|
||||||
|
return;
|
||||||
|
}
|
||||||
_itemBufferIndex = 0;
|
_itemBufferIndex = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if(_multiParseState == WAIT_FOR_RETURN1){
|
|
||||||
if(data != '\r'){
|
|
||||||
itemWriteByte(data);
|
|
||||||
} else {
|
|
||||||
_multiParseState = EXPECT_FEED1;
|
|
||||||
}
|
|
||||||
} else if(_multiParseState == EXPECT_FEED1){
|
} else if(_multiParseState == EXPECT_FEED1){
|
||||||
if(data != '\n'){
|
if(data != '\n'){
|
||||||
_multiParseState = WAIT_FOR_RETURN1;
|
_multiParseState = WAIT_FOR_RETURN1;
|
||||||
|
Reference in New Issue
Block a user