#define RESPONSE_STREAM_BUFFER_SIZE 1460

This commit is contained in:
Mathieu Carbou
2024-09-11 21:56:23 +02:00
parent 02063bd929
commit e28aa5e3fc
2 changed files with 5 additions and 4 deletions

View File

@@ -101,6 +101,7 @@ namespace fs {
// if this value is returned when asked for data, packet will not be sent and you will be asked for data again
#define RESPONSE_TRY_AGAIN 0xFFFFFFFF
#define RESPONSE_STREAM_BUFFER_SIZE 1460
typedef uint8_t WebRequestMethodComposite;
typedef std::function<void(void)> ArDisconnectHandler;
@@ -377,8 +378,8 @@ class AsyncWebServerRequest {
AsyncWebServerResponse* beginChunkedResponse(const char* contentType, AwsResponseFiller callback, AwsTemplateProcessor templateCallback = nullptr);
AsyncWebServerResponse* beginChunkedResponse(const String& contentType, AwsResponseFiller callback, AwsTemplateProcessor templateCallback = nullptr);
AsyncResponseStream* beginResponseStream(const char* contentType, size_t bufferSize = 1460);
AsyncResponseStream* beginResponseStream(const String& contentType, size_t bufferSize = 1460) { return beginResponseStream(contentType.c_str(), bufferSize); }
AsyncResponseStream* beginResponseStream(const char* contentType, size_t bufferSize = RESPONSE_STREAM_BUFFER_SIZE);
AsyncResponseStream* beginResponseStream(const String& contentType, size_t bufferSize = RESPONSE_STREAM_BUFFER_SIZE) { return beginResponseStream(contentType.c_str(), bufferSize); }
#ifndef ESP8266
[[deprecated("Replaced by beginResponse(...)")]]

View File

@@ -340,7 +340,7 @@ void AsyncWebServerRequest::_parsePlainPostChar(uint8_t data) {
void AsyncWebServerRequest::_handleUploadByte(uint8_t data, bool last) {
_itemBuffer[_itemBufferIndex++] = data;
if (last || _itemBufferIndex == 1460) {
if (last || _itemBufferIndex == RESPONSE_STREAM_BUFFER_SIZE) {
// check if authenticated before calling the upload
if (_handler)
_handler->handleUpload(this, _itemFilename, _itemSize - _itemBufferIndex, _itemBuffer, _itemBufferIndex, false);
@@ -444,7 +444,7 @@ void AsyncWebServerRequest::_parseMultipartPostByte(uint8_t data, bool last) {
if (_itemIsFile) {
if (_itemBuffer)
free(_itemBuffer);
_itemBuffer = (uint8_t*)malloc(1460);
_itemBuffer = (uint8_t*)malloc(RESPONSE_STREAM_BUFFER_SIZE);
if (_itemBuffer == NULL) {
_multiParseState = PARSE_ERROR;
return;