diff --git a/actix-http/CHANGES.md b/actix-http/CHANGES.md index 212ce6a15..ae41610c3 100644 --- a/actix-http/CHANGES.md +++ b/actix-http/CHANGES.md @@ -1,5 +1,11 @@ # Changes +## [1.0.xx] - 2019-12-xx + +### Fixed + +* Poll upgrade service's readiness from HTTP service handlers + ## [1.0.0] - 2019-12-13 ### Added diff --git a/actix-http/src/h1/service.rs b/actix-http/src/h1/service.rs index fb5514da3..beb577f9a 100644 --- a/actix-http/src/h1/service.rs +++ b/actix-http/src/h1/service.rs @@ -72,7 +72,7 @@ where Request = (Request, Framed), Response = (), >, - U::Error: fmt::Display, + U::Error: fmt::Display + Into, U::InitError: fmt::Debug, { /// Create simple tcp stream service @@ -115,7 +115,7 @@ mod openssl { Request = (Request, Framed, Codec>), Response = (), >, - U::Error: fmt::Display, + U::Error: fmt::Display + Into, U::InitError: fmt::Debug, { /// Create openssl based service @@ -255,7 +255,7 @@ where X::Error: Into, X::InitError: fmt::Debug, U: ServiceFactory), Response = ()>, - U::Error: fmt::Display, + U::Error: fmt::Display + Into, U::InitError: fmt::Debug, { type Config = (); @@ -412,7 +412,7 @@ where X: Service, X::Error: Into, U: Service), Response = ()>, - U::Error: fmt::Display, + U::Error: fmt::Display + Into, { type Request = (T, Option); type Response = (); @@ -440,6 +440,19 @@ where })? .is_ready() && ready; + + let ready = if let Some(ref mut upg) = self.upgrade { + upg.poll_ready(cx) + .map_err(|e| { + let e = e.into(); + log::error!("Http service readiness error: {:?}", e); + DispatchError::Service(e) + })? + .is_ready() + && ready + } else { + ready + }; if ready { Poll::Ready(Ok(())) diff --git a/actix-http/tests/test_ws.rs b/actix-http/tests/test_ws.rs index 8255b620c..7152fee48 100644 --- a/actix-http/tests/test_ws.rs +++ b/actix-http/tests/test_ws.rs @@ -8,11 +8,10 @@ use actix_http::{body, h1, ws, Error, HttpService, Request, Response}; use actix_http_test::test_server; use actix_service::{fn_factory, Service}; use actix_utils::framed::Dispatcher; -use bitflags::_core::task::{Context, Poll}; use bytes::Bytes; use futures::future; +use futures::task::{Context, Poll}; use futures::{Future, SinkExt, StreamExt}; -use futures_util::future::ok; struct WsService(Arc, Cell)>>); @@ -90,7 +89,7 @@ async fn test_simple() { move || { let ws_service = ws_service.clone(); HttpService::build() - .upgrade(fn_factory(move || ok::<_, ()>(ws_service.clone()))) + .upgrade(fn_factory(move || future::ok::<_, ()>(ws_service.clone()))) .finish(|_| future::ok::<_, ()>(Response::NotFound())) .tcp() }