some fixes for web frameworks compat

This commit is contained in:
Bogdan Pilyugin 2023-07-21 16:03:13 +02:00
parent 51db5691ce
commit 93c35bf7da

View File

@ -112,10 +112,22 @@ static esp_err_t set_content_type_from_file(httpd_req_t *req,
{ {
return httpd_resp_set_type(req, "image/x-icon"); return httpd_resp_set_type(req, "image/x-icon");
} }
else if (IS_FILE_EXT(filename, ".svg"))
{
return httpd_resp_set_type(req, "image/svg+xml");
}
else if (IS_FILE_EXT(filename, ".css")) else if (IS_FILE_EXT(filename, ".css"))
{ {
return httpd_resp_set_type(req, "text/css"); return httpd_resp_set_type(req, "text/css");
} }
else if (IS_FILE_EXT(filename, ".js"))
{
return httpd_resp_set_type(req, "text/javascript");
}
else if (IS_FILE_EXT(filename, ".woff"))
{
return httpd_resp_set_type(req, "font/woff");
}
else if (IS_FILE_EXT(filename, ".woff2")) else if (IS_FILE_EXT(filename, ".woff2"))
{ {
return httpd_resp_set_type(req, "font/woff2"); return httpd_resp_set_type(req, "font/woff2");
@ -336,6 +348,7 @@ static esp_err_t GETHandler(httpd_req_t *req)
bufSize = MIN(stat.size, SCRATCH_BUFSIZE - MAX_DYNVAR_LENGTH); bufSize = MIN(stat.size, SCRATCH_BUFSIZE - MAX_DYNVAR_LENGTH);
readBytes = 0; readBytes = 0;
//allocate buffer for file data //allocate buffer for file data
if(bufSize == 0) bufSize = 1;
char *buf = (char*) malloc(bufSize); char *buf = (char*) malloc(bufSize);
if (!buf) if (!buf)
{ {
@ -354,7 +367,8 @@ static esp_err_t GETHandler(httpd_req_t *req)
IS_FILE_EXT(filename, ".json") || IS_FILE_EXT(filename, ".json") ||
IS_FILE_EXT(filename, ".css") || IS_FILE_EXT(filename, ".css") ||
IS_FILE_EXT(filename, ".js")) IS_FILE_EXT(filename, ".js"))
isDynamicVars = true; isDynamicVars = false;
//check if file is compressed by GZIP and add correspondent header //check if file is compressed by GZIP and add correspondent header
if (memmem(buf, 3, GZIP_SIGN, 3)) if (memmem(buf, 3, GZIP_SIGN, 3))