From bc6b38c1b627c6dcdd50896ded4148dd6e0734ba Mon Sep 17 00:00:00 2001 From: littleblack111 Date: Mon, 1 Sep 2025 21:16:52 +0800 Subject: httpconnector: properly parse url --- src/client/connector/connectors/httpconnector.rs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/client/connector/connectors/httpconnector.rs b/src/client/connector/connectors/httpconnector.rs index 2bdb36a..6d501cc 100644 --- a/src/client/connector/connectors/httpconnector.rs +++ b/src/client/connector/connectors/httpconnector.rs @@ -1,24 +1,22 @@ -use std::net::AddrParseError; - use crate::connector::*; -pub(crate) struct HTTPConnector<'a> { +pub(crate) struct HTTPConnector { prev: String, - url: &'a str, + url: reqwest::Url, channel: Channel, } -impl<'a> HTTPConnector<'a> { - pub fn new(url: &'a str) -> Result { +impl HTTPConnector { + pub fn new(url: &str) -> Result { Ok(Self { prev: String::new(), - url, + url: reqwest::Url::parse(url)?, channel: Channel::new(), }) } } -impl Connection for HTTPConnector<'_> { +impl Connection for HTTPConnector { type Err = reqwest::Error; fn test_connection(&self) -> std::result::Result { @@ -26,7 +24,7 @@ impl Connection for HTTPConnector<'_> { } async fn update(&self) -> Option> { - let res = match reqwest::get(self.url).await { + let res = match reqwest::get(self.url.clone()).await { Ok(resp) => match resp.text().await { Ok(text) => text, Err(e) => return Some(Err(e)), -- cgit v1.2.3