Skip to content

Commit

Permalink
Clone static HttpConnector
Browse files Browse the repository at this point in the history
  • Loading branch information
ry committed Sep 25, 2018
1 parent 4667abe commit 2b5270f
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions src/http.rs
Expand Up @@ -10,22 +10,19 @@ use hyper::client::Client;
use hyper::client::HttpConnector;
use hyper::Uri;
use hyper_rustls;
use std::sync::Mutex;

type HttpsConnector = hyper_rustls::HttpsConnector<HttpConnector>;
type Connector = hyper_rustls::HttpsConnector<HttpConnector>;

lazy_static! {
static ref connector_mutex: Mutex<HttpsConnector> = {
let num_dns_threads = 0;
Mutex::new(hyper_rustls::HttpsConnector::new(num_dns_threads))
static ref connector: Connector = {
let num_dns_threads = 4;
};
}

pub fn get_client() -> Client<HttpsConnector, hyper::Body> {
pub fn get_client() -> Client<Connector, hyper::Body> {
// TODO use Hyper's connection pool.
//let connector = connector_mutex.lock().unwrap();
let connector: HttpsConnector = hyper_rustls::HttpsConnector::new(4);
let client = Client::builder().build(connector);
let c = Connector::new(num_dns_threads);
let client = Client::builder().build(c);
return client;
}

Expand Down

0 comments on commit 2b5270f

Please sign in to comment.