Test fixes for Tobiases

This commit is contained in:
Jm 2021-01-05 18:57:03 -08:00
parent eb402809e2
commit 84e3d7c276
2 changed files with 14 additions and 4 deletions

2
proto

@ -1 +1 @@
Subproject commit dfe7bc1217a00c23eecb9dfcf1d56fe95ebddc3b Subproject commit 75078afe43934f4ce15ef86ebc6950658a170145

View File

@ -494,6 +494,9 @@ void handleStaticBrowse(HTTPRequest *req, HTTPResponse *res)
std::string paramValDelete; std::string paramValDelete;
std::string paramValEdit; std::string paramValEdit;
DEBUG_MSG("Static Browse - Disabling keep-alive\n");
res->setHeader("Connection", "close");
// Set a default content type // Set a default content type
res->setHeader("Content-Type", "text/html"); res->setHeader("Content-Type", "text/html");
@ -700,6 +703,11 @@ void handleStatic(HTTPRequest *req, HTTPResponse *res)
void handleFormUpload(HTTPRequest *req, HTTPResponse *res) void handleFormUpload(HTTPRequest *req, HTTPResponse *res)
{ {
DEBUG_MSG("Form Upload - Disabling keep-alive\n");
res->setHeader("Connection", "close");
DEBUG_MSG("Form Upload - Set frequency to 240mhz\n");
// The upload process is very CPU intensive. Let's speed things up a bit. // The upload process is very CPU intensive. Let's speed things up a bit.
setCpuFrequencyMhz(240); setCpuFrequencyMhz(240);
@ -708,6 +716,7 @@ void handleFormUpload(HTTPRequest *req, HTTPResponse *res)
// Then we select the body parser based on the encoding. // Then we select the body parser based on the encoding.
// Actually we do this only for documentary purposes, we know the form is going // Actually we do this only for documentary purposes, we know the form is going
// to be multipart/form-data. // to be multipart/form-data.
DEBUG_MSG("Form Upload - Creating body parser reference\n");
HTTPBodyParser *parser; HTTPBodyParser *parser;
std::string contentType = req->getHeader("Content-Type"); std::string contentType = req->getHeader("Content-Type");
@ -723,6 +732,7 @@ void handleFormUpload(HTTPRequest *req, HTTPResponse *res)
// Now, we can decide based on the content type: // Now, we can decide based on the content type:
if (contentType == "multipart/form-data") { if (contentType == "multipart/form-data") {
DEBUG_MSG("Form Upload - multipart/form-data\n");
parser = new HTTPMultipartBodyParser(req); parser = new HTTPMultipartBodyParser(req);
} else { } else {
Serial.printf("Unknown POST Content-Type: %s\n", contentType.c_str()); Serial.printf("Unknown POST Content-Type: %s\n", contentType.c_str());
@ -757,21 +767,21 @@ void handleFormUpload(HTTPRequest *req, HTTPResponse *res)
// Double check that it is what we expect // Double check that it is what we expect
if (name != "file") { if (name != "file") {
DEBUG_MSG("Skipping unexpected field"); DEBUG_MSG("Skipping unexpected field\n");
res->println("<p>No file found.</p>"); res->println("<p>No file found.</p>");
return; return;
} }
// Double check that it is what we expect // Double check that it is what we expect
if (filename == "") { if (filename == "") {
DEBUG_MSG("Skipping unexpected field"); DEBUG_MSG("Skipping unexpected field\n");
res->println("<p>No file found.</p>"); res->println("<p>No file found.</p>");
return; return;
} }
// SPIFFS limits the total lenth of a path + file to 31 characters. // SPIFFS limits the total lenth of a path + file to 31 characters.
if (filename.length() + 8 > 31) { if (filename.length() + 8 > 31) {
DEBUG_MSG("Uploaded filename too long!"); DEBUG_MSG("Uploaded filename too long!\n");
res->println("<p>Uploaded filename too long! Limit of 23 characters.</p>"); res->println("<p>Uploaded filename too long! Limit of 23 characters.</p>");
delete parser; delete parser;
return; return;