diff --git a/actix-http/CHANGES.md b/actix-http/CHANGES.md index 587abaf77..212ce6a15 100644 --- a/actix-http/CHANGES.md +++ b/actix-http/CHANGES.md @@ -1,6 +1,6 @@ # Changes -## [1.0.0] - 2019-12-xx +## [1.0.0] - 2019-12-13 ### Added diff --git a/actix-http/Cargo.toml b/actix-http/Cargo.toml index 63e3977a5..c0e7419c2 100644 --- a/actix-http/Cargo.toml +++ b/actix-http/Cargo.toml @@ -56,7 +56,9 @@ chrono = "0.4.6" derive_more = "0.99.2" either = "1.5.3" encoding_rs = "0.8" -futures = "0.3.1" +futures-core = "0.3.1" +futures-util = "0.3.1" +futures-channel = "0.3.1" fxhash = "0.2.1" h2 = "0.2.1" http = "0.2.0" @@ -92,6 +94,7 @@ actix-server = "1.0.0" actix-connect = { version = "1.0.0", features=["openssl"] } actix-http-test = { version = "1.0.0-alpha.3", features=["openssl"] } actix-tls = { version = "1.0.0", features=["openssl"] } +futures = "0.3.1" env_logger = "0.6" serde_derive = "1.0" open-ssl = { version="0.10", package = "openssl" } diff --git a/actix-http/src/body.rs b/actix-http/src/body.rs index ecb12fc23..850f97ee4 100644 --- a/actix-http/src/body.rs +++ b/actix-http/src/body.rs @@ -4,7 +4,7 @@ use std::task::{Context, Poll}; use std::{fmt, mem}; use bytes::{Bytes, BytesMut}; -use futures::Stream; +use futures_core::Stream; use pin_project::{pin_project, project}; use crate::error::Error; @@ -435,7 +435,7 @@ where #[cfg(test)] mod tests { use super::*; - use futures::future::poll_fn; + use futures_util::future::poll_fn; impl Body { pub(crate) fn get_ref(&self) -> &[u8] { diff --git a/actix-http/src/client/connection.rs b/actix-http/src/client/connection.rs index 566769c5e..0ca788b32 100644 --- a/actix-http/src/client/connection.rs +++ b/actix-http/src/client/connection.rs @@ -4,7 +4,7 @@ use std::{fmt, io, mem, time}; use actix_codec::{AsyncRead, AsyncWrite, Framed}; use bytes::{Buf, Bytes}; -use futures::future::{err, Either, Future, FutureExt, LocalBoxFuture, Ready}; +use futures_util::future::{err, Either, Future, FutureExt, LocalBoxFuture, Ready}; use h2::client::SendRequest; use pin_project::{pin_project, project}; diff --git a/actix-http/src/client/connector.rs b/actix-http/src/client/connector.rs index a06afa7b0..055d4276d 100644 --- a/actix-http/src/client/connector.rs +++ b/actix-http/src/client/connector.rs @@ -337,7 +337,7 @@ where mod connect_impl { use std::task::{Context, Poll}; - use futures::future::{err, Either, Ready}; + use futures_util::future::{err, Either, Ready}; use super::*; use crate::client::connection::IoConnection; @@ -400,8 +400,8 @@ mod connect_impl { use std::pin::Pin; use std::task::{Context, Poll}; - use futures::future::Either; - use futures::ready; + use futures_core::ready; + use futures_util::future::Either; use super::*; use crate::client::connection::EitherConnection; diff --git a/actix-http/src/client/h1proto.rs b/actix-http/src/client/h1proto.rs index db4dede71..a0a20edf6 100644 --- a/actix-http/src/client/h1proto.rs +++ b/actix-http/src/client/h1proto.rs @@ -6,8 +6,9 @@ use std::{io, mem, time}; use actix_codec::{AsyncRead, AsyncWrite, Framed}; use bytes::buf::BufMutExt; use bytes::{Bytes, BytesMut}; -use futures::future::poll_fn; -use futures::{SinkExt, Stream, StreamExt}; +use futures_core::Stream; +use futures_util::future::poll_fn; +use futures_util::{SinkExt, StreamExt}; use crate::error::PayloadError; use crate::h1; diff --git a/actix-http/src/client/h2proto.rs b/actix-http/src/client/h2proto.rs index ff8f21d00..eabf54e97 100644 --- a/actix-http/src/client/h2proto.rs +++ b/actix-http/src/client/h2proto.rs @@ -3,7 +3,7 @@ use std::time; use actix_codec::{AsyncRead, AsyncWrite}; use bytes::Bytes; -use futures::future::poll_fn; +use futures_util::future::poll_fn; use h2::{client::SendRequest, SendStream}; use http::header::{HeaderValue, CONNECTION, CONTENT_LENGTH, TRANSFER_ENCODING}; use http::{request::Request, Method, Version}; diff --git a/actix-http/src/client/pool.rs b/actix-http/src/client/pool.rs index 0346c0614..acf76559a 100644 --- a/actix-http/src/client/pool.rs +++ b/actix-http/src/client/pool.rs @@ -11,7 +11,7 @@ use actix_rt::time::{delay_for, Delay}; use actix_service::Service; use actix_utils::{oneshot, task::LocalWaker}; use bytes::Bytes; -use futures::future::{poll_fn, FutureExt, LocalBoxFuture}; +use futures_util::future::{poll_fn, FutureExt, LocalBoxFuture}; use fxhash::FxHashMap; use h2::client::{handshake, Connection, SendRequest}; use http::uri::Authority; diff --git a/actix-http/src/config.rs b/actix-http/src/config.rs index 77633bdc2..be949aaef 100644 --- a/actix-http/src/config.rs +++ b/actix-http/src/config.rs @@ -6,7 +6,7 @@ use std::{fmt, net}; use actix_rt::time::{delay_for, delay_until, Delay, Instant}; use bytes::BytesMut; -use futures::{future, FutureExt}; +use futures_util::{future, FutureExt}; use time; // "Sun, 06 Nov 1994 08:49:37 GMT".len() diff --git a/actix-http/src/encoding/decoder.rs b/actix-http/src/encoding/decoder.rs index 10635b3b3..cdc4699d5 100644 --- a/actix-http/src/encoding/decoder.rs +++ b/actix-http/src/encoding/decoder.rs @@ -7,7 +7,7 @@ use actix_threadpool::{run, CpuFuture}; use brotli::DecompressorWriter; use bytes::Bytes; use flate2::write::{GzDecoder, ZlibDecoder}; -use futures::{ready, Stream}; +use futures_core::{ready, Stream}; use super::Writer; use crate::error::PayloadError; diff --git a/actix-http/src/encoding/encoder.rs b/actix-http/src/encoding/encoder.rs index c58e1f434..6ec122fa0 100644 --- a/actix-http/src/encoding/encoder.rs +++ b/actix-http/src/encoding/encoder.rs @@ -8,6 +8,7 @@ use actix_threadpool::{run, CpuFuture}; use brotli::CompressorWriter; use bytes::Bytes; use flate2::write::{GzEncoder, ZlibEncoder}; +use futures_core::ready; use crate::body::{Body, BodySize, MessageBody, ResponseBody}; use crate::http::header::{ContentEncoding, CONTENT_ENCODING}; @@ -101,7 +102,7 @@ impl MessageBody for Encoder { } if let Some(ref mut fut) = self.fut { - let mut encoder = match futures::ready!(Pin::new(fut).poll(cx)) { + let mut encoder = match ready!(Pin::new(fut).poll(cx)) { Ok(item) => item, Err(e) => return Poll::Ready(Some(Err(e.into()))), }; diff --git a/actix-http/src/error.rs b/actix-http/src/error.rs index 512b14ca7..bb18184d8 100644 --- a/actix-http/src/error.rs +++ b/actix-http/src/error.rs @@ -10,7 +10,7 @@ pub use actix_threadpool::BlockingError; use actix_utils::timeout::TimeoutError; use bytes::BytesMut; use derive_more::{Display, From}; -pub use futures::channel::oneshot::Canceled; +pub use futures_channel::oneshot::Canceled; use http::uri::InvalidUri; use http::{header, Error as HttpError, StatusCode}; use httparse; diff --git a/actix-http/src/h1/codec.rs b/actix-http/src/h1/codec.rs index 5b75a4e56..de2af9ee7 100644 --- a/actix-http/src/h1/codec.rs +++ b/actix-http/src/h1/codec.rs @@ -195,17 +195,11 @@ impl Encoder for Codec { #[cfg(test)] mod tests { - use std::{cmp, io}; - - use actix_codec::{AsyncRead, AsyncWrite}; - use bytes::{Buf, Bytes, BytesMut}; - use http::{Method, Version}; + use bytes::BytesMut; + use http::Method; use super::*; - use crate::error::ParseError; - use crate::h1::Message; use crate::httpmessage::HttpMessage; - use crate::request::Request; #[test] fn test_http_request_chunked_payload_and_next_message() { diff --git a/actix-http/src/h1/dispatcher.rs b/actix-http/src/h1/dispatcher.rs index 1147465be..6b37be683 100644 --- a/actix-http/src/h1/dispatcher.rs +++ b/actix-http/src/h1/dispatcher.rs @@ -912,7 +912,7 @@ where #[cfg(test)] mod tests { use actix_service::IntoService; - use futures::future::{lazy, ok}; + use futures_util::future::{lazy, ok}; use super::*; use crate::error::Error; diff --git a/actix-http/src/h1/encoder.rs b/actix-http/src/h1/encoder.rs index c3426c6e0..4689906b4 100644 --- a/actix-http/src/h1/encoder.rs +++ b/actix-http/src/h1/encoder.rs @@ -521,12 +521,14 @@ fn write_camel_case(value: &[u8], buffer: &mut [u8]) { #[cfg(test)] mod tests { + use std::rc::Rc; + use bytes::Bytes; - //use std::rc::Rc; + use http::header::AUTHORIZATION; use super::*; use crate::http::header::{HeaderValue, CONTENT_TYPE}; - use http::header::AUTHORIZATION; + use crate::RequestHead; #[test] fn test_chunked_te() { diff --git a/actix-http/src/h1/expect.rs b/actix-http/src/h1/expect.rs index 187999358..6c08df08e 100644 --- a/actix-http/src/h1/expect.rs +++ b/actix-http/src/h1/expect.rs @@ -1,7 +1,7 @@ use std::task::{Context, Poll}; use actix_service::{Service, ServiceFactory}; -use futures::future::{ok, Ready}; +use futures_util::future::{ok, Ready}; use crate::error::Error; use crate::request::Request; diff --git a/actix-http/src/h1/payload.rs b/actix-http/src/h1/payload.rs index abf42dc89..6a348810c 100644 --- a/actix-http/src/h1/payload.rs +++ b/actix-http/src/h1/payload.rs @@ -7,7 +7,7 @@ use std::task::{Context, Poll}; use actix_utils::task::LocalWaker; use bytes::Bytes; -use futures::Stream; +use futures_core::Stream; use crate::error::PayloadError; @@ -226,7 +226,7 @@ impl Inner { #[cfg(test)] mod tests { use super::*; - use futures::future::poll_fn; + use futures_util::future::poll_fn; #[actix_rt::test] async fn test_unread_data() { diff --git a/actix-http/src/h1/service.rs b/actix-http/src/h1/service.rs index 6d5123843..fb5514da3 100644 --- a/actix-http/src/h1/service.rs +++ b/actix-http/src/h1/service.rs @@ -8,8 +8,8 @@ use std::{fmt, net}; use actix_codec::{AsyncRead, AsyncWrite, Framed}; use actix_rt::net::TcpStream; use actix_service::{pipeline_factory, IntoServiceFactory, Service, ServiceFactory}; -use futures::future::{ok, Ready}; -use futures::ready; +use futures_core::ready; +use futures_util::future::{ok, Ready}; use crate::body::MessageBody; use crate::cloneable::CloneableService; diff --git a/actix-http/src/h1/upgrade.rs b/actix-http/src/h1/upgrade.rs index d02d4f075..22ba99e26 100644 --- a/actix-http/src/h1/upgrade.rs +++ b/actix-http/src/h1/upgrade.rs @@ -3,7 +3,7 @@ use std::task::{Context, Poll}; use actix_codec::Framed; use actix_service::{Service, ServiceFactory}; -use futures::future::Ready; +use futures_util::future::Ready; use crate::error::Error; use crate::h1::Codec; diff --git a/actix-http/src/h2/mod.rs b/actix-http/src/h2/mod.rs index 6ba29bbcf..b00969227 100644 --- a/actix-http/src/h2/mod.rs +++ b/actix-http/src/h2/mod.rs @@ -3,7 +3,7 @@ use std::pin::Pin; use std::task::{Context, Poll}; use bytes::Bytes; -use futures::Stream; +use futures_core::Stream; use h2::RecvStream; mod dispatcher; diff --git a/actix-http/src/h2/service.rs b/actix-http/src/h2/service.rs index 91d721baf..7cae99f5b 100644 --- a/actix-http/src/h2/service.rs +++ b/actix-http/src/h2/service.rs @@ -11,8 +11,8 @@ use actix_service::{ ServiceFactory, }; use bytes::Bytes; -use futures::future::ok; -use futures::ready; +use futures_core::ready; +use futures_util::future::ok; use h2::server::{self, Handshake}; use log::error; @@ -141,9 +141,9 @@ mod openssl { #[cfg(feature = "rustls")] mod rustls { use super::*; - use actix_tls::rustls::{Acceptor, ServerConfig, Session, TlsStream}; + use actix_tls::rustls::{Acceptor, ServerConfig, TlsStream}; use actix_tls::SslError; - use std::{fmt, io}; + use std::io; impl H2Service, S, B> where diff --git a/actix-http/src/payload.rs b/actix-http/src/payload.rs index 9f7f2a31f..54de6ed93 100644 --- a/actix-http/src/payload.rs +++ b/actix-http/src/payload.rs @@ -2,7 +2,7 @@ use std::pin::Pin; use std::task::{Context, Poll}; use bytes::Bytes; -use futures::Stream; +use futures_core::Stream; use h2::RecvStream; use crate::error::PayloadError; diff --git a/actix-http/src/response.rs b/actix-http/src/response.rs index be62151be..fcdcd7cdf 100644 --- a/actix-http/src/response.rs +++ b/actix-http/src/response.rs @@ -7,7 +7,7 @@ use std::task::{Context, Poll}; use std::{fmt, str}; use bytes::{Bytes, BytesMut}; -use futures::stream::Stream; +use futures_core::Stream; use serde::Serialize; use serde_json; diff --git a/actix-http/src/service.rs b/actix-http/src/service.rs index cb7e541ee..2d934cc19 100644 --- a/actix-http/src/service.rs +++ b/actix-http/src/service.rs @@ -7,7 +7,8 @@ use actix_codec::{AsyncRead, AsyncWrite, Framed}; use actix_rt::net::TcpStream; use actix_service::{pipeline_factory, IntoServiceFactory, Service, ServiceFactory}; use bytes::Bytes; -use futures::{future::ok, ready, Future}; +use futures_core::{ready, Future}; +use futures_util::future::ok; use h2::server::{self, Handshake}; use pin_project::{pin_project, project}; diff --git a/awc/CHANGES.md b/awc/CHANGES.md index f4923db88..726a6d666 100644 --- a/awc/CHANGES.md +++ b/awc/CHANGES.md @@ -1,5 +1,9 @@ # Changes +## [1.0.0] - 2019-12-13 + +* Release + ## [1.0.0-alpha.3] * Migrate to `std::future` diff --git a/awc/Cargo.toml b/awc/Cargo.toml index a183b9fee..a84e7295c 100644 --- a/awc/Cargo.toml +++ b/awc/Cargo.toml @@ -42,7 +42,7 @@ actix-rt = "1.0.0" base64 = "0.11" bytes = "0.5.2" derive_more = "0.99.2" -futures = "0.3.1" +futures-core = "0.3.1" log =" 0.4" mime = "0.3" percent-encoding = "2.1" @@ -63,5 +63,6 @@ actix-server = "1.0.0" actix-tls = { version = "1.0.0", features=["openssl", "rustls"] } brotli = "3.3.0" flate2 = "1.0.13" +futures = "0.3.1" env_logger = "0.6" webpki = "0.21" diff --git a/awc/src/connect.rs b/awc/src/connect.rs index 59a909df5..618d653f5 100644 --- a/awc/src/connect.rs +++ b/awc/src/connect.rs @@ -1,3 +1,4 @@ +use std::future::Future; use std::pin::Pin; use std::rc::Rc; use std::task::{Context, Poll}; @@ -12,7 +13,6 @@ use actix_http::h1::ClientCodec; use actix_http::http::HeaderMap; use actix_http::{RequestHead, RequestHeadType, ResponseHead}; use actix_service::Service; -use futures::future::{FutureExt, LocalBoxFuture}; use crate::response::ClientResponse; @@ -24,7 +24,7 @@ pub(crate) trait Connect { head: RequestHead, body: Body, addr: Option, - ) -> LocalBoxFuture<'static, Result>; + ) -> Pin>>>; fn send_request_extra( &mut self, @@ -32,16 +32,22 @@ pub(crate) trait Connect { extra_headers: Option, body: Body, addr: Option, - ) -> LocalBoxFuture<'static, Result>; + ) -> Pin>>>; /// Send request, returns Response and Framed fn open_tunnel( &mut self, head: RequestHead, addr: Option, - ) -> LocalBoxFuture< - 'static, - Result<(ResponseHead, Framed), SendRequestError>, + ) -> Pin< + Box< + dyn Future< + Output = Result< + (ResponseHead, Framed), + SendRequestError, + >, + >, + >, >; /// Send request and extra headers, returns Response and Framed @@ -50,9 +56,15 @@ pub(crate) trait Connect { head: Rc, extra_headers: Option, addr: Option, - ) -> LocalBoxFuture< - 'static, - Result<(ResponseHead, Framed), SendRequestError>, + ) -> Pin< + Box< + dyn Future< + Output = Result< + (ResponseHead, Framed), + SendRequestError, + >, + >, + >, >; } @@ -70,14 +82,14 @@ where head: RequestHead, body: Body, addr: Option, - ) -> LocalBoxFuture<'static, Result> { + ) -> Pin>>> { // connect to the host let fut = self.0.call(ClientConnect { uri: head.uri.clone(), addr, }); - async move { + Box::pin(async move { let connection = fut.await?; // send request @@ -85,8 +97,7 @@ where .send_request(RequestHeadType::from(head), body) .await .map(|(head, payload)| ClientResponse::new(head, payload)) - } - .boxed_local() + }) } fn send_request_extra( @@ -95,14 +106,14 @@ where extra_headers: Option, body: Body, addr: Option, - ) -> LocalBoxFuture<'static, Result> { + ) -> Pin>>> { // connect to the host let fut = self.0.call(ClientConnect { uri: head.uri.clone(), addr, }); - async move { + Box::pin(async move { let connection = fut.await?; // send request @@ -111,17 +122,22 @@ where .await?; Ok(ClientResponse::new(head, payload)) - } - .boxed_local() + }) } fn open_tunnel( &mut self, head: RequestHead, addr: Option, - ) -> LocalBoxFuture< - 'static, - Result<(ResponseHead, Framed), SendRequestError>, + ) -> Pin< + Box< + dyn Future< + Output = Result< + (ResponseHead, Framed), + SendRequestError, + >, + >, + >, > { // connect to the host let fut = self.0.call(ClientConnect { @@ -129,7 +145,7 @@ where addr, }); - async move { + Box::pin(async move { let connection = fut.await?; // send request @@ -138,8 +154,7 @@ where let framed = framed.map_io(|io| BoxedSocket(Box::new(Socket(io)))); Ok((head, framed)) - } - .boxed_local() + }) } fn open_tunnel_extra( @@ -147,9 +162,15 @@ where head: Rc, extra_headers: Option, addr: Option, - ) -> LocalBoxFuture< - 'static, - Result<(ResponseHead, Framed), SendRequestError>, + ) -> Pin< + Box< + dyn Future< + Output = Result< + (ResponseHead, Framed), + SendRequestError, + >, + >, + >, > { // connect to the host let fut = self.0.call(ClientConnect { @@ -157,7 +178,7 @@ where addr, }); - async move { + Box::pin(async move { let connection = fut.await?; // send request @@ -167,8 +188,7 @@ where let framed = framed.map_io(|io| BoxedSocket(Box::new(Socket(io)))); Ok((head, framed)) - } - .boxed_local() + }) } } diff --git a/awc/src/frozen.rs b/awc/src/frozen.rs index 748a15d3b..f7098863c 100644 --- a/awc/src/frozen.rs +++ b/awc/src/frozen.rs @@ -4,7 +4,7 @@ use std::rc::Rc; use std::time::Duration; use bytes::Bytes; -use futures::Stream; +use futures_core::Stream; use serde::Serialize; use actix_http::body::Body; diff --git a/awc/src/request.rs b/awc/src/request.rs index e8434aea9..67b063a8e 100644 --- a/awc/src/request.rs +++ b/awc/src/request.rs @@ -5,7 +5,7 @@ use std::time::Duration; use std::{fmt, net}; use bytes::Bytes; -use futures::Stream; +use futures_core::Stream; use percent_encoding::percent_encode; use serde::Serialize; diff --git a/awc/src/response.rs b/awc/src/response.rs index c1cbf9e25..20093c72d 100644 --- a/awc/src/response.rs +++ b/awc/src/response.rs @@ -5,7 +5,7 @@ use std::pin::Pin; use std::task::{Context, Poll}; use bytes::{Bytes, BytesMut}; -use futures::{ready, Future, Stream}; +use futures_core::{ready, Future, Stream}; use actix_http::cookie::Cookie; use actix_http::error::{CookieParseError, PayloadError}; diff --git a/awc/src/sender.rs b/awc/src/sender.rs index f6142ab2a..7381e77b7 100644 --- a/awc/src/sender.rs +++ b/awc/src/sender.rs @@ -7,7 +7,7 @@ use std::time::Duration; use actix_rt::time::{delay_for, Delay}; use bytes::Bytes; use derive_more::From; -use futures::{future::LocalBoxFuture, ready, Future, Stream}; +use futures_core::{ready, Future, Stream}; use serde::Serialize; use serde_json; @@ -49,7 +49,7 @@ impl Into for PrepForSendingError { #[must_use = "futures do nothing unless polled"] pub enum SendClientRequest { Fut( - LocalBoxFuture<'static, Result>, + Pin>>>, Option, bool, ), @@ -58,7 +58,7 @@ pub enum SendClientRequest { impl SendClientRequest { pub(crate) fn new( - send: LocalBoxFuture<'static, Result>, + send: Pin>>>, response_decompress: bool, timeout: Option, ) -> SendClientRequest {