diff --git a/Cargo.toml b/Cargo.toml index 0e95c327c..205e178b9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -60,8 +60,8 @@ flate2-rust = ["flate2/rust_backend"] [dependencies] actix = "0.7.0" -#actix-net = { git="https://github.com/actix/actix-net.git" } -actix-net = { path = "../actix-net" } +actix-net = { git="https://github.com/actix/actix-net.git" } +#actix-net = { path = "../actix-net" } base64 = "0.9" bitflags = "1.0" diff --git a/src/client/connector.rs b/src/client/connector.rs index 6e82e3fd8..8d71913fe 100644 --- a/src/client/connector.rs +++ b/src/client/connector.rs @@ -51,7 +51,7 @@ type SslConnector = Arc; feature = "ssl", feature = "tls", feature = "rust-tls", -)))] +),))] type SslConnector = (); use server::IoStream; @@ -290,7 +290,7 @@ impl Default for ClientConnector { feature = "ssl", feature = "tls", feature = "rust-tls", - )))] + ),))] { () } diff --git a/src/server/acceptor.rs b/src/server/acceptor.rs index caad0e2e3..bad8847dc 100644 --- a/src/server/acceptor.rs +++ b/src/server/acceptor.rs @@ -1,5 +1,5 @@ -use std::net; use std::time::Duration; +use std::{fmt, net}; use actix_net::server::ServerMessage; use actix_net::service::{NewService, Service}; @@ -27,6 +27,7 @@ where F: Fn() -> T + Send + Clone + 'static, T::Response: IoStream + Send, T: NewService, + T::InitError: fmt::Debug, { type Io = T::Response; type NewService = T; @@ -84,6 +85,7 @@ pub(crate) struct TcpAcceptor { impl TcpAcceptor where T: NewService>, + T::InitError: fmt::Debug, { pub(crate) fn new(inner: T) -> Self { TcpAcceptor { inner } @@ -93,6 +95,7 @@ where impl NewService for TcpAcceptor where T: NewService>, + T::InitError: fmt::Debug, { type Request = net::TcpStream; type Response = T::Response; @@ -111,6 +114,7 @@ where pub(crate) struct TcpAcceptorResponse where T: NewService, + T::InitError: fmt::Debug, { fut: T::Future, } @@ -118,16 +122,21 @@ where impl Future for TcpAcceptorResponse where T: NewService, + T::InitError: fmt::Debug, { type Item = TcpAcceptorService; type Error = T::InitError; fn poll(&mut self) -> Poll { - match self.fut.poll()? { - Async::NotReady => Ok(Async::NotReady), - Async::Ready(service) => { + match self.fut.poll() { + Ok(Async::NotReady) => Ok(Async::NotReady), + Ok(Async::Ready(service)) => { Ok(Async::Ready(TcpAcceptorService { inner: service })) } + Err(e) => { + error!("Can not create accetor service: {:?}", e); + Err(e) + } } } } diff --git a/src/server/builder.rs b/src/server/builder.rs index 46ab9f467..8c0a0f624 100644 --- a/src/server/builder.rs +++ b/src/server/builder.rs @@ -1,5 +1,5 @@ use std::marker::PhantomData; -use std::net; +use std::{fmt, net}; use actix_net::either::Either; use actix_net::server::{Server, ServiceFactory}; @@ -37,6 +37,7 @@ where F: Fn() -> H + Send + Clone + 'static, H: IntoHttpHandler, A: AcceptorServiceFactory, + ::InitError: fmt::Debug, P: HttpPipelineFactory, { /// Create http service builder @@ -58,6 +59,7 @@ where pub fn acceptor(self, acceptor: A1) -> HttpServiceBuilder where A1: AcceptorServiceFactory, + ::InitError: fmt::Debug, { HttpServiceBuilder { acceptor, @@ -153,6 +155,7 @@ impl ServiceProvider for HttpServiceBuilder where F: Fn() -> H + Send + Clone + 'static, A: AcceptorServiceFactory, + ::InitError: fmt::Debug, P: HttpPipelineFactory, H: IntoHttpHandler, { diff --git a/src/server/http.rs b/src/server/http.rs index 846f7f010..034f903e2 100644 --- a/src/server/http.rs +++ b/src/server/http.rs @@ -1,7 +1,8 @@ -use std::{io, mem, net}; +use std::{fmt, io, mem, net}; use actix::{Addr, System}; use actix_net::server::Server; +use actix_net::service::NewService; use actix_net::ssl; use net2::TcpBuilder; @@ -233,6 +234,7 @@ where pub(crate) fn listen_with(mut self, lst: net::TcpListener, acceptor: A) -> Self where A: AcceptorServiceFactory, + ::InitError: fmt::Debug, { let addr = lst.local_addr().unwrap(); self.sockets.push(Socket { @@ -254,7 +256,7 @@ where /// /// HttpServer does not change any configuration for TcpListener, /// it needs to be configured before passing it to listen() method. - pub fn listen_tls(mut self, lst: net::TcpListener, acceptor: TlsAcceptor) -> Self { + pub fn listen_tls(self, lst: net::TcpListener, acceptor: TlsAcceptor) -> Self { use actix_net::service::NewServiceExt; self.listen_with(lst, move || { @@ -288,7 +290,7 @@ where /// Use listener for accepting incoming tls connection requests /// /// This method sets alpn protocols to "h2" and "http/1.1" - pub fn listen_rustls(mut self, lst: net::TcpListener, config: ServerConfig) -> Self { + pub fn listen_rustls(self, lst: net::TcpListener, config: ServerConfig) -> Self { use super::{RustlsAcceptor, ServerFlags}; use actix_net::service::NewServiceExt; @@ -324,6 +326,7 @@ where where S: net::ToSocketAddrs, A: AcceptorServiceFactory, + ::InitError: fmt::Debug, { let sockets = self.bind2(addr)?;