forked from me-no-dev/ESPAsyncWebServer
fixes
This commit is contained in:
@@ -30,7 +30,7 @@ class SPIFFSEditor: public AsyncWebHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void handleRequest(AsyncWebServerRequest *request){
|
void handleRequest(AsyncWebServerRequest *request){
|
||||||
if(_username.length() && (request->method() != HTTP_GET || (request->url() != "/edit" && request->url() != "/list")) && !request->authenticate(_username.c_str(),_password.c_str()))
|
if(_username.length() && (request->method() != HTTP_GET || request->url() == "/edit" || request->url() == "/list") && !request->authenticate(_username.c_str(),_password.c_str()))
|
||||||
return request->requestAuthentication();
|
return request->requestAuthentication();
|
||||||
|
|
||||||
if(request->method() == HTTP_GET && request->url() == "/edit"){
|
if(request->method() == HTTP_GET && request->url() == "/edit"){
|
||||||
|
@@ -218,11 +218,11 @@ size_t AsyncAbstractResponse::_ack(AsyncWebServerRequest *request, size_t len, u
|
|||||||
if(_state == RESPONSE_CONTENT){
|
if(_state == RESPONSE_CONTENT){
|
||||||
size_t remaining = _contentLength - _sentLength;
|
size_t remaining = _contentLength - _sentLength;
|
||||||
size_t outLen = (remaining > space)?space:remaining;
|
size_t outLen = (remaining > space)?space:remaining;
|
||||||
uint8_t *buf = (uint8_t *)os_malloc(outLen);
|
uint8_t *buf = (uint8_t *)malloc(outLen);
|
||||||
outLen = _fillBuffer(buf, outLen);
|
outLen = _fillBuffer(buf, outLen);
|
||||||
request->client()->write((const char*)buf, outLen);
|
request->client()->write((const char*)buf, outLen);
|
||||||
_sentLength += outLen;
|
_sentLength += outLen;
|
||||||
os_free(buf);
|
free(buf);
|
||||||
if(_sentLength == _contentLength){
|
if(_sentLength == _contentLength){
|
||||||
_state = RESPONSE_WAIT_ACK;
|
_state = RESPONSE_WAIT_ACK;
|
||||||
}
|
}
|
||||||
|
@@ -79,7 +79,6 @@ AsyncWebServerRequest::~AsyncWebServerRequest(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void AsyncWebServerRequest::_onData(void *buf, size_t len){
|
void AsyncWebServerRequest::_onData(void *buf, size_t len){
|
||||||
//os_printf("r:%u\n", len);
|
|
||||||
if(_parseState < PARSE_REQ_BODY){
|
if(_parseState < PARSE_REQ_BODY){
|
||||||
size_t i;
|
size_t i;
|
||||||
for(i=0; i<len; i++){
|
for(i=0; i<len; i++){
|
||||||
@@ -291,7 +290,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){
|
||||||
if(_handler) _handler->handleUpload(this, _itemFilename, _itemSize - _itemBufferIndex, _itemBuffer, _itemBufferIndex, false);
|
if(_handler)
|
||||||
|
_handler->handleUpload(this, _itemFilename, _itemSize - _itemBufferIndex, _itemBuffer, _itemBufferIndex, false);
|
||||||
_itemBufferIndex = 0;
|
_itemBufferIndex = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -312,6 +312,7 @@ enum {
|
|||||||
|
|
||||||
void AsyncWebServerRequest::_parseMultipartPostByte(uint8_t data, bool last){
|
void AsyncWebServerRequest::_parseMultipartPostByte(uint8_t data, bool last){
|
||||||
#define itemWriteByte(b) do { _itemSize++; if(_itemIsFile) _handleUploadByte(b, last); else _itemValue+=(char)(b); } while(0)
|
#define itemWriteByte(b) do { _itemSize++; if(_itemIsFile) _handleUploadByte(b, last); else _itemValue+=(char)(b); } while(0)
|
||||||
|
|
||||||
if(!_parsedLength){
|
if(!_parsedLength){
|
||||||
_multiParseState = EXPECT_BOUNDARY;
|
_multiParseState = EXPECT_BOUNDARY;
|
||||||
_temp = String();
|
_temp = String();
|
||||||
@@ -377,8 +378,8 @@ void AsyncWebServerRequest::_parseMultipartPostByte(uint8_t data, bool last){
|
|||||||
_itemValue = String();
|
_itemValue = String();
|
||||||
if(_itemIsFile){
|
if(_itemIsFile){
|
||||||
if(_itemBuffer)
|
if(_itemBuffer)
|
||||||
os_free(_itemBuffer);
|
free(_itemBuffer);
|
||||||
_itemBuffer = (uint8_t*)os_malloc(1460);
|
_itemBuffer = (uint8_t*)malloc(1460);
|
||||||
_itemBufferIndex = 0;
|
_itemBufferIndex = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -429,13 +430,14 @@ void AsyncWebServerRequest::_parseMultipartPostByte(uint8_t data, bool last){
|
|||||||
_itemBufferIndex = 0;
|
_itemBufferIndex = 0;
|
||||||
_addParam(new AsyncWebParameter(_itemName, _itemFilename, true, true, _itemSize));
|
_addParam(new AsyncWebParameter(_itemName, _itemFilename, true, true, _itemSize));
|
||||||
}
|
}
|
||||||
os_free(_itemBuffer);
|
free(_itemBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
_boundaryPosition++;
|
_boundaryPosition++;
|
||||||
}
|
}
|
||||||
} else if(_multiParseState == DASH3_OR_RETURN2){
|
} else if(_multiParseState == DASH3_OR_RETURN2){
|
||||||
|
os_printf("X:%u:'%c'\n",_contentLength - _parsedLength - 4,data);
|
||||||
if(data == '\r'){
|
if(data == '\r'){
|
||||||
_multiParseState = EXPECT_FEED2;
|
_multiParseState = EXPECT_FEED2;
|
||||||
} else if(data == '-' && _contentLength == (_parsedLength + 4)){
|
} else if(data == '-' && _contentLength == (_parsedLength + 4)){
|
||||||
|
Reference in New Issue
Block a user