From dcd4e660a3f005b18fce459b46193333dfd2638c Mon Sep 17 00:00:00 2001 From: Sergey Lyubka <sergey.lyubka@cesanta.com> Date: Wed, 21 Oct 2015 12:15:00 +0300 Subject: [PATCH] Serve current dir by default in mg_serve_http() PUBLISHED_FROM=421b4256629b2bccd20ceb127ece02be57085b40 --- mongoose.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/mongoose.c b/mongoose.c index b6cfb0f42..1bada6c92 100644 --- a/mongoose.c +++ b/mongoose.c @@ -5772,7 +5772,10 @@ void mg_serve_http(struct mg_connection *nc, struct http_message *hm, struct mg_serve_http_opts opts) { char path[MG_MAX_PATH]; struct mg_str *hdr; - uri_to_path(hm, path, sizeof(path), &opts); + + if (opts.document_root == NULL) { + opts.document_root = "."; + } if (opts.per_directory_auth_file == NULL) { opts.per_directory_auth_file = ".htpasswd"; } @@ -5788,6 +5791,8 @@ void mg_serve_http(struct mg_connection *nc, struct http_message *hm, if (opts.index_files == NULL) { opts.index_files = "index.html,index.htm,index.shtml,index.cgi,index.php"; } + + uri_to_path(hm, path, sizeof(path), &opts); mg_send_http_file(nc, path, sizeof(path), hm, &opts); /* Close connection for non-keep-alive requests */ -- GitLab