From a1fcbb071857f73cd1136e6ce4bcad6b1eb9c109 Mon Sep 17 00:00:00 2001 From: Deomid Ryabkov Date: Wed, 3 Aug 2022 14:39:55 +0100 Subject: [PATCH] Fix WS connections to URLs that don't end in / Same as in mg_connect_http_opt(). --- mongoose.c | 3 ++- src/mg_http_websocket.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/mongoose.c b/mongoose.c index a7724f84..09485384 100644 --- a/mongoose.c +++ b/mongoose.c @@ -10257,7 +10257,7 @@ void mg_send_websocket_handshake3(struct mg_connection *nc, const char *path, } void mg_send_websocket_handshake3v(struct mg_connection *nc, - const struct mg_str path, + const struct mg_str path_in, const struct mg_str host, const struct mg_str protocol, const struct mg_str extra_headers, @@ -10276,6 +10276,7 @@ void mg_send_websocket_handshake3v(struct mg_connection *nc, if (user.len > 0) { mg_basic_auth_header(user, pass, &auth); } + const struct mg_str path = (path_in.len > 0 ? path_in : mg_mk_str("/")); /* * NOTE: the (auth.buf == NULL ? "" : auth.buf) is because cc3200 libc is diff --git a/src/mg_http_websocket.c b/src/mg_http_websocket.c index 1f1a0da9..df50c247 100644 --- a/src/mg_http_websocket.c +++ b/src/mg_http_websocket.c @@ -424,7 +424,7 @@ void mg_send_websocket_handshake3(struct mg_connection *nc, const char *path, } void mg_send_websocket_handshake3v(struct mg_connection *nc, - const struct mg_str path, + const struct mg_str path_in, const struct mg_str host, const struct mg_str protocol, const struct mg_str extra_headers, @@ -443,6 +443,7 @@ void mg_send_websocket_handshake3v(struct mg_connection *nc, if (user.len > 0) { mg_basic_auth_header(user, pass, &auth); } + const struct mg_str path = (path_in.len > 0 ? path_in : mg_mk_str("/")); /* * NOTE: the (auth.buf == NULL ? "" : auth.buf) is because cc3200 libc is