Skip to content

Commit

Permalink
feat(websocket): Explicitly force the use of ws/wss protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
0x676e67 committed Jan 28, 2025
1 parent 7f57bd5 commit d0aa711
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions src/client/websocket/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,21 +168,17 @@ impl WebSocketRequestBuilder {

// Ensure the scheme is http or https
let url = request.url_mut();
match url.scheme() {
"ws" | "wss" => {
let new_scheme = if url.scheme() == "ws" {
Scheme::HTTP.as_str()
} else {
Scheme::HTTPS.as_str()
};
url.set_scheme(new_scheme)
.map_err(|_| error::url_bad_scheme(url.clone()))?;
}
"http" | "https" => {}
let new_scheme = match url.scheme() {
"ws" => Scheme::HTTP.as_str(),
"wss" => Scheme::HTTPS.as_str(),
_ => {
return Err(error::url_bad_scheme(url.clone()));
}
}
};

// Update the scheme
url.set_scheme(new_scheme)
.map_err(|_| error::url_bad_scheme(url.clone()))?;

// Get the version of the request
// If the version is not set, use the default version
Expand Down

0 comments on commit d0aa711

Please sign in to comment.