Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Net] Fix WebSocketClient path parsing. #49965

Merged
merged 1 commit into from
Jun 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions modules/websocket/websocket_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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);
}

Expand Down
1 change: 1 addition & 0 deletions modules/websocket/wsl_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down