-
Notifications
You must be signed in to change notification settings - Fork 173
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
ws client redirections #397
Conversation
Left a few thoughts! |
…nrpsee into na-ws-client-redirections
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some grumbles
Ah, I figured it out basically |
Relative reference must start with either `/` or `//`
// Relative URI. | ||
else { | ||
// Replace the entire path_and_query if `location` starts with `/` or `//`. | ||
if location.starts_with('/') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
//cc @maciejhirsz is it fair to assume that if the initial request
included a query such as ws://example.com/page?name=hi
then the server will include it in the re-direction location header?
ws-client/Cargo.toml
Outdated
pin-project = "1" | ||
thiserror = "1" | ||
url = "2" | ||
http = "0.2" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Switched to the http crate
instead for URI parsing because it supports both absolute URI
and relative resource URI
Useful when getting the location header back...
However, it doesn't support to get the default port and it's put in an Option<Port>
so you can't really tell whether the port was invalid or no port was provided....
…nrpsee into na-ws-client-redirections
if location.starts_with('/') { | ||
target.path_and_query = location; | ||
} else { | ||
match target.path_and_query.rfind('/') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
//cc @maciejhirsz I had to do this instead of Path::join
because on Windows
the path is joined by \
which is a faulty URI relative resource
.
This will work for both //
and /
FWIW.
if is_upgrade_request(&req) { | ||
log::debug!("{:?}", req); | ||
|
||
match req.uri().path() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh okay the above description makes sense after reading this! 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking pretty clean!
Closes #339