]> git.proxmox.com Git - proxmox.git/commitdiff
http: rename SimpleHttp to Client
authorFabian Grünbichler <f.gruenbichler@proxmox.com>
Thu, 4 Aug 2022 08:03:36 +0000 (10:03 +0200)
committerFabian Grünbichler <f.gruenbichler@proxmox.com>
Wed, 7 Sep 2022 07:17:45 +0000 (09:17 +0200)
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 <f.gruenbichler@proxmox.com>
proxmox-http/src/client/mod.rs
proxmox-http/src/client/simple.rs
proxmox-http/src/proxy_config.rs
proxmox-metrics/src/influxdb/http.rs

index 5bbd4d354fe8c6dd88d5361bc368cb3c9c06d05a..86d94dcd82a15c32b0d73af3d1e5373e82725101 100644 (file)
@@ -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;
index 4a2876c4b2c4cab3f15c704e488e50f3a503a194..bfb1ee7a9c3381f5df95747940af01598505e8b2 100644 (file)
@@ -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<HttpsConnector, Body>,
+pub struct Client {
+    client: HyperClient<HttpsConnector, Body>,
     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<Body> for SimpleHttp {
+impl crate::HttpClient<Body> for Client {
     fn get(
         &self,
         uri: &str,
@@ -194,7 +195,7 @@ impl crate::HttpClient<Body> for SimpleHttp {
 }
 
 #[cfg(all(feature = "client-trait", feature = "proxmox-async"))]
-impl crate::HttpClient<String> for SimpleHttp {
+impl crate::HttpClient<String> for Client {
     fn get(
         &self,
         uri: &str,
index f874ce13db9fd874eeafc396a3d16d0c36117df0..0861d8f7e85ae13f630c063cb824f2f307f4c5d5 100644 (file)
@@ -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};
 
index 352b5f6563988e3bc4b84beb6e6e3c7eaec11f74..d734cdd2204a4a194b2ed6e4eb19a24935f5ccd7 100644 (file)
@@ -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<String>,
@@ -77,11 +77,11 @@ impl InfluxDbHttp {
         channel: mpsc::Receiver<Arc<MetricsData>>,
     ) -> Result<Self, Error> {
         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()?;