feat/refactor: add Client::request_with_host, move main code into it
This commit is contained in:
parent
d462cd4fbe
commit
86fb310e71
1 changed files with 12 additions and 1 deletions
|
@ -52,7 +52,18 @@ impl Client {
|
|||
}
|
||||
|
||||
let host = url.host_str().ok_or(InvalidUrl::ConvertError)?;
|
||||
let addr = (host, url.port().unwrap_or(1965))
|
||||
let port = url.port().unwrap_or(1965);
|
||||
|
||||
self.request_with_host(url_str, host, port).await
|
||||
}
|
||||
|
||||
pub async fn request_with_host(
|
||||
self: &Self,
|
||||
url_str: &str,
|
||||
host: &str,
|
||||
port: u16,
|
||||
) -> Result<Response, LibError> {
|
||||
let addr = (host, port)
|
||||
.to_socket_addrs()?
|
||||
.next()
|
||||
.ok_or(InvalidUrl::ConvertError)?;
|
||||
|
|
Loading…
Add table
Reference in a new issue