From 86fb310e71a6888896d898df4bf0ab0a7ca44f73 Mon Sep 17 00:00:00 2001 From: DarkCat09 Date: Thu, 1 Aug 2024 20:16:28 +0400 Subject: [PATCH] feat/refactor: add Client::request_with_host, move main code into it --- src/client.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/client.rs b/src/client.rs index dec27ed..4f8f11f 100644 --- a/src/client.rs +++ b/src/client.rs @@ -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 { + let addr = (host, port) .to_socket_addrs()? .next() .ok_or(InvalidUrl::ConvertError)?;