diff --git a/CHANGES.md b/CHANGES.md index ca335c79e..c001707e3 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -3,6 +3,7 @@ ## Unreleased - 2020-xx-xx ### Changed * Bumped `rand` to `0.8` +* Update `rust-tls` to `0.19.0` ### Fixed * added the actual parsing error to `test::read_body_json` [#1812] diff --git a/Cargo.toml b/Cargo.toml index b074f2f72..9666c4b33 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -91,9 +91,9 @@ awc = { version = "2.0.3", default-features = false } bytes = "1" derive_more = "0.99.5" encoding_rs = "0.8" -futures-channel = { version = "0.3.5", default-features = false } -futures-core = { version = "0.3.5", default-features = false } -futures-util = { version = "0.3.5", default-features = false } +futures-channel = { version = "0.3.7", default-features = false } +futures-core = { version = "0.3.7", default-features = false } +futures-util = { version = "0.3.7", default-features = false } fxhash = "0.2.1" log = "0.4" mime = "0.3" @@ -106,7 +106,7 @@ serde_urlencoded = "0.7" time = { version = "0.2.7", default-features = false, features = ["std"] } url = "2.1" open-ssl = { package = "openssl", version = "0.10", optional = true } -rust-tls = { package = "rustls", version = "0.18.0", optional = true } +rust-tls = { package = "rustls", version = "0.19.0", optional = true } tinyvec = { version = "1", features = ["alloc"] } [dev-dependencies] @@ -138,10 +138,14 @@ actix = { git = "https://github.com/fakeshadow/actix.git", branch = "tokio-0.3" actix-rt = { git = "https://github.com/fakeshadow/actix-net.git", branch = "mio-0.7.3" } actix-server = { git = "https://github.com/fakeshadow/actix-net.git", branch = "mio-0.7.3" } actix-tls = { git = "https://github.com/fakeshadow/actix-net.git", branch = "mio-0.7.3" } -actix-connect = { git = "https://github.com/fakeshadow/actix-net.git", branch = "mio-0.7.3" } +#actix-connect = { git = "https://github.com/fakeshadow/actix-net.git", branch = "mio-0.7.3" } +actix-connect = { path = "../actix-net-fs/actix-connect" } actix-utils = { git = "https://github.com/fakeshadow/actix-net.git", branch = "mio-0.7.3" } actix-codec = { git = "https://github.com/fakeshadow/actix-net.git", branch = "mio-0.7.3" } + http = { git = "https://github.com/fakeshadow/http.git" } +trust-dns-proto = { git = "https://github.com/messense/trust-dns.git", branch = "tokio-1" } +trust-dns-resolver = { git = "https://github.com/messense/trust-dns.git", branch = "tokio-1" } [[bench]] name = "server" diff --git a/actix-http-test/Cargo.toml b/actix-http-test/Cargo.toml index 0655aabb8..4b1bd7d9f 100644 --- a/actix-http-test/Cargo.toml +++ b/actix-http-test/Cargo.toml @@ -40,7 +40,7 @@ awc = "2.0.0" base64 = "0.13" bytes = "1" -futures-core = { version = "0.3.5", default-features = false } +futures-core = { version = "0.3.7", default-features = false } http = "0.2.2" log = "0.4" socket2 = "0.3" diff --git a/actix-http/src/client/error.rs b/actix-http/src/client/error.rs index 23219ceb6..0af1555ae 100644 --- a/actix-http/src/client/error.rs +++ b/actix-http/src/client/error.rs @@ -25,7 +25,6 @@ pub enum ConnectError { // #[cfg(feature = "openssl")] // #[display(fmt = "{}", _0)] // SslHandshakeError(SslError), - /// Failed to resolve the hostname #[display(fmt = "Failed resolving hostname: {}", _0)] Resolver(ResolveError), diff --git a/actix-http/src/h1/dispatcher.rs b/actix-http/src/h1/dispatcher.rs index 8683d1500..92e77620c 100644 --- a/actix-http/src/h1/dispatcher.rs +++ b/actix-http/src/h1/dispatcher.rs @@ -108,7 +108,6 @@ where messages: VecDeque, ka_expire: Instant, - #[pin] ka_timer: Option, diff --git a/actix-http/src/h1/mod.rs b/actix-http/src/h1/mod.rs index 0c85f076a..3d5dea5d6 100644 --- a/actix-http/src/h1/mod.rs +++ b/actix-http/src/h1/mod.rs @@ -17,7 +17,7 @@ pub use self::codec::Codec; pub use self::dispatcher::Dispatcher; pub use self::expect::ExpectHandler; pub use self::payload::Payload; -pub use self::service::{H1Service, H1ServiceHandler, OneRequest}; +pub use self::service::{H1Service, H1ServiceHandler}; pub use self::upgrade::UpgradeHandler; pub use self::utils::SendResponse; diff --git a/actix-http/src/h1/service.rs b/actix-http/src/h1/service.rs index 6cd014174..26ff5292f 100644 --- a/actix-http/src/h1/service.rs +++ b/actix-http/src/h1/service.rs @@ -9,12 +9,12 @@ use actix_codec::{AsyncRead, AsyncWrite, Framed}; use actix_rt::net::TcpStream; use actix_service::{pipeline_factory, IntoServiceFactory, Service, ServiceFactory}; use futures_core::ready; -use futures_util::future::{ok, Ready}; +use futures_util::future::ready; use crate::body::MessageBody; use crate::cloneable::CloneableService; use crate::config::ServiceConfig; -use crate::error::{DispatchError, Error, ParseError}; +use crate::error::{DispatchError, Error}; use crate::helpers::DataFactory; use crate::request::Request; use crate::response::Response; @@ -22,7 +22,7 @@ use crate::{ConnectCallback, Extensions}; use super::codec::Codec; use super::dispatcher::Dispatcher; -use super::{ExpectHandler, Message, UpgradeHandler}; +use super::{ExpectHandler, UpgradeHandler}; /// `ServiceFactory` implementation for HTTP1 transport pub struct H1Service> { @@ -90,7 +90,7 @@ where > { pipeline_factory(|io: TcpStream| { let peer_addr = io.peer_addr().ok(); - ok((io, peer_addr)) + ready(Ok((io, peer_addr))) }) .and_then(self) } @@ -139,7 +139,7 @@ mod openssl { ) .and_then(|io: SslStream| { let peer_addr = io.get_ref().peer_addr().ok(); - ok((io, peer_addr)) + ready(Ok((io, peer_addr))) }) .and_then(self.map_err(TlsError::Service)) } @@ -189,7 +189,7 @@ mod rustls { ) .and_then(|io: TlsStream| { let peer_addr = io.get_ref().0.peer_addr().ok(); - ok((io, peer_addr)) + ready(Ok((io, peer_addr))) }) .and_then(self.map_err(TlsError::Service)) } @@ -500,103 +500,3 @@ where ) } } - -/// `ServiceFactory` implementation for `OneRequestService` service -#[derive(Default)] -pub struct OneRequest { - config: ServiceConfig, - _t: PhantomData, -} - -impl OneRequest -where - T: AsyncRead + AsyncWrite + Unpin, -{ - /// Create new `H1SimpleService` instance. - pub fn new() -> Self { - OneRequest { - config: ServiceConfig::default(), - _t: PhantomData, - } - } -} - -impl ServiceFactory for OneRequest -where - T: AsyncRead + AsyncWrite + Unpin, -{ - type Config = (); - type Request = T; - type Response = (Request, Framed); - type Error = ParseError; - type InitError = (); - type Service = OneRequestService; - type Future = Ready>; - - fn new_service(&self, _: ()) -> Self::Future { - ok(OneRequestService { - _t: PhantomData, - config: self.config.clone(), - }) - } -} - -/// `Service` implementation for HTTP1 transport. Reads one request and returns -/// request and framed object. -pub struct OneRequestService { - _t: PhantomData, - config: ServiceConfig, -} - -impl Service for OneRequestService -where - T: AsyncRead + AsyncWrite + Unpin, -{ - type Request = T; - type Response = (Request, Framed); - type Error = ParseError; - type Future = OneRequestServiceResponse; - - fn poll_ready(&mut self, _: &mut Context<'_>) -> Poll> { - Poll::Ready(Ok(())) - } - - fn call(&mut self, req: Self::Request) -> Self::Future { - OneRequestServiceResponse { - framed: Some(Framed::new(req, Codec::new(self.config.clone()))), - } - } -} - -#[doc(hidden)] -#[pin_project::pin_project] -pub struct OneRequestServiceResponse -where - T: AsyncRead + AsyncWrite + Unpin, -{ - #[pin] - framed: Option>, -} - -impl Future for OneRequestServiceResponse -where - T: AsyncRead + AsyncWrite + Unpin, -{ - type Output = Result<(Request, Framed), ParseError>; - - fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { - let this = self.as_mut().project(); - - match ready!(this.framed.as_pin_mut().unwrap().next_item(cx)) { - Some(Ok(req)) => match req { - Message::Item(req) => { - let mut this = self.as_mut().project(); - Poll::Ready(Ok((req, this.framed.take().unwrap()))) - } - Message::Chunk(_) => unreachable!("Something is wrong"), - }, - Some(Err(err)) => Poll::Ready(Err(err)), - None => Poll::Ready(Err(ParseError::Incomplete)), - } - } -} diff --git a/actix-multipart/Cargo.toml b/actix-multipart/Cargo.toml index d651d8ee9..2bbf5c6e1 100644 --- a/actix-multipart/Cargo.toml +++ b/actix-multipart/Cargo.toml @@ -23,7 +23,7 @@ actix-utils = "2.0.0" bytes = "1" derive_more = "0.99.2" httparse = "1.3" -futures-util = { version = "0.3.5", default-features = false } +futures-util = { version = "0.3.7", default-features = false } log = "0.4" mime = "0.3" twoway = "0.2" diff --git a/actix-web-actors/Cargo.toml b/actix-web-actors/Cargo.toml index 29ab08eef..33fe45ae3 100644 --- a/actix-web-actors/Cargo.toml +++ b/actix-web-actors/Cargo.toml @@ -21,11 +21,11 @@ actix-web = { version = "3.0.0", default-features = false } actix-http = "2.0.0" actix-codec = "0.3.0" bytes = "1" -futures-channel = { version = "0.3.5", default-features = false } -futures-core = { version = "0.3.5", default-features = false } +futures-channel = { version = "0.3.7", default-features = false } +futures-core = { version = "0.3.7", default-features = false } pin-project = "1.0.0" [dev-dependencies] actix-rt = "1.1.1" env_logger = "0.7" -futures-util = { version = "0.3.5", default-features = false } +futures-util = { version = "0.3.7", default-features = false } diff --git a/actix-web-codegen/Cargo.toml b/actix-web-codegen/Cargo.toml index fd99a8376..5120e29d0 100644 --- a/actix-web-codegen/Cargo.toml +++ b/actix-web-codegen/Cargo.toml @@ -21,6 +21,6 @@ proc-macro2 = "1" [dev-dependencies] actix-rt = "1.1.1" actix-web = "3.0.0" -futures-util = { version = "0.3.5", default-features = false } +futures-util = { version = "0.3.7", default-features = false } trybuild = "1" rustversion = "1" diff --git a/awc/CHANGES.md b/awc/CHANGES.md index 0b348d845..713b0d418 100644 --- a/awc/CHANGES.md +++ b/awc/CHANGES.md @@ -4,6 +4,7 @@ ### Changed * Upgrade `bytes` to `1`. * Bumped `rand` to `0.8` +* Update `rust-tls` to `0.19.0` ## 2.0.3 - 2020-11-29 diff --git a/awc/Cargo.toml b/awc/Cargo.toml index c8cf553f1..7e21a2318 100644 --- a/awc/Cargo.toml +++ b/awc/Cargo.toml @@ -46,7 +46,7 @@ base64 = "0.13" bytes = "1" cfg-if = "1.0" derive_more = "0.99.2" -futures-core = { version = "0.3.5", default-features = false } +futures-core = { version = "0.3.7", default-features = false } log =" 0.4" mime = "0.3" percent-encoding = "2.1" @@ -55,7 +55,7 @@ serde = "1.0" serde_json = "1.0" serde_urlencoded = "0.7" open-ssl = { version = "0.10", package = "openssl", optional = true } -rust-tls = { version = "0.18.0", package = "rustls", optional = true, features = ["dangerous_configuration"] } +rust-tls = { version = "0.19.0", package = "rustls", optional = true, features = ["dangerous_configuration"] } [dev-dependencies] actix-connect = { version = "2.0.0", features = ["openssl"] } @@ -67,6 +67,6 @@ actix-server = "1.0.0" actix-tls = { version = "2.0.0", features = ["openssl", "rustls"] } brotli2 = "0.3.2" flate2 = "1.0.13" -futures-util = { version = "0.3.5", default-features = false } +futures-util = { version = "0.3.7", default-features = false } env_logger = "0.7" webpki = "0.21" diff --git a/src/handler.rs b/src/handler.rs index 3d0a2382e..26ec95f8d 100644 --- a/src/handler.rs +++ b/src/handler.rs @@ -15,19 +15,19 @@ use crate::responder::Responder; use crate::service::{ServiceRequest, ServiceResponse}; /// Async handler converter factory -pub trait Factory: Clone + 'static +pub trait Handler: Clone + 'static where - R: Future, - O: Responder, + R: Future, + R::Output: Responder, { fn call(&self, param: T) -> R; } -impl Factory<(), R, O> for F +impl Handler<(), R> for F where F: Fn() -> R + Clone + 'static, - R: Future, - O: Responder, + R: Future, + R::Output: Responder, { fn call(&self, _: ()) -> R { (self)() @@ -36,53 +36,53 @@ where #[doc(hidden)] /// Extract arguments from request, run factory function and make response. -pub struct Handler +pub struct HandlerService where - F: Factory, + F: Handler, T: FromRequest, - R: Future, - O: Responder, + R: Future, + R::Output: Responder, { hnd: F, - _t: PhantomData<(T, R, O)>, + _t: PhantomData<(T, R)>, } -impl Handler +impl HandlerService where - F: Factory, + F: Handler, T: FromRequest, - R: Future, - O: Responder, + R: Future, + R::Output: Responder, { pub fn new(hnd: F) -> Self { - Handler { + HandlerService { hnd, _t: PhantomData, } } } -impl Clone for Handler +impl Clone for HandlerService where - F: Factory, + F: Handler, T: FromRequest, - R: Future, - O: Responder, + R: Future, + R::Output: Responder, { fn clone(&self) -> Self { - Handler { + HandlerService { hnd: self.hnd.clone(), _t: PhantomData, } } } -impl ServiceFactory for Handler +impl ServiceFactory for HandlerService where - F: Factory, + F: Handler, T: FromRequest, - R: Future, - O: Responder, + R: Future, + R::Output: Responder, { type Request = ServiceRequest; type Response = ServiceResponse; @@ -98,17 +98,17 @@ where } // Handler is both it's ServiceFactory and Service Type. -impl Service for Handler +impl Service for HandlerService where - F: Factory, + F: Handler, T: FromRequest, - R: Future, - O: Responder, + R: Future, + R::Output: Responder, { type Request = ServiceRequest; type Response = ServiceResponse; type Error = Error; - type Future = HandlerServiceFuture; + type Future = HandlerServiceFuture; fn poll_ready(&mut self, _: &mut Context<'_>) -> Poll> { Poll::Ready(Ok(())) @@ -123,24 +123,24 @@ where #[doc(hidden)] #[pin_project(project = HandlerProj)] -pub enum HandlerServiceFuture +pub enum HandlerServiceFuture where - F: Factory, + F: Handler, T: FromRequest, - R: Future, - O: Responder, + R: Future, + R::Output: Responder, { Extract(#[pin] T::Future, Option, F), Handle(#[pin] R, Option), - Respond(#[pin] O::Future, Option), + Respond(#[pin] ::Future, Option), } -impl Future for HandlerServiceFuture +impl Future for HandlerServiceFuture where - F: Factory, + F: Handler, T: FromRequest, - R: Future, - O: Responder, + R: Future, + R::Output: Responder, { // Error type in this future is a placeholder type. // all instances of error must be converted to ServiceResponse and return in Ok. @@ -181,10 +181,10 @@ where /// FromRequest trait impl for tuples macro_rules! factory_tuple ({ $(($n:tt, $T:ident)),+} => { - impl Factory<($($T,)+), Res, O> for Func + impl Handler<($($T,)+), Res> for Func where Func: Fn($($T,)+) -> Res + Clone + 'static, - Res: Future, - O: Responder, + Res: Future, + Res::Output: Responder, { fn call(&self, param: ($($T,)+)) -> Res { (self)($(param.$n,)+) diff --git a/src/lib.rs b/src/lib.rs index b8346d966..8246c8286 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -121,7 +121,7 @@ pub mod dev { pub use crate::config::{AppConfig, AppService}; #[doc(hidden)] - pub use crate::handler::Factory; + pub use crate::handler::Handler; pub use crate::info::ConnectionInfo; pub use crate::rmap::ResourceMap; pub use crate::service::{ diff --git a/src/resource.rs b/src/resource.rs index 501e40174..24313e857 100644 --- a/src/resource.rs +++ b/src/resource.rs @@ -17,7 +17,7 @@ use crate::data::Data; use crate::dev::{insert_slash, AppService, HttpServiceFactory, ResourceDef}; use crate::extract::FromRequest; use crate::guard::Guard; -use crate::handler::Factory; +use crate::handler::Handler; use crate::responder::Responder; use crate::route::{CreateRouteService, Route, RouteService}; use crate::service::{ServiceRequest, ServiceResponse}; @@ -227,12 +227,12 @@ where /// # fn index(req: HttpRequest) -> HttpResponse { unimplemented!() } /// App::new().service(web::resource("/").route(web::route().to(index))); /// ``` - pub fn to(mut self, handler: F) -> Self + pub fn to(mut self, handler: F) -> Self where - F: Factory, + F: Handler, I: FromRequest + 'static, - R: Future + 'static, - U: Responder + 'static, + R: Future + 'static, + R::Output: Responder + 'static, { self.routes.push(Route::new().to(handler)); self diff --git a/src/route.rs b/src/route.rs index 025ddc563..544612698 100644 --- a/src/route.rs +++ b/src/route.rs @@ -11,7 +11,7 @@ use futures_util::future::{ready, FutureExt, LocalBoxFuture}; use crate::extract::FromRequest; use crate::guard::{self, Guard}; -use crate::handler::{Factory, Handler}; +use crate::handler::{Handler, HandlerService}; use crate::responder::Responder; use crate::service::{ServiceRequest, ServiceResponse}; use crate::HttpResponse; @@ -51,7 +51,7 @@ impl Route { #[allow(clippy::new_without_default)] pub fn new() -> Route { Route { - service: Box::new(RouteNewService::new(Handler::new(|| { + service: Box::new(RouteNewService::new(HandlerService::new(|| { ready(HttpResponse::NotFound()) }))), guards: Rc::new(Vec::new()), @@ -219,14 +219,14 @@ impl Route { /// ); /// } /// ``` - pub fn to(mut self, handler: F) -> Self + pub fn to(mut self, handler: F) -> Self where - F: Factory, + F: Handler, T: FromRequest + 'static, - R: Future + 'static, - U: Responder + 'static, + R: Future + 'static, + R::Output: Responder + 'static, { - self.service = Box::new(RouteNewService::new(Handler::new(handler))); + self.service = Box::new(RouteNewService::new(HandlerService::new(handler))); self } } diff --git a/src/web.rs b/src/web.rs index bf2158917..85e5f2e7b 100644 --- a/src/web.rs +++ b/src/web.rs @@ -9,7 +9,7 @@ pub use futures_channel::oneshot::Canceled; use crate::error::BlockingError; use crate::extract::FromRequest; -use crate::handler::Factory; +use crate::handler::Handler; use crate::resource::Resource; use crate::responder::Responder; use crate::route::Route; @@ -244,12 +244,12 @@ pub fn method(method: Method) -> Route { /// web::to(index)) /// ); /// ``` -pub fn to(handler: F) -> Route +pub fn to(handler: F) -> Route where - F: Factory, + F: Handler, I: FromRequest + 'static, - R: Future + 'static, - U: Responder + 'static, + R: Future + 'static, + R::Output: Responder + 'static, { Route::new().to(handler) }