mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-06 15:51:25 +00:00
Fix #1647 - add note in the doc that opts->root_dir is ignored by the mg_http_serve_file()
This commit is contained in:
1 parent
ae29a1734c
commit
3e2ad83b2c
1 file changed
+10
-4
+10
-4
@@ -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);
|
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.
|
||||||
|
<span class="badge bg-danger">NOTE: </span> `opts->root_dir` settings
|
||||||
|
is ignored by this function.
|
||||||
|
<span class="badge bg-danger">NOTE: </span> `opts->extra_headers`
|
||||||
|
must end with `\r\n`.
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
- `c` - Connection to use
|
- `c` - Connection to use
|
||||||
@@ -1037,9 +1041,11 @@ Usage example:
|
|||||||
void fn(struct mg_connection *c, int ev, void *ev_data, void *fn_data) {
|
void fn(struct mg_connection *c, int ev, void *ev_data, void *fn_data) {
|
||||||
if (ev == MG_EV_HTTP_MSG) {
|
if (ev == MG_EV_HTTP_MSG) {
|
||||||
struct mg_http_message *hm = (struct mg_http_message *) ev_data;
|
struct mg_http_message *hm = (struct mg_http_message *) ev_data;
|
||||||
struct mg_http_serve_opts opts = {.mime_types = "png=image/png",
|
struct mg_http_serve_opts opts = {
|
||||||
.extra_headers = "AA: bb\r\nCC: dd\r\n"};
|
.mime_types = "png=image/png",
|
||||||
mg_http_serve_file(c, hm, "a.png", &opts); // Send file
|
.extra_headers = "AA: bb\r\nCC: dd\r\n"
|
||||||
|
};
|
||||||
|
mg_http_serve_file(c, hm, "a.png", &opts);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|||||||
Reference in new issue
Block a user