-
Notifications
You must be signed in to change notification settings - Fork 0
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
chore: replace url with http::uri::Uri #6
Conversation
src/client.rs
Outdated
match self.config.url.cell.clone() { | ||
Some(uri) if self.config.url.prefix_host_with_basin => { | ||
let host = uri.host().ok_or(ClientError::MissingHost)?; | ||
let authority: Authority = format!("{basin}.{host}").parse()?; |
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.
Let's also append the port (if any)?
let authority: Authority = format!("{basin}.{host}").parse()?; | |
let port = if let Some(port) = uri.port_u16() { | |
format!(":{port}") | |
} else { | |
String::new() | |
}; | |
let authority: Authority = format!("{basin}.{host}{port}").parse()?; |
Or something cleaner than 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.
The reason I used url
before was so we can set_host
without changing other parameters, but I think it's OK for us to ignore the username:password
section of the URI
src/client.rs
Outdated
// TODO: Connection pool? | ||
let endpoint: Endpoint = url.as_str().parse()?; | ||
let endpoint: Endpoint = uri.to_string().parse()?; |
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.
You can uri.into()
IIRC
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.
Looks good. Just a comment, should verify.
src/client.rs
Outdated
Some(uri) if self.config.url.prefix_host_with_basin => { | ||
let host = uri.host().ok_or(ClientError::MissingHost)?; | ||
let port = uri.port_u16().map_or(String::new(), |p| p.to_string()); | ||
let authority: Authority = format!("{basin}.{host}:{port}").parse()?; |
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.
If the port
is an empty string will it parse correctly?
basin.s2.dev:
doesn't seem like a valid authority.
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.
oh i am sorry, i forgot to push again
No description provided.