diff --git a/Cargo.toml b/Cargo.toml index 64458347..071c2868 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,22 +12,22 @@ version = "0.1.0" [dependencies] futures = "0.1.14" -hyper = "0.11.1" +http = "0.1" +hyper = "0.12" ruma-api = "0.4.0" ruma-client-api = "0.1.0" ruma-identifiers = "0.11.0" serde_json = "1.0.2" serde_urlencoded = "0.5.1" -tokio-core = "0.1.8" url = "1.5.1" [dependencies.hyper-tls] optional = true -version = "0.1.2" +version = "0.3.0" [dependencies.native-tls] optional = true -version = "0.1.4" +version = "0.2.1" [dev-dependencies] futures-await = { git = 'https://github.com/alexcrichton/futures-await' } diff --git a/src/api.rs b/src/api.rs index 2983a307..2dbeb926 100644 --- a/src/api.rs +++ b/src/api.rs @@ -20,7 +20,7 @@ macro_rules! endpoint { #[$($attr)+] pub mod $inner_mod { use futures::Future; - use hyper::client::Connect; + use hyper::client::connect::Connect; use ruma_client_api::$($outer_mod::)*$inner_mod::Endpoint; $(use super::$super_import;)* pub use ruma_client_api::$($outer_mod::)*$inner_mod::{ @@ -37,7 +37,7 @@ macro_rules! endpoint { request: Request, ) -> impl Future where - C: Connect, + C: Connect + 'static, { client.request::(request) } diff --git a/src/error.rs b/src/error.rs index 91fdccbb..f6ca9384 100644 --- a/src/error.rs +++ b/src/error.rs @@ -1,4 +1,5 @@ -use hyper::error::{Error as HyperError, UriError}; +use http::uri::InvalidUri; +use hyper::error::Error as HyperError; use ruma_api::Error as RumaApiError; use serde_json::Error as SerdeJsonError; use serde_urlencoded::ser::Error as SerdeUrlEncodedSerializeError; @@ -12,7 +13,7 @@ pub enum Error { /// An error at the HTTP layer. Hyper(HyperError), /// An error when parsing a string as a URI. - Uri(UriError), + Uri(InvalidUri), /// An error when parsing a string as a URL. Url(ParseError), /// An error converting between ruma_client_api types and Hyper types. @@ -29,8 +30,8 @@ impl From for Error { } } -impl From for Error { - fn from(error: UriError) -> Error { +impl From for Error { + fn from(error: InvalidUri) -> Error { Error::Uri(error) } } diff --git a/src/lib.rs b/src/lib.rs index a16c6789..338c823e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -5,6 +5,7 @@ #![feature(try_from)] extern crate futures; +extern crate http; extern crate hyper; #[cfg(feature = "tls")] extern crate hyper_tls; @@ -15,7 +16,6 @@ extern crate ruma_client_api; extern crate ruma_identifiers; extern crate serde_json; extern crate serde_urlencoded; -extern crate tokio_core; extern crate url; use std::cell::RefCell; @@ -26,13 +26,13 @@ use std::str::FromStr; use futures::future::{Future, FutureFrom, IntoFuture}; use futures::stream::{self, Stream}; use hyper::{Client as HyperClient, Uri}; -use hyper::client::{Connect, HttpConnector}; +use hyper::client::HttpConnector; +use hyper::client::connect::Connect; #[cfg(feature = "hyper-tls")] use hyper_tls::HttpsConnector; #[cfg(feature = "hyper-tls")] use native_tls::Error as NativeTlsError; use ruma_api::Endpoint; -use tokio_core::reactor::Handle; use url::Url; pub use error::Error; @@ -60,10 +60,10 @@ where impl Client { /// Creates a new client for making HTTP requests to the given homeserver. - pub fn new(handle: &Handle, homeserver_url: Url, session: Option) -> Self { + pub fn new(homeserver_url: Url, session: Option) -> Self { Client(Rc::new(ClientData { homeserver_url: homeserver_url, - hyper: HyperClient::configure().keep_alive(true).build(handle), + hyper: HyperClient::builder().keep_alive(true).build_http(), session: RefCell::new(session), })) } @@ -72,16 +72,15 @@ impl Client { #[cfg(feature = "tls")] impl Client> { /// Creates a new client for making HTTPS requests to the given homeserver. - pub fn https(handle: &Handle, homeserver_url: Url, session: Option) -> Result { - let connector = HttpsConnector::new(4, handle)?; + pub fn https(homeserver_url: Url, session: Option) -> Result { + let connector = HttpsConnector::new(4)?; Ok(Client(Rc::new(ClientData { homeserver_url: homeserver_url, hyper: { - HyperClient::configure() - .connector(connector) + HyperClient::builder() .keep_alive(true) - .build(handle) + .build(connector) }, session: RefCell::new(session), }))) @@ -90,7 +89,7 @@ impl Client> { impl Client where - C: Connect, + C: Connect + 'static, { /// Creates a new client using the given `hyper::Client`. /// @@ -261,7 +260,7 @@ where .map_err(Error::from) }) .and_then(move |(uri, mut hyper_request)| { - hyper_request.set_uri(uri); + *hyper_request.uri_mut() = uri; data2.hyper .request(hyper_request)