From 3e2ad83b2cbdf762e8b6041d85ccef87c7b15260 Mon Sep 17 00:00:00 2001 From: cpq Date: Thu, 4 Aug 2022 17:47:48 +0100 Subject: [PATCH] Fix #1647 - add note in the doc that opts->root_dir is ignored by the mg_http_serve_file() --- docs/README.md | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/docs/README.md b/docs/README.md index 2a099e29..764dc795 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1020,7 +1020,11 @@ void mg_http_serve_file(struct mg_connection *c, struct mg_http_message *hm, const char *path, struct mg_http_serve_opts *opts); ``` -Serve static file. Note that the `extra_headers` must end with `\r\n`. +Serve static file. +NOTE: `opts->root_dir` settings +is ignored by this function. +NOTE: `opts->extra_headers` +must end with `\r\n`. Parameters: - `c` - Connection to use @@ -1037,9 +1041,11 @@ Usage example: void fn(struct mg_connection *c, int ev, void *ev_data, void *fn_data) { if (ev == MG_EV_HTTP_MSG) { struct mg_http_message *hm = (struct mg_http_message *) ev_data; - struct mg_http_serve_opts opts = {.mime_types = "png=image/png", - .extra_headers = "AA: bb\r\nCC: dd\r\n"}; - mg_http_serve_file(c, hm, "a.png", &opts); // Send file + struct mg_http_serve_opts opts = { + .mime_types = "png=image/png", + .extra_headers = "AA: bb\r\nCC: dd\r\n" + }; + mg_http_serve_file(c, hm, "a.png", &opts); } } ```