diff --git a/modules/websocket/websocket_client.cpp b/modules/websocket/websocket_client.cpp index b416e69b21..5376aeb462 100644 --- a/modules/websocket/websocket_client.cpp +++ b/modules/websocket/websocket_client.cpp @@ -44,9 +44,9 @@ Error WebSocketClient::connect_to_url(String p_url, const Vector p_proto _is_multiplayer = gd_mp_api; String host = p_url; - String path = "/"; - String scheme = ""; - int port = 80; + String path; + String scheme; + int port = 0; Error err = p_url.parse_url(scheme, host, port, path); ERR_FAIL_COND_V_MSG(err != OK, err, "Invalid URL: " + p_url); @@ -57,6 +57,9 @@ Error WebSocketClient::connect_to_url(String p_url, const Vector p_proto if (port == 0) { port = ssl ? 443 : 80; } + if (path.empty()) { + path = "/"; + } return connect_to_host(host, path, port, ssl, p_protocols, p_custom_headers); } diff --git a/modules/websocket/wsl_client.cpp b/modules/websocket/wsl_client.cpp index 599e741072..9fcf04d843 100644 --- a/modules/websocket/wsl_client.cpp +++ b/modules/websocket/wsl_client.cpp @@ -156,6 +156,7 @@ bool WSLClient::_verify_headers(String &r_protocol) { Error WSLClient::connect_to_host(String p_host, String p_path, uint16_t p_port, bool p_ssl, const Vector p_protocols, const Vector p_custom_headers) { ERR_FAIL_COND_V(_connection.is_valid(), ERR_ALREADY_IN_USE); + ERR_FAIL_COND_V(p_path.empty(), ERR_INVALID_PARAMETER); _peer = Ref(memnew(WSLPeer)); IP_Address addr;