From da49b98d15947d01f2530d8142b45a9ef5b97373 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Gr=C3=BCnbichler?= Date: Thu, 4 Aug 2022 10:03:36 +0200 Subject: [PATCH] http: rename SimpleHttp to Client MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit so we have proxmox_http::client::Client for the async, hyper-based client and proxmox_http::client::sync::Client for the sync, ureq-based one. this is a breaking change. Signed-off-by: Fabian Grünbichler --- proxmox-http/src/client/mod.rs | 4 ++-- proxmox-http/src/client/simple.rs | 17 +++++++++-------- proxmox-http/src/proxy_config.rs | 2 +- proxmox-metrics/src/influxdb/http.rs | 8 ++++---- 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/proxmox-http/src/client/mod.rs b/proxmox-http/src/client/mod.rs index 5bbd4d35..86d94dcd 100644 --- a/proxmox-http/src/client/mod.rs +++ b/proxmox-http/src/client/mod.rs @@ -1,7 +1,7 @@ //! Simple TLS capable HTTP client implementations. //! //! Feature `client` contains a lightweight wrapper around `hyper` with support for TLS connections -//! in [`SimpleHttp`](crate::client::SimpleHttp). +//! in [`Client`](crate::client::Client). //! //! Feature `client-sync` contains a lightweight wrapper around `ureq` in //! [`sync::Client`](crate::client::sync::Client). @@ -26,7 +26,7 @@ pub use connector::HttpsConnector; #[cfg(feature = "client")] mod simple; #[cfg(feature = "client")] -pub use simple::SimpleHttp; +pub use simple::Client; #[cfg(feature = "client")] pub mod tls; diff --git a/proxmox-http/src/client/simple.rs b/proxmox-http/src/client/simple.rs index 4a2876c4..bfb1ee7a 100644 --- a/proxmox-http/src/client/simple.rs +++ b/proxmox-http/src/client/simple.rs @@ -8,7 +8,8 @@ use futures::*; #[cfg(all(feature = "client-trait", feature = "proxmox-async"))] use http::header::HeaderName; use http::{HeaderValue, Request, Response}; -use hyper::client::{Client, HttpConnector}; +use hyper::client::Client as HyperClient; +use hyper::client::HttpConnector; use hyper::Body; use openssl::ssl::{SslConnector, SslMethod}; @@ -16,12 +17,12 @@ use crate::client::HttpsConnector; use crate::HttpOptions; /// Asyncrounous HTTP client implementation -pub struct SimpleHttp { - client: Client, +pub struct Client { + client: HyperClient, options: HttpOptions, } -impl SimpleHttp { +impl Client { pub const DEFAULT_USER_AGENT_STRING: &'static str = "proxmox-simple-http-client/0.1"; pub fn new() -> Self { @@ -43,7 +44,7 @@ impl SimpleHttp { if let Some(ref proxy_config) = options.proxy_config { https.set_proxy(proxy_config.clone()); } - let client = Client::builder().build(https); + let client = HyperClient::builder().build(https); Self { client, options } } @@ -151,14 +152,14 @@ impl SimpleHttp { } } -impl Default for SimpleHttp { +impl Default for Client { fn default() -> Self { Self::new() } } #[cfg(all(feature = "client-trait", feature = "proxmox-async"))] -impl crate::HttpClient for SimpleHttp { +impl crate::HttpClient for Client { fn get( &self, uri: &str, @@ -194,7 +195,7 @@ impl crate::HttpClient for SimpleHttp { } #[cfg(all(feature = "client-trait", feature = "proxmox-async"))] -impl crate::HttpClient for SimpleHttp { +impl crate::HttpClient for Client { fn get( &self, uri: &str, diff --git a/proxmox-http/src/proxy_config.rs b/proxmox-http/src/proxy_config.rs index f874ce13..0861d8f7 100644 --- a/proxmox-http/src/proxy_config.rs +++ b/proxmox-http/src/proxy_config.rs @@ -1,6 +1,6 @@ //! HTTP proxy configuration. //! -//! This can be used with the async [`SimpleHttp`](crate::client::SimpleHttp) or sync [`Client`](crate::client::sync::Client). +//! This can be used with the async [`Client`](crate::client::Client) or sync [`Client`](crate::client::sync::Client). use anyhow::{bail, format_err, Error}; diff --git a/proxmox-metrics/src/influxdb/http.rs b/proxmox-metrics/src/influxdb/http.rs index 352b5f65..d734cdd2 100644 --- a/proxmox-metrics/src/influxdb/http.rs +++ b/proxmox-metrics/src/influxdb/http.rs @@ -6,13 +6,13 @@ use openssl::ssl::{SslConnector, SslMethod, SslVerifyMode}; use proxmox_http::HttpOptions; use tokio::sync::mpsc; -use proxmox_http::client::SimpleHttp; +use proxmox_http::client::Client; use crate::influxdb::utils; use crate::{Metrics, MetricsData}; struct InfluxDbHttp { - client: SimpleHttp, + client: Client, healthuri: http::Uri, writeuri: http::Uri, token: Option, @@ -77,11 +77,11 @@ impl InfluxDbHttp { channel: mpsc::Receiver>, ) -> Result { let client = if verify_tls { - SimpleHttp::with_options(HttpOptions::default()) + Client::with_options(HttpOptions::default()) } else { let mut ssl_connector = SslConnector::builder(SslMethod::tls()).unwrap(); ssl_connector.set_verify(SslVerifyMode::NONE); - SimpleHttp::with_ssl_connector(ssl_connector.build(), HttpOptions::default()) + Client::with_ssl_connector(ssl_connector.build(), HttpOptions::default()) }; let uri: http::uri::Uri = uri.parse()?;