mirror of
https://github.com/simon987/sist2.git
synced 2025-04-16 00:46:43 +00:00
Update to mongoose 7.6
This commit is contained in:
parent
8bfd010f4b
commit
ea7dfe7c84
@ -60,7 +60,7 @@ static const char *const Version = VERSION;
|
|||||||
#define SIST_PLATFORM unknown
|
#define SIST_PLATFORM unknown
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define EXPECTED_MONGOOSE_VERSION "7.3"
|
#define EXPECTED_MONGOOSE_VERSION "7.6"
|
||||||
|
|
||||||
#define Q(x) #x
|
#define Q(x) #x
|
||||||
#define QUOTE(x) Q(x)
|
#define QUOTE(x) Q(x)
|
||||||
|
@ -12,6 +12,13 @@
|
|||||||
#define HTTP_TEXT_TYPE_HEADER "Content-Type: text/plain;charset=utf-8\r\n"
|
#define HTTP_TEXT_TYPE_HEADER "Content-Type: text/plain;charset=utf-8\r\n"
|
||||||
#define HTTP_REPLY_NOT_FOUND mg_http_reply(nc, 404, HTTP_SERVER_HEADER HTTP_TEXT_TYPE_HEADER, "Not found");
|
#define HTTP_REPLY_NOT_FOUND mg_http_reply(nc, 404, HTTP_SERVER_HEADER HTTP_TEXT_TYPE_HEADER, "Not found");
|
||||||
|
|
||||||
|
static struct mg_http_serve_opts DefaultServeOpts = {
|
||||||
|
.fs = NULL,
|
||||||
|
.ssi_pattern = NULL,
|
||||||
|
.root_dir = NULL,
|
||||||
|
.mime_types = ""
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
static void send_response_line(struct mg_connection *nc, int status_code, size_t length, char *extra_headers) {
|
static void send_response_line(struct mg_connection *nc, int status_code, size_t length, char *extra_headers) {
|
||||||
mg_printf(
|
mg_printf(
|
||||||
@ -54,7 +61,7 @@ store_t *get_tag_store(const char *index_id) {
|
|||||||
|
|
||||||
void search_index(struct mg_connection *nc, struct mg_http_message *hm) {
|
void search_index(struct mg_connection *nc, struct mg_http_message *hm) {
|
||||||
if (WebCtx.dev) {
|
if (WebCtx.dev) {
|
||||||
mg_http_serve_file(nc, hm, "sist2-vue/dist/index.html", "text/html", NULL);
|
mg_http_serve_file(nc, hm, "sist2-vue/dist/index.html", &DefaultServeOpts);
|
||||||
} else {
|
} else {
|
||||||
send_response_line(nc, 200, sizeof(index_html), "Content-Type: text/html");
|
send_response_line(nc, 200, sizeof(index_html), "Content-Type: text/html");
|
||||||
mg_send(nc, index_html, sizeof(index_html));
|
mg_send(nc, index_html, sizeof(index_html));
|
||||||
@ -104,12 +111,13 @@ void stats_files(struct mg_connection *nc, struct mg_http_message *hm) {
|
|||||||
strcpy(full_path, index->path);
|
strcpy(full_path, index->path);
|
||||||
strcat(full_path, file);
|
strcat(full_path, file);
|
||||||
|
|
||||||
mg_http_serve_file(nc, hm, full_path, "text/csv", disposition);
|
struct mg_http_serve_opts opts = {};
|
||||||
|
mg_http_serve_file(nc, hm, full_path, &opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
void javascript(struct mg_connection *nc, struct mg_http_message *hm) {
|
void javascript(struct mg_connection *nc, struct mg_http_message *hm) {
|
||||||
if (WebCtx.dev) {
|
if (WebCtx.dev) {
|
||||||
mg_http_serve_file(nc, hm, "sist2-vue/dist/js/index.js", "application/javascript", NULL);
|
mg_http_serve_file(nc, hm, "sist2-vue/dist/js/index.js", &DefaultServeOpts);
|
||||||
} else {
|
} else {
|
||||||
send_response_line(nc, 200, sizeof(index_js), "Content-Type: application/javascript");
|
send_response_line(nc, 200, sizeof(index_js), "Content-Type: application/javascript");
|
||||||
mg_send(nc, index_js, sizeof(index_js));
|
mg_send(nc, index_js, sizeof(index_js));
|
||||||
@ -118,7 +126,7 @@ void javascript(struct mg_connection *nc, struct mg_http_message *hm) {
|
|||||||
|
|
||||||
void javascript_vendor(struct mg_connection *nc, struct mg_http_message *hm) {
|
void javascript_vendor(struct mg_connection *nc, struct mg_http_message *hm) {
|
||||||
if (WebCtx.dev) {
|
if (WebCtx.dev) {
|
||||||
mg_http_serve_file(nc, hm, "sist2-vue/dist/js/chunk-vendors.js", "application/javascript", NULL);
|
mg_http_serve_file(nc, hm, "sist2-vue/dist/js/chunk-vendors.js", &DefaultServeOpts);
|
||||||
} else {
|
} else {
|
||||||
send_response_line(nc, 200, sizeof(chunk_vendors_js), "Content-Type: application/javascript");
|
send_response_line(nc, 200, sizeof(chunk_vendors_js), "Content-Type: application/javascript");
|
||||||
mg_send(nc, chunk_vendors_js, sizeof(chunk_vendors_js));
|
mg_send(nc, chunk_vendors_js, sizeof(chunk_vendors_js));
|
||||||
@ -274,10 +282,18 @@ void serve_file_from_disk(cJSON *json, index_t *idx, struct mg_connection *nc, s
|
|||||||
|
|
||||||
char disposition[8192];
|
char disposition[8192];
|
||||||
snprintf(disposition, sizeof(disposition),
|
snprintf(disposition, sizeof(disposition),
|
||||||
HTTP_SERVER_HEADER "Content-Disposition: inline; filename=\"%s%s%s\"\r\nAccept-Ranges: bytes\r\n",
|
HTTP_SERVER_HEADER "Content-Disposition: inline; filename=\"%s%s%s\"\r\n"
|
||||||
|
"Accept-Ranges: bytes\r\nCache-Control: no-store\r\n",
|
||||||
name, strlen(ext) == 0 ? "" : ".", ext);
|
name, strlen(ext) == 0 ? "" : ".", ext);
|
||||||
|
|
||||||
mg_http_serve_file(nc, hm, full_path, mime, disposition);
|
char mime_mapping[1024];
|
||||||
|
snprintf(mime_mapping, sizeof(mime_mapping), "%s=%s", ext, mime);
|
||||||
|
|
||||||
|
struct mg_http_serve_opts opts = {
|
||||||
|
.extra_headers = disposition,
|
||||||
|
.mime_types = mime_mapping
|
||||||
|
};
|
||||||
|
mg_http_serve_file(nc, hm, full_path, &opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cache_es_version() {
|
void cache_es_version() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user