summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2021-06-28 18:38:51 +0200
committerGitHub <noreply@github.com>2021-06-28 18:38:51 +0200
commit51350a951c2b046f934ad90eeeeff72ce4d39aac (patch)
tree96c8654728a02840eb3e3a97c6c54599f56864af
parent492d741a3eccf2ebe5d20f16fc0c98c1917b550c (diff)
parentd244dda5970c2aa87bbe3f5468badae5c42b503d (diff)
Merge pull request #49965 from Faless/net/4.x_fix_request
[Net] Fix WebSocketClient path parsing.
-rw-r--r--modules/websocket/websocket_client.cpp9
-rw-r--r--modules/websocket/wsl_client.cpp1
2 files changed, 7 insertions, 3 deletions
diff --git a/modules/websocket/websocket_client.cpp b/modules/websocket/websocket_client.cpp
index 27f0f9af6b..af1dc8ff54 100644
--- a/modules/websocket/websocket_client.cpp
+++ b/modules/websocket/websocket_client.cpp
@@ -42,9 +42,9 @@ Error WebSocketClient::connect_to_url(String p_url, const Vector<String> 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);
@@ -55,6 +55,9 @@ Error WebSocketClient::connect_to_url(String p_url, const Vector<String> p_proto
if (port == 0) {
port = ssl ? 443 : 80;
}
+ if (path.is_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 af1bdb532c..74017fedd7 100644
--- a/modules/websocket/wsl_client.cpp
+++ b/modules/websocket/wsl_client.cpp
@@ -158,6 +158,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<String> p_protocols, const Vector<String> p_custom_headers) {
ERR_FAIL_COND_V(_connection.is_valid(), ERR_ALREADY_IN_USE);
+ ERR_FAIL_COND_V(p_path.is_empty(), ERR_INVALID_PARAMETER);
_peer = Ref<WSLPeer>(memnew(WSLPeer));
IPAddress addr;