diff --git a/examples/client.rs b/examples/client.rs index be943676bd..cfce85b03b 100644 --- a/examples/client.rs +++ b/examples/client.rs @@ -31,7 +31,7 @@ fn main() { } tokio::run(lazy(move || { - let client = Client::default(); + let client = Client::new(); let mut req = Request::new(Body::empty()); *req.uri_mut() = url; diff --git a/examples/web_api.rs b/examples/web_api.rs index 16aedccc50..607620720a 100644 --- a/examples/web_api.rs +++ b/examples/web_api.rs @@ -6,9 +6,9 @@ extern crate tokio; use futures::{Future, Stream}; use futures::future::lazy; -use tokio::reactor::Handle; use hyper::{Body, Chunk, Client, Method, Request, Response, StatusCode}; +use hyper::client::HttpConnector; use hyper::server::{Http, Service}; #[allow(unused, deprecated)] @@ -19,7 +19,7 @@ static URL: &str = "http://127.0.0.1:1337/web_api"; static INDEX: &[u8] = b"test.html"; static LOWERCASE: &[u8] = b"i am a lower case string"; -struct ResponseExamples(Handle); +struct ResponseExamples(Client); impl Service for ResponseExamples { type Request = Request; @@ -35,13 +35,12 @@ impl Service for ResponseExamples { }, (&Method::GET, "/test.html") => { // Run a web query against the web api below - let client = Client::configure().build(&self.0); let req = Request::builder() .method(Method::POST) .uri(URL) .body(LOWERCASE.into()) .unwrap(); - let web_res_future = client.request(req); + let web_res_future = self.0.request(req); Box::new(web_res_future.map(|web_res| { let body = Body::wrap_stream(web_res.into_body().map(|b| { @@ -79,8 +78,8 @@ fn main() { let addr = "127.0.0.1:1337".parse().unwrap(); tokio::run(lazy(move || { - let handle = Handle::current(); - let serve = Http::new().serve_addr(&addr, move || Ok(ResponseExamples(handle.clone()))).unwrap(); + let client = Client::new(); + let serve = Http::new().serve_addr(&addr, move || Ok(ResponseExamples(client.clone()))).unwrap(); println!("Listening on http://{} with 1 thread.", serve.incoming_ref().local_addr()); serve.map_err(|_| ()).for_each(move |conn| { diff --git a/src/client/connect.rs b/src/client/connect.rs index 0a367086f1..ca261d864b 100644 --- a/src/client/connect.rs +++ b/src/client/connect.rs @@ -135,26 +135,30 @@ impl Connected { */ } -fn connect(addr: &SocketAddr, handle: &Handle) -> io::Result { - let builder = match addr { - &SocketAddr::V4(_) => TcpBuilder::new_v4()?, - &SocketAddr::V6(_) => TcpBuilder::new_v6()?, - }; - - if cfg!(windows) { - // Windows requires a socket be bound before calling connect - let any: SocketAddr = match addr { - &SocketAddr::V4(_) => { - ([0, 0, 0, 0], 0).into() - }, - &SocketAddr::V6(_) => { - ([0, 0, 0, 0, 0, 0, 0, 0], 0).into() - } +fn connect(addr: &SocketAddr, handle: &Option) -> io::Result { + if let Some(ref handle) = *handle { + let builder = match addr { + &SocketAddr::V4(_) => TcpBuilder::new_v4()?, + &SocketAddr::V6(_) => TcpBuilder::new_v6()?, }; - builder.bind(any)?; - } - Ok(TcpStream::connect_std(builder.to_tcp_stream()?, addr, handle)) + if cfg!(windows) { + // Windows requires a socket be bound before calling connect + let any: SocketAddr = match addr { + &SocketAddr::V4(_) => { + ([0, 0, 0, 0], 0).into() + }, + &SocketAddr::V6(_) => { + ([0, 0, 0, 0, 0, 0, 0, 0], 0).into() + } + }; + builder.bind(any)?; + } + + Ok(TcpStream::connect_std(builder.to_tcp_stream()?, addr, handle)) + } else { + Ok(TcpStream::connect(addr)) + } } /// A connector for the `http` scheme. @@ -164,7 +168,7 @@ fn connect(addr: &SocketAddr, handle: &Handle) -> io::Result { pub struct HttpConnector { executor: HttpConnectExecutor, enforce_http: bool, - handle: Handle, + handle: Option, keep_alive_timeout: Option, } @@ -173,7 +177,16 @@ impl HttpConnector { /// /// Takes number of DNS worker threads. #[inline] - pub fn new(threads: usize, handle: &Handle) -> HttpConnector { + pub fn new(threads: usize) -> HttpConnector { + HttpConnector::new_with_handle_opt(threads, None) + } + + /// Construct a new HttpConnector with a specific Tokio handle. + pub fn new_with_handle(threads: usize, handle: Handle) -> HttpConnector { + HttpConnector::new_with_handle_opt(threads, Some(handle)) + } + + fn new_with_handle_opt(threads: usize, handle: Option) -> HttpConnector { let pool = CpuPoolBuilder::new() .name_prefix("hyper-dns") .pool_size(threads) @@ -184,14 +197,13 @@ impl HttpConnector { /// Construct a new HttpConnector. /// /// Takes an executor to run blocking tasks on. - #[inline] - pub fn new_with_executor(executor: E, handle: &Handle) -> HttpConnector + pub fn new_with_executor(executor: E, handle: Option) -> HttpConnector where E: Executor + Send + Sync { HttpConnector { executor: HttpConnectExecutor(Arc::new(executor)), enforce_http: true, - handle: handle.clone(), + handle, keep_alive_timeout: None, } } @@ -257,7 +269,7 @@ impl Connect for HttpConnector { } #[inline] -fn invalid_url(err: InvalidUrl, handle: &Handle) -> HttpConnecting { +fn invalid_url(err: InvalidUrl, handle: &Option) -> HttpConnecting { HttpConnecting { state: State::Error(Some(io::Error::new(io::ErrorKind::InvalidInput, err))), handle: handle.clone(), @@ -292,7 +304,7 @@ impl StdError for InvalidUrl { #[must_use = "futures do nothing unless polled"] pub struct HttpConnecting { state: State, - handle: Handle, + handle: Option, keep_alive_timeout: Option, } @@ -365,7 +377,7 @@ struct ConnectingTcp { impl ConnectingTcp { // not a Future, since passing a &Handle to poll - fn poll(&mut self, handle: &Handle) -> Poll { + fn poll(&mut self, handle: &Option) -> Poll { let mut err = None; loop { if let Some(ref mut current) = self.current { @@ -431,29 +443,26 @@ mod tests { #![allow(deprecated)] use std::io; use futures::Future; - use tokio::runtime::Runtime; use super::{Connect, Destination, HttpConnector}; #[test] fn test_errors_missing_authority() { - let runtime = Runtime::new().unwrap(); let uri = "/foo/bar?baz".parse().unwrap(); let dst = Destination { uri, }; - let connector = HttpConnector::new(1, runtime.handle()); + let connector = HttpConnector::new(1); assert_eq!(connector.connect(dst).wait().unwrap_err().kind(), io::ErrorKind::InvalidInput); } #[test] fn test_errors_enforce_http() { - let runtime = Runtime::new().unwrap(); let uri = "https://example.domain/foo/bar?baz".parse().unwrap(); let dst = Destination { uri, }; - let connector = HttpConnector::new(1, runtime.handle()); + let connector = HttpConnector::new(1); assert_eq!(connector.connect(dst).wait().unwrap_err().kind(), io::ErrorKind::InvalidInput); } @@ -461,12 +470,11 @@ mod tests { #[test] fn test_errors_missing_scheme() { - let runtime = Runtime::new().unwrap(); let uri = "example.domain".parse().unwrap(); let dst = Destination { uri, }; - let connector = HttpConnector::new(1, runtime.handle()); + let connector = HttpConnector::new(1); assert_eq!(connector.connect(dst).wait().unwrap_err().kind(), io::ErrorKind::InvalidInput); } diff --git a/src/client/mod.rs b/src/client/mod.rs index 5f8ef96c1a..73cbbbb720 100644 --- a/src/client/mod.rs +++ b/src/client/mod.rs @@ -2,7 +2,6 @@ use std::fmt; use std::io; -use std::marker::PhantomData; use std::sync::Arc; use std::time::Duration; @@ -12,7 +11,6 @@ use futures::sync::oneshot; use http::{Method, Request, Response, Uri, Version}; use http::header::{Entry, HeaderValue, HOST}; use http::uri::Scheme; -use tokio::reactor::Handle; use tokio_executor::spawn; pub use tokio_service::Service; @@ -21,7 +19,6 @@ use self::pool::Pool; pub use self::connect::{Connect, HttpConnector}; -use self::background::{bg, Background}; use self::connect::Destination; pub mod conn; @@ -45,14 +42,14 @@ pub struct Client { impl Client { /// Create a new Client with the default config. #[inline] - pub fn new(handle: &Handle) -> Client { - Config::default().build(handle) + pub fn new() -> Client { + Builder::default().build_http() } } impl Default for Client { fn default() -> Client { - Client::new(&Handle::current()) + Client::new() } } @@ -61,36 +58,18 @@ impl Client { /// /// # Example /// - /// ```no_run - /// # extern crate hyper; - /// # extern crate tokio; + /// ``` + /// use hyper::Client; /// - /// # fn main() { - /// # let runtime = tokio::runtime::Runtime::new().unwrap(); - /// # let handle = runtime.handle(); - /// let client = hyper::Client::configure() + /// let client = Client::builder() /// .keep_alive(true) - /// .build(&handle); - /// # drop(client); - /// # } + /// .build_http(); + /// # let infer: Client<_, hyper::Body> = client; + /// # drop(infer); /// ``` #[inline] - pub fn configure() -> Config { - Config::default() - } -} - -impl Client { - #[inline] - fn configured(config: Config, exec: Exec) -> Client { - Client { - connector: Arc::new(config.connector), - executor: exec, - h1_writev: config.h1_writev, - pool: Pool::new(config.keep_alive, config.keep_alive_timeout), - retry_canceled_requests: config.retry_canceled_requests, - set_host: config.set_host, - } + pub fn builder() -> Builder { + Builder::default() } } @@ -425,11 +404,11 @@ fn set_relative_uri(uri: &mut Uri, is_proxied: bool) { *uri = path; } -/// Configuration for a Client -pub struct Config { - _body_type: PhantomData, +/// Builder for a Client +#[derive(Clone)] +pub struct Builder { //connect_timeout: Duration, - connector: C, + exec: Exec, keep_alive: bool, keep_alive_timeout: Option, h1_writev: bool, @@ -439,15 +418,10 @@ pub struct Config { set_host: bool, } -/// Phantom type used to signal that `Config` should create a `HttpConnector`. -#[derive(Debug, Clone, Copy)] -pub struct UseDefaultConnector(()); - -impl Default for Config { - fn default() -> Config { - Config { - _body_type: PhantomData::, - connector: UseDefaultConnector(()), +impl Default for Builder { + fn default() -> Self { + Self { + exec: Exec::Default, keep_alive: true, keep_alive_timeout: Some(Duration::from_secs(90)), h1_writev: true, @@ -458,50 +432,12 @@ impl Default for Config { } } -impl Config { - /// Set the body stream to be used by the `Client`. - /// - /// # Example - /// - /// ```rust - /// # use hyper::client::Config; - /// let cfg = Config::default() - /// .body::(); - /// # drop(cfg); - #[inline] - pub fn body(self) -> Config { - Config { - _body_type: PhantomData::, - connector: self.connector, - keep_alive: self.keep_alive, - keep_alive_timeout: self.keep_alive_timeout, - h1_writev: self.h1_writev, - max_idle: self.max_idle, - retry_canceled_requests: self.retry_canceled_requests, - set_host: self.set_host, - } - } - - /// Set the `Connect` type to be used. - #[inline] - pub fn connector(self, val: CC) -> Config { - Config { - _body_type: self._body_type, - connector: val, - keep_alive: self.keep_alive, - keep_alive_timeout: self.keep_alive_timeout, - h1_writev: self.h1_writev, - max_idle: self.max_idle, - retry_canceled_requests: self.retry_canceled_requests, - set_host: self.set_host, - } - } - +impl Builder { /// Enable or disable keep-alive mechanics. /// /// Default is enabled. #[inline] - pub fn keep_alive(mut self, val: bool) -> Config { + pub fn keep_alive(&mut self, val: bool) -> &mut Self { self.keep_alive = val; self } @@ -512,7 +448,7 @@ impl Config { /// /// Default is 90 seconds. #[inline] - pub fn keep_alive_timeout(mut self, val: Option) -> Config { + pub fn keep_alive_timeout(&mut self, val: Option) -> &mut Self { self.keep_alive_timeout = val; self } @@ -526,7 +462,7 @@ impl Config { /// /// Default is `true`. #[inline] - pub fn http1_writev(mut self, val: bool) -> Config { + pub fn http1_writev(&mut self, val: bool) -> &mut Self { self.h1_writev = val; self } @@ -543,7 +479,7 @@ impl Config { /// /// Default is `true`. #[inline] - pub fn retry_canceled_requests(mut self, val: bool) -> Config { + pub fn retry_canceled_requests(&mut self, val: bool) -> &mut Self { self.retry_canceled_requests = val; self } @@ -555,71 +491,56 @@ impl Config { /// /// Default is `true`. #[inline] - pub fn set_host(mut self, val: bool) -> Config { + pub fn set_host(&mut self, val: bool) -> &mut Self { self.set_host = val; self } -} -impl Config -where C: Connect, - C::Transport: 'static, - C::Future: 'static, - B: Payload + Send, - B::Data: Send, -{ - /// Construct the Client with this configuration. - #[inline] - pub fn build(self) -> Client { - Client::configured(self, Exec::Default) - } - - /// Construct a Client with this configuration and an executor. - /// - /// The executor will be used to spawn "background" connection tasks - /// to drive requests and responses. - pub fn executor(self, executor: E) -> Client + /// Provide an executor to execute background `Connection` tasks. + pub fn executor(&mut self, exec: E) -> &mut Self where - E: Executor + Send + Sync + 'static, + E: Executor + Send>> + Send + Sync + 'static, { - Client::configured(self, Exec::new(executor)) + self.exec = Exec::Executor(Arc::new(exec)); + self } -} -impl Config -where - B: Payload + Send, - B::Data: Send, -{ - /// Construct the Client with this configuration. - #[inline] - pub fn build(self, handle: &Handle) -> Client { - let mut connector = HttpConnector::new(4, handle); + /// Builder a client with this configuration and the default `HttpConnector`. + pub fn build_http(&self) -> Client + where + B: Payload + Send, + B::Data: Send, + { + let mut connector = HttpConnector::new(4); if self.keep_alive { connector.set_keepalive(self.keep_alive_timeout); } - self.connector(connector).build() + self.build(connector) } - /// Construct a Client with this configuration and an executor. - /// - /// The executor will be used to spawn "background" connection tasks - /// to drive requests and responses. - pub fn build_with_executor(self, handle: &Handle, executor: E) -> Client + /// Combine the configuration of this builder with a connector to create a `Client`. + pub fn build(&self, connector: C) -> Client where - E: Executor + Send + Sync + 'static, + C: Connect, + C::Transport: 'static, + C::Future: 'static, + B: Payload + Send, + B::Data: Send, { - let mut connector = HttpConnector::new(4, handle); - if self.keep_alive { - connector.set_keepalive(self.keep_alive_timeout); + Client { + connector: Arc::new(connector), + executor: self.exec.clone(), + h1_writev: self.h1_writev, + pool: Pool::new(self.keep_alive, self.keep_alive_timeout), + retry_canceled_requests: self.retry_canceled_requests, + set_host: self.set_host, } - self.connector(connector).executor(executor) } } -impl fmt::Debug for Config { +impl fmt::Debug for Builder { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("Config") + f.debug_struct("Builder") .field("keep_alive", &self.keep_alive) .field("keep_alive_timeout", &self.keep_alive_timeout) .field("http1_writev", &self.h1_writev) @@ -629,29 +550,16 @@ impl fmt::Debug for Config { } } -impl Clone for Config { - fn clone(&self) -> Config { - Config { - connector: self.connector.clone(), - .. *self - } - } -} - // ===== impl Exec ===== #[derive(Clone)] enum Exec { Default, - Executor(Arc + Send + Sync>), + Executor(Arc + Send>> + Send + Sync>), } impl Exec { - pub(crate) fn new + Send + Sync + 'static>(executor: E) -> Exec { - Exec::Executor(Arc::new(executor)) - } - fn execute(&self, fut: F) where F: Future + Send + 'static, @@ -659,7 +567,7 @@ impl Exec { match *self { Exec::Default => spawn(fut), Exec::Executor(ref e) => { - let _ = e.execute(bg(Box::new(fut))) + let _ = e.execute(Box::new(fut)) .map_err(|err| { panic!("executor error: {:?}", err.kind()); }); @@ -668,33 +576,3 @@ impl Exec { } } -// ===== impl Background ===== - -// The types inside this module are not exported out of the crate, -// so they are in essence un-nameable. -mod background { - use futures::{Future, Poll}; - - // This is basically `impl Future`, since the type is un-nameable, - // and only implementeds `Future`. - #[allow(missing_debug_implementations)] - pub struct Background { - inner: Box + Send>, - } - - pub fn bg(fut: Box + Send>) -> Background { - Background { - inner: fut, - } - } - - impl Future for Background { - type Item = (); - type Error = (); - - fn poll(&mut self) -> Poll { - self.inner.poll() - } - } -} - diff --git a/src/client/pool.rs b/src/client/pool.rs index dcdc56f7a8..19679494df 100644 --- a/src/client/pool.rs +++ b/src/client/pool.rs @@ -503,11 +503,12 @@ mod tests { #[test] fn test_pool_timer_removes_expired() { + use std::sync::Arc; let runtime = ::tokio::runtime::Runtime::new().unwrap(); let pool = Pool::new(true, Some(Duration::from_millis(100))); let executor = runtime.executor(); - pool.spawn_expired_interval(&Exec::new(executor)); + pool.spawn_expired_interval(&Exec::Executor(Arc::new(executor))); let key = Arc::new("foo".to_string()); pool.pooled(key.clone(), 41); diff --git a/src/client/tests.rs b/src/client/tests.rs index dd35314706..c29daa4346 100644 --- a/src/client/tests.rs +++ b/src/client/tests.rs @@ -20,9 +20,9 @@ fn retryable_request() { let sock1 = connector.mock("http://mock.local"); let sock2 = connector.mock("http://mock.local"); - let client = Client::configure() - .connector(connector) - .executor(executor.sender().clone()); + let client = Client::builder() + .executor(executor.sender().clone()) + .build::<_, ::Body>(connector); { @@ -66,9 +66,9 @@ fn conn_reset_after_write() { let sock1 = connector.mock("http://mock.local"); - let client = Client::configure() - .connector(connector) - .executor(executor.sender().clone()); + let client = Client::builder() + .executor(executor.sender().clone()) + .build::<_, ::Body>(connector); { let req = Request::builder() diff --git a/tests/client.rs b/tests/client.rs index c8de6dcf4c..f66f39cf71 100644 --- a/tests/client.rs +++ b/tests/client.rs @@ -186,11 +186,15 @@ macro_rules! test { let addr = server.local_addr().expect("local_addr"); let runtime = $runtime; - let mut config = Client::configure(); + let mut config = Client::builder(); if !$set_host { - config = config.set_host(false); + config.set_host(false); } - let client = config.build_with_executor(&runtime.reactor(), runtime.executor()); + let connector = ::hyper::client::HttpConnector::new_with_handle(1, runtime.reactor().clone()); + let client = Client::builder() + .set_host($set_host) + .executor(runtime.executor()) + .build(connector); let body = if let Some(body) = $request_body { let body: &'static str = body; @@ -657,9 +661,9 @@ mod dispatch_impl { let addr = server.local_addr().unwrap(); let runtime = Runtime::new().unwrap(); let (closes_tx, closes) = mpsc::channel(10); - let client = Client::configure() - .connector(DebugConnector::with_http_and_closes(HttpConnector::new(1, &runtime.reactor()), closes_tx)) - .executor(runtime.executor()); + let client = Client::builder() + .executor(runtime.executor()) + .build(DebugConnector::with_http_and_closes(HttpConnector::new_with_handle(1, runtime.reactor().clone()), closes_tx)); let (tx1, rx1) = oneshot::channel(); @@ -716,9 +720,9 @@ mod dispatch_impl { }); let res = { - let client = Client::configure() - .connector(DebugConnector::with_http_and_closes(HttpConnector::new(1, &handle), closes_tx)) - .executor(runtime.executor()); + let client = Client::builder() + .executor(runtime.executor()) + .build(DebugConnector::with_http_and_closes(HttpConnector::new_with_handle(1, handle.clone()), closes_tx)); let req = Request::builder() .uri(&*format!("http://{}/a", addr)) @@ -769,9 +773,9 @@ mod dispatch_impl { let _ = client_drop_rx.wait(); }); - let client = Client::configure() - .connector(DebugConnector::with_http_and_closes(HttpConnector::new(1, &handle), closes_tx)) - .executor(runtime.executor()); + let client = Client::builder() + .executor(runtime.executor()) + .build(DebugConnector::with_http_and_closes(HttpConnector::new_with_handle(1, handle.clone()), closes_tx)); let req = Request::builder() .uri(&*format!("http://{}/a", addr)) @@ -833,9 +837,9 @@ mod dispatch_impl { }); let res = { - let client = Client::configure() - .connector(DebugConnector::with_http_and_closes(HttpConnector::new(1, &handle), closes_tx)) - .executor(runtime.executor()); + let client = Client::builder() + .executor(runtime.executor()) + .build(DebugConnector::with_http_and_closes(HttpConnector::new_with_handle(1, handle.clone()), closes_tx)); let req = Request::builder() .uri(&*format!("http://{}/a", addr)) @@ -885,9 +889,9 @@ mod dispatch_impl { }); let res = { - let client = Client::configure() - .connector(DebugConnector::with_http_and_closes(HttpConnector::new(1, &handle), closes_tx)) - .executor(runtime.executor()); + let client = Client::builder() + .executor(runtime.executor()) + .build(DebugConnector::with_http_and_closes(HttpConnector::new_with_handle(1, handle.clone()), closes_tx)); let req = Request::builder() .uri(&*format!("http://{}/a", addr)) @@ -935,10 +939,10 @@ mod dispatch_impl { let _ = rx2.wait(); }); - let client = Client::configure() - .connector(DebugConnector::with_http_and_closes(HttpConnector::new(1, &handle), closes_tx)) + let client = Client::builder() .keep_alive(false) - .executor(runtime.executor()); + .executor(runtime.executor()) + .build(DebugConnector::with_http_and_closes(HttpConnector::new_with_handle(1, handle.clone()), closes_tx)); let req = Request::builder() .uri(&*format!("http://{}/a", addr)) @@ -984,9 +988,9 @@ mod dispatch_impl { let _ = tx1.send(()); }); - let client = Client::configure() - .connector(DebugConnector::with_http_and_closes(HttpConnector::new(1, &handle), closes_tx)) - .executor(runtime.executor()); + let client = Client::builder() + .executor(runtime.executor()) + .build(DebugConnector::with_http_and_closes(HttpConnector::new_with_handle(1, handle.clone()), closes_tx)); let req = Request::builder() .uri(&*format!("http://{}/a", addr)) @@ -1029,9 +1033,9 @@ mod dispatch_impl { let _ = tx1.send(()); }); - let client = Client::configure() - .connector(DebugConnector::with_http_and_closes(HttpConnector::new(1, &handle), closes_tx)) - .executor(runtime.executor()); + let client = Client::builder() + .executor(runtime.executor()) + .build(DebugConnector::with_http_and_closes(HttpConnector::new_with_handle(1, handle.clone()), closes_tx)); let req = Request::builder() .uri(&*format!("http://{}/a", addr)) @@ -1068,14 +1072,14 @@ mod dispatch_impl { let connector = DebugConnector::new(&handle); let connects = connector.connects.clone(); - let client = Client::configure() - .connector(connector) - .executor(runtime.executor()); + let client = Client::builder() + .executor(runtime.executor()) + .build(connector); assert_eq!(connects.load(Ordering::Relaxed), 0); let req = Request::builder() .uri("http://hyper.local/a") - .body(Default::default()) + .body(Body::empty()) .unwrap(); let _fut = client.request(req); // internal Connect::connect should have been lazy, and not @@ -1093,9 +1097,9 @@ mod dispatch_impl { let connector = DebugConnector::new(&handle); let connects = connector.connects.clone(); - let client = Client::configure() - .connector(connector) - .executor(runtime.executor()); + let client = Client::builder() + .executor(runtime.executor()) + .build(connector); let (tx1, rx1) = oneshot::channel(); let (tx2, rx2) = oneshot::channel(); @@ -1156,9 +1160,9 @@ mod dispatch_impl { let connector = DebugConnector::new(&handle); let connects = connector.connects.clone(); - let client = Client::configure() - .connector(connector) - .executor(runtime.executor()); + let client = Client::builder() + .executor(runtime.executor()) + .build(connector); let (tx1, rx1) = oneshot::channel(); let (tx2, rx2) = oneshot::channel(); @@ -1217,9 +1221,9 @@ mod dispatch_impl { let connector = DebugConnector::new(&handle) .proxy(); - let client = Client::configure() - .connector(connector) - .executor(runtime.executor()); + let client = Client::builder() + .executor(runtime.executor()) + .build(connector); let (tx1, rx1) = oneshot::channel(); thread::spawn(move || { @@ -1256,7 +1260,7 @@ mod dispatch_impl { impl DebugConnector { fn new(handle: &Handle) -> DebugConnector { - let http = HttpConnector::new(1, handle); + let http = HttpConnector::new_with_handle(1, handle.clone()); let (tx, _) = mpsc::channel(10); DebugConnector::with_http_and_closes(http, tx) }