1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#[cfg(feature = "proxy")]
pub use hyper_proxy as proxy;
use crate::internal;
use hyper::{
client::{connect::Connect, HttpConnector},
Body, Client,
};
use hyper_tls::HttpsConnector;
#[cfg(feature = "proxy")]
use proxy::ProxyConnector;
pub type Https = HttpsConnector<HttpConnector>;
#[cfg(feature = "proxy")]
pub type Proxy = ProxyConnector<Https>;
pub fn https() -> Https {
HttpsConnector::new(num_cpus::get()).unwrap()
}
#[cfg(feature = "proxy")]
pub fn proxy(proxy: proxy::Proxy) -> Proxy {
ProxyConnector::from_proxy(https(), proxy).unwrap()
}
pub(crate) fn create_client<C>(connector: C) -> internal::Client<C>
where
C: Connect + Sync + 'static,
C::Transport: 'static,
C::Future: 'static,
{
Client::builder().keep_alive(false).build::<C, Body>(connector)
}
pub(crate) fn default() -> internal::Client<Https> {
create_client(https())
}