mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-11 16:40:17 +00:00
Fix MG DAV
PUBLISHED_FROM=132db6ed9c9e1eb9ec19b4f9299448b901b92231
This commit is contained in:
1 parent
31323b01bc
commit
518a7f8a71
3 files changed
+16
-2
No files matched your search
@@ -1,6 +1,6 @@
|
|||||||
PROG = simplest_web_server
|
PROG = simplest_web_server
|
||||||
SOURCES = $(PROG).c ../../mongoose.c
|
SOURCES = $(PROG).c ../../mongoose.c
|
||||||
CFLAGS = -W -Wall -I../.. $(CFLAGS_EXTRA)
|
CFLAGS = -W -Wall -I../.. $(CFLAGS_EXTRA) -DMG_DISABLE_DAV_AUTH
|
||||||
|
|
||||||
all: $(PROG)
|
all: $(PROG)
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ int main(void) {
|
|||||||
// Set up HTTP server parameters
|
// Set up HTTP server parameters
|
||||||
mg_set_protocol_http_websocket(nc);
|
mg_set_protocol_http_websocket(nc);
|
||||||
s_http_server_opts.document_root = "."; // Serve current directory
|
s_http_server_opts.document_root = "."; // Serve current directory
|
||||||
|
s_http_server_opts.dav_document_root = "."; // Allow access via WebDav
|
||||||
s_http_server_opts.enable_directory_listing = "yes";
|
s_http_server_opts.enable_directory_listing = "yes";
|
||||||
|
|
||||||
printf("Starting web server on port %s\n", s_http_port);
|
printf("Starting web server on port %s\n", s_http_port);
|
||||||
|
|||||||
+14
-1
@@ -5196,7 +5196,7 @@ static int is_authorized(struct http_message *hm, const char *path,
|
|||||||
#ifndef MG_DISABLE_DIRECTORY_LISTING
|
#ifndef MG_DISABLE_DIRECTORY_LISTING
|
||||||
static size_t mg_url_encode(const char *src, size_t s_len, char *dst,
|
static size_t mg_url_encode(const char *src, size_t s_len, char *dst,
|
||||||
size_t dst_len) {
|
size_t dst_len) {
|
||||||
static const char *dont_escape = "._-$,;~()";
|
static const char *dont_escape = "._-$,;~()/";
|
||||||
static const char *hex = "0123456789abcdef";
|
static const char *hex = "0123456789abcdef";
|
||||||
size_t i = 0, j = 0;
|
size_t i = 0, j = 0;
|
||||||
|
|
||||||
@@ -6133,6 +6133,17 @@ static void mg_send_digest_auth_request(struct mg_connection *c,
|
|||||||
domain, (unsigned long) time(NULL));
|
domain, (unsigned long) time(NULL));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void send_options(struct mg_connection *nc) {
|
||||||
|
mg_printf(nc, "%s",
|
||||||
|
"HTTP/1.1 200 OK\r\nAllow: GET, POST, HEAD, CONNECT, PUT, "
|
||||||
|
"DELETE, OPTIONS, MKCOL,"
|
||||||
|
#ifndef MG_DISABLE_DAV
|
||||||
|
"PROPFIND \r\nDAV: 1"
|
||||||
|
#endif
|
||||||
|
"\r\n\r\n");
|
||||||
|
nc->flags |= MG_F_SEND_AND_CLOSE;
|
||||||
|
}
|
||||||
|
|
||||||
void mg_send_http_file(struct mg_connection *nc, char *path,
|
void mg_send_http_file(struct mg_connection *nc, char *path,
|
||||||
size_t path_buf_len, struct http_message *hm,
|
size_t path_buf_len, struct http_message *hm,
|
||||||
struct mg_serve_http_opts *opts) {
|
struct mg_serve_http_opts *opts) {
|
||||||
@@ -6178,6 +6189,8 @@ void mg_send_http_file(struct mg_connection *nc, char *path,
|
|||||||
} else if (!mg_vcmp(&hm->method, "PUT")) {
|
} else if (!mg_vcmp(&hm->method, "PUT")) {
|
||||||
handle_put(nc, path, hm);
|
handle_put(nc, path, hm);
|
||||||
#endif
|
#endif
|
||||||
|
} else if (!mg_vcmp(&hm->method, "OPTIONS")) {
|
||||||
|
send_options(nc);
|
||||||
} else if (S_ISDIR(st.st_mode) &&
|
} else if (S_ISDIR(st.st_mode) &&
|
||||||
!find_index_file(path, path_buf_len, opts->index_files, &st)) {
|
!find_index_file(path, path_buf_len, opts->index_files, &st)) {
|
||||||
if (strcmp(opts->enable_directory_listing, "yes") == 0) {
|
if (strcmp(opts->enable_directory_listing, "yes") == 0) {
|
||||||
|
|||||||
Reference in new issue
Block a user