Update of hyper
* hyper::UriError was moved to http::InvalidUri * tokio_core::reactor::Handle is no longer used by the new hyper version; tokio_core can get dropped completely
This commit is contained in:
		
							parent
							
								
									799d8e8d77
								
							
						
					
					
						commit
						66037a9339
					
				| @ -12,22 +12,22 @@ version = "0.1.0" | |||||||
| 
 | 
 | ||||||
| [dependencies] | [dependencies] | ||||||
| futures = "0.1.14" | futures = "0.1.14" | ||||||
| hyper = "0.11.1" | http = "0.1" | ||||||
|  | hyper = "0.12" | ||||||
| ruma-api = "0.4.0" | ruma-api = "0.4.0" | ||||||
| ruma-client-api = "0.1.0" | ruma-client-api = "0.1.0" | ||||||
| ruma-identifiers = "0.11.0" | ruma-identifiers = "0.11.0" | ||||||
| serde_json = "1.0.2" | serde_json = "1.0.2" | ||||||
| serde_urlencoded = "0.5.1" | serde_urlencoded = "0.5.1" | ||||||
| tokio-core = "0.1.8" |  | ||||||
| url = "1.5.1" | url = "1.5.1" | ||||||
| 
 | 
 | ||||||
| [dependencies.hyper-tls] | [dependencies.hyper-tls] | ||||||
| optional = true | optional = true | ||||||
| version = "0.1.2" | version = "0.3.0" | ||||||
| 
 | 
 | ||||||
| [dependencies.native-tls] | [dependencies.native-tls] | ||||||
| optional = true | optional = true | ||||||
| version = "0.1.4" | version = "0.2.1" | ||||||
| 
 | 
 | ||||||
| [dev-dependencies] | [dev-dependencies] | ||||||
| futures-await = { git = 'https://github.com/alexcrichton/futures-await' } | futures-await = { git = 'https://github.com/alexcrichton/futures-await' } | ||||||
|  | |||||||
| @ -20,7 +20,7 @@ macro_rules! endpoint { | |||||||
|         #[$($attr)+] |         #[$($attr)+] | ||||||
|         pub mod $inner_mod { |         pub mod $inner_mod { | ||||||
|             use futures::Future; |             use futures::Future; | ||||||
|             use hyper::client::Connect; |             use hyper::client::connect::Connect; | ||||||
|             use ruma_client_api::$($outer_mod::)*$inner_mod::Endpoint; |             use ruma_client_api::$($outer_mod::)*$inner_mod::Endpoint; | ||||||
|             $(use super::$super_import;)* |             $(use super::$super_import;)* | ||||||
|             pub use ruma_client_api::$($outer_mod::)*$inner_mod::{ |             pub use ruma_client_api::$($outer_mod::)*$inner_mod::{ | ||||||
| @ -37,7 +37,7 @@ macro_rules! endpoint { | |||||||
|                 request: Request, |                 request: Request, | ||||||
|             ) -> impl Future<Item = Response, Error = Error> |             ) -> impl Future<Item = Response, Error = Error> | ||||||
|             where |             where | ||||||
|                 C: Connect, |                 C: Connect + 'static, | ||||||
|             { |             { | ||||||
|                 client.request::<Endpoint>(request) |                 client.request::<Endpoint>(request) | ||||||
|             } |             } | ||||||
|  | |||||||
| @ -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 ruma_api::Error as RumaApiError; | ||||||
| use serde_json::Error as SerdeJsonError; | use serde_json::Error as SerdeJsonError; | ||||||
| use serde_urlencoded::ser::Error as SerdeUrlEncodedSerializeError; | use serde_urlencoded::ser::Error as SerdeUrlEncodedSerializeError; | ||||||
| @ -12,7 +13,7 @@ pub enum Error { | |||||||
|     /// An error at the HTTP layer.
 |     /// An error at the HTTP layer.
 | ||||||
|     Hyper(HyperError), |     Hyper(HyperError), | ||||||
|     /// An error when parsing a string as a URI.
 |     /// An error when parsing a string as a URI.
 | ||||||
|     Uri(UriError), |     Uri(InvalidUri), | ||||||
|     /// An error when parsing a string as a URL.
 |     /// An error when parsing a string as a URL.
 | ||||||
|     Url(ParseError), |     Url(ParseError), | ||||||
|     /// An error converting between ruma_client_api types and Hyper types.
 |     /// An error converting between ruma_client_api types and Hyper types.
 | ||||||
| @ -29,8 +30,8 @@ impl From<HyperError> for Error { | |||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| impl From<UriError> for Error { | impl From<InvalidUri> for Error { | ||||||
|     fn from(error: UriError) -> Error { |     fn from(error: InvalidUri) -> Error { | ||||||
|         Error::Uri(error) |         Error::Uri(error) | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  | |||||||
							
								
								
									
										23
									
								
								src/lib.rs
									
									
									
									
									
								
							
							
						
						
									
										23
									
								
								src/lib.rs
									
									
									
									
									
								
							| @ -5,6 +5,7 @@ | |||||||
| #![feature(try_from)] | #![feature(try_from)] | ||||||
| 
 | 
 | ||||||
| extern crate futures; | extern crate futures; | ||||||
|  | extern crate http; | ||||||
| extern crate hyper; | extern crate hyper; | ||||||
| #[cfg(feature = "tls")] | #[cfg(feature = "tls")] | ||||||
| extern crate hyper_tls; | extern crate hyper_tls; | ||||||
| @ -15,7 +16,6 @@ extern crate ruma_client_api; | |||||||
| extern crate ruma_identifiers; | extern crate ruma_identifiers; | ||||||
| extern crate serde_json; | extern crate serde_json; | ||||||
| extern crate serde_urlencoded; | extern crate serde_urlencoded; | ||||||
| extern crate tokio_core; |  | ||||||
| extern crate url; | extern crate url; | ||||||
| 
 | 
 | ||||||
| use std::cell::RefCell; | use std::cell::RefCell; | ||||||
| @ -26,13 +26,13 @@ use std::str::FromStr; | |||||||
| use futures::future::{Future, FutureFrom, IntoFuture}; | use futures::future::{Future, FutureFrom, IntoFuture}; | ||||||
| use futures::stream::{self, Stream}; | use futures::stream::{self, Stream}; | ||||||
| use hyper::{Client as HyperClient, Uri}; | use hyper::{Client as HyperClient, Uri}; | ||||||
| use hyper::client::{Connect, HttpConnector}; | use hyper::client::HttpConnector; | ||||||
|  | use hyper::client::connect::Connect; | ||||||
| #[cfg(feature = "hyper-tls")] | #[cfg(feature = "hyper-tls")] | ||||||
| use hyper_tls::HttpsConnector; | use hyper_tls::HttpsConnector; | ||||||
| #[cfg(feature = "hyper-tls")] | #[cfg(feature = "hyper-tls")] | ||||||
| use native_tls::Error as NativeTlsError; | use native_tls::Error as NativeTlsError; | ||||||
| use ruma_api::Endpoint; | use ruma_api::Endpoint; | ||||||
| use tokio_core::reactor::Handle; |  | ||||||
| use url::Url; | use url::Url; | ||||||
| 
 | 
 | ||||||
| pub use error::Error; | pub use error::Error; | ||||||
| @ -60,10 +60,10 @@ where | |||||||
| 
 | 
 | ||||||
| impl Client<HttpConnector> { | impl Client<HttpConnector> { | ||||||
|     /// Creates a new client for making HTTP requests to the given homeserver.
 |     /// Creates a new client for making HTTP requests to the given homeserver.
 | ||||||
|     pub fn new(handle: &Handle, homeserver_url: Url, session: Option<Session>) -> Self { |     pub fn new(homeserver_url: Url, session: Option<Session>) -> Self { | ||||||
|         Client(Rc::new(ClientData { |         Client(Rc::new(ClientData { | ||||||
|             homeserver_url: homeserver_url, |             homeserver_url: homeserver_url, | ||||||
|             hyper: HyperClient::configure().keep_alive(true).build(handle), |             hyper: HyperClient::builder().keep_alive(true).build_http(), | ||||||
|             session: RefCell::new(session), |             session: RefCell::new(session), | ||||||
|         })) |         })) | ||||||
|     } |     } | ||||||
| @ -72,16 +72,15 @@ impl Client<HttpConnector> { | |||||||
| #[cfg(feature = "tls")] | #[cfg(feature = "tls")] | ||||||
| impl Client<HttpsConnector<HttpConnector>> { | impl Client<HttpsConnector<HttpConnector>> { | ||||||
|     /// Creates a new client for making HTTPS requests to the given homeserver.
 |     /// Creates a new client for making HTTPS requests to the given homeserver.
 | ||||||
|     pub fn https(handle: &Handle, homeserver_url: Url, session: Option<Session>) -> Result<Self, NativeTlsError> { |     pub fn https(homeserver_url: Url, session: Option<Session>) -> Result<Self, NativeTlsError> { | ||||||
|         let connector = HttpsConnector::new(4, handle)?; |         let connector = HttpsConnector::new(4)?; | ||||||
| 
 | 
 | ||||||
|         Ok(Client(Rc::new(ClientData { |         Ok(Client(Rc::new(ClientData { | ||||||
|             homeserver_url: homeserver_url, |             homeserver_url: homeserver_url, | ||||||
|             hyper: { |             hyper: { | ||||||
|                 HyperClient::configure() |                 HyperClient::builder() | ||||||
|                     .connector(connector) |  | ||||||
|                     .keep_alive(true) |                     .keep_alive(true) | ||||||
|                     .build(handle) |                     .build(connector) | ||||||
|             }, |             }, | ||||||
|             session: RefCell::new(session), |             session: RefCell::new(session), | ||||||
|         }))) |         }))) | ||||||
| @ -90,7 +89,7 @@ impl Client<HttpsConnector<HttpConnector>> { | |||||||
| 
 | 
 | ||||||
| impl<C> Client<C> | impl<C> Client<C> | ||||||
| where | where | ||||||
|     C: Connect, |     C: Connect + 'static, | ||||||
| { | { | ||||||
|     /// Creates a new client using the given `hyper::Client`.
 |     /// Creates a new client using the given `hyper::Client`.
 | ||||||
|     ///
 |     ///
 | ||||||
| @ -261,7 +260,7 @@ where | |||||||
|                     .map_err(Error::from) |                     .map_err(Error::from) | ||||||
|             }) |             }) | ||||||
|             .and_then(move |(uri, mut hyper_request)| { |             .and_then(move |(uri, mut hyper_request)| { | ||||||
|                 hyper_request.set_uri(uri); |                 *hyper_request.uri_mut() = uri; | ||||||
| 
 | 
 | ||||||
|                 data2.hyper |                 data2.hyper | ||||||
|                     .request(hyper_request) |                     .request(hyper_request) | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user