//! 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).
#[cfg(feature = "client")]
mod simple;
#[cfg(feature = "client")]
-pub use simple::SimpleHttp;
+pub use simple::Client;
#[cfg(feature = "client")]
pub mod tls;
#[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};
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 {
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 }
}
}
}
-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,
}
#[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,
//! 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};
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>,
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()?;