Skip to content

Supporting ETag http headers on static files #7687

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 20 commits into from
Nov 30, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
example updated, som more TRACE output.
  • Loading branch information
mathertel committed Feb 1, 2023
commit 108ea5a823996615732f01e4662fd6951c957c7e
19 changes: 15 additions & 4 deletions libraries/WebServer/examples/WebServer/WebServer.ino
Original file line number Diff line number Diff line change
Expand Up @@ -163,20 +163,31 @@ public:
void upload(WebServer UNUSED &server, String UNUSED _requestUri, HTTPUpload &upload) override {
// ensure that filename starts with '/'
String fName = upload.filename;
static size_t uploadSize;
if (!fName.startsWith("/")) { fName = "/" + fName; }

if (upload.status == UPLOAD_FILE_START) {
// Open the file
if (LittleFS.exists(fName)) { LittleFS.remove(fName); } // if
// Open the file for writing
TRACE("starting upload file %s...", fName.c_str());
if (LittleFS.exists(fName)) {
LittleFS.remove(fName);
} // if
_fsUploadFile = LittleFS.open(fName, "w");
uploadSize = 0;

} else if (upload.status == UPLOAD_FILE_WRITE) {
// Write received bytes
if (_fsUploadFile) { _fsUploadFile.write(upload.buf, upload.currentSize); }
if (_fsUploadFile) {
_fsUploadFile.write(upload.buf, upload.currentSize);
uploadSize += upload.currentSize;
}

} else if (upload.status == UPLOAD_FILE_END) {
// Close the file
if (_fsUploadFile) { _fsUploadFile.close(); }
if (_fsUploadFile) {
_fsUploadFile.close();
}
TRACE("uploading %d bytes done.", uploadSize);
} // if
} // upload()

Expand Down