Skip to content

Commit 8f28c88

Browse files
RickeyWardearlephilhower
authored andcommitted
Added naive content length to upload struct (#5142)
Content length provides context into the size of the upload, it's not the exact form body size it's off by the request header info, but it was already parsed by the library and provides little to no additional overhead to pass on for use in request handlers.
1 parent 1fb9b4e commit 8f28c88

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

Diff for: libraries/ESP8266WebServer/src/ESP8266WebServer.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,9 @@ typedef struct {
5555
String filename;
5656
String name;
5757
String type;
58-
size_t totalSize; // file size
58+
size_t totalSize; // total size of uploaded file so far
5959
size_t currentSize; // size of data currently in buf
60+
size_t contentLength; // size of entire post request, file size + headers and other request data.
6061
uint8_t buf[HTTP_UPLOAD_BUFLEN];
6162
} HTTPUpload;
6263

Diff for: libraries/ESP8266WebServer/src/Parsing.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,7 @@ bool ESP8266WebServer::_parseForm(WiFiClient& client, const String& boundary, ui
468468
_currentUpload->type = argType;
469469
_currentUpload->totalSize = 0;
470470
_currentUpload->currentSize = 0;
471+
_currentUpload->contentLength = len;
471472
#ifdef DEBUG_ESP_HTTP_SERVER
472473
DEBUG_OUTPUT.print("Start File: ");
473474
DEBUG_OUTPUT.print(_currentUpload->filename);

0 commit comments

Comments
 (0)