UNTESTED: fix for sending proper content type on config endpoint

This commit is contained in:
Niklas Jensen
2026-01-26 13:24:19 +01:00
committed by nikguin04
parent 25063c1bd4
commit 0a2d3c0e31
2 changed files with 20 additions and 1 deletions
+8 -1
View File
@@ -2,6 +2,7 @@
#include <communication/webserver.h>
#include <vector>
#include <cstring>
#include "utils/string_utils.hpp"
static const char *TAG = "FileService";
@@ -107,7 +108,13 @@ esp_err_t getConfigFile(httpd_req_t *request) {
}
String content = file.readString();
file.close();
httpd_resp_set_type(request, "application/json");
if (ends_with(path, ".pb")) {
httpd_resp_set_type(request, "application/x-protobuf");
} else if (ends_with(path, ".json")) {
httpd_resp_set_type(request, "application/json");
} else {
httpd_resp_set_type(request, "text/plain");
}
return httpd_resp_send(request, content.c_str(), content.length());
}