From 117d28f7ba104cb162307772aaf4a3d30367167a Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Wed, 4 Mar 2020 15:09:31 +0900 Subject: [PATCH 01/27] Update `actix-connect` to 2.0.0-alpha.1 --- actix-framed/Cargo.toml | 2 +- actix-http/Cargo.toml | 4 ++-- awc/Cargo.toml | 2 +- test-server/Cargo.toml | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/actix-framed/Cargo.toml b/actix-framed/Cargo.toml index dc974e402..133b8083d 100644 --- a/actix-framed/Cargo.toml +++ b/actix-framed/Cargo.toml @@ -32,6 +32,6 @@ log = "0.4" [dev-dependencies] actix-server = "1.0.0" -actix-connect = { version = "1.0.0", features=["openssl"] } +actix-connect = { version = "2.0.0-alpha.1", features=["openssl"] } actix-http-test = { version = "1.0.0", features=["openssl"] } actix-utils = "1.0.3" diff --git a/actix-http/Cargo.toml b/actix-http/Cargo.toml index 356e68405..ea33b42d0 100644 --- a/actix-http/Cargo.toml +++ b/actix-http/Cargo.toml @@ -45,7 +45,7 @@ actors = ["actix"] [dependencies] actix-service = "1.0.5" actix-codec = "0.2.0" -actix-connect = "1.0.2" +actix-connect = "2.0.0-alpha.1" actix-utils = "1.0.6" actix-rt = "1.0.0" actix-threadpool = "0.3.1" @@ -94,7 +94,7 @@ fail-ure = { version = "0.1.5", package="failure", optional = true } [dev-dependencies] actix-server = "1.0.1" -actix-connect = { version = "1.0.2", features=["openssl"] } +actix-connect = { version = "2.0.0-alpha.1", features=["openssl"] } actix-http-test = { version = "1.0.0", features=["openssl"] } actix-tls = { version = "1.0.0", features=["openssl"] } criterion = "0.3" diff --git a/awc/Cargo.toml b/awc/Cargo.toml index 71b23ece3..ec6ebc77a 100644 --- a/awc/Cargo.toml +++ b/awc/Cargo.toml @@ -54,7 +54,7 @@ open-ssl = { version="0.10", package="openssl", optional = true } rust-tls = { version = "0.16.0", package="rustls", optional = true, features = ["dangerous_configuration"] } [dev-dependencies] -actix-connect = { version = "1.0.1", features=["openssl"] } +actix-connect = { version = "2.0.0-alpha.1", features=["openssl"] } actix-web = { version = "2.0.0", features=["openssl"] } actix-http = { version = "2.0.0-alpha.1", features=["openssl"] } actix-http-test = { version = "1.0.0", features=["openssl"] } diff --git a/test-server/Cargo.toml b/test-server/Cargo.toml index 117c1a318..ba8e1c9ea 100644 --- a/test-server/Cargo.toml +++ b/test-server/Cargo.toml @@ -32,7 +32,7 @@ openssl = ["open-ssl", "awc/openssl"] [dependencies] actix-service = "1.0.1" actix-codec = "0.2.0" -actix-connect = "1.0.0" +actix-connect = "2.0.0-alpha.1" actix-utils = "1.0.3" actix-rt = "1.0.0" actix-server = "1.0.0" From b9b52079e0eb27dfff1135df880618539284ca07 Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Wed, 4 Mar 2020 15:10:23 +0900 Subject: [PATCH 02/27] Update `actix-tls` to 2.0.0-alpha.1 --- Cargo.toml | 2 +- actix-http/Cargo.toml | 4 ++-- awc/Cargo.toml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 125008870..af6a728ab 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -68,7 +68,7 @@ actix-server = "1.0.0" actix-testing = "1.0.0" actix-macros = "0.1.0" actix-threadpool = "0.3.1" -actix-tls = "1.0.0" +actix-tls = "2.0.0-alpha.1" actix-web-codegen = "0.2.0" actix-http = "2.0.0-alpha.1" diff --git a/actix-http/Cargo.toml b/actix-http/Cargo.toml index ea33b42d0..9efe16996 100644 --- a/actix-http/Cargo.toml +++ b/actix-http/Cargo.toml @@ -49,7 +49,7 @@ actix-connect = "2.0.0-alpha.1" actix-utils = "1.0.6" actix-rt = "1.0.0" actix-threadpool = "0.3.1" -actix-tls = { version = "1.0.0", optional = true } +actix-tls = { version = "2.0.0-alpha.1", optional = true } actix = { version = "0.10.0-alpha.1", optional = true } base64 = "0.11" @@ -96,7 +96,7 @@ fail-ure = { version = "0.1.5", package="failure", optional = true } actix-server = "1.0.1" actix-connect = { version = "2.0.0-alpha.1", features=["openssl"] } actix-http-test = { version = "1.0.0", features=["openssl"] } -actix-tls = { version = "1.0.0", features=["openssl"] } +actix-tls = { version = "2.0.0-alpha.1", features=["openssl"] } criterion = "0.3" futures = "0.3.1" env_logger = "0.7" diff --git a/awc/Cargo.toml b/awc/Cargo.toml index ec6ebc77a..99f0e3eba 100644 --- a/awc/Cargo.toml +++ b/awc/Cargo.toml @@ -60,7 +60,7 @@ actix-http = { version = "2.0.0-alpha.1", features=["openssl"] } actix-http-test = { version = "1.0.0", features=["openssl"] } actix-utils = "1.0.3" actix-server = "1.0.0" -actix-tls = { version = "1.0.0", features=["openssl", "rustls"] } +actix-tls = { version = "2.0.0-alpha.1", features=["openssl", "rustls"] } brotli2 = "0.3.2" flate2 = "1.0.13" futures = "0.3.1" From 687dc609dd19602c0af6a3b3bba6acdc1875221c Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Wed, 4 Mar 2020 15:11:31 +0900 Subject: [PATCH 03/27] Update `rustls` to 0.17 --- Cargo.toml | 2 +- actix-http/Cargo.toml | 2 +- awc/Cargo.toml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index af6a728ab..fa29c225f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -90,7 +90,7 @@ serde_urlencoded = "0.6.1" time = { version = "0.2.7", default-features = false, features = ["std"] } url = "2.1" open-ssl = { version="0.10", package = "openssl", optional = true } -rust-tls = { version = "0.16.0", package = "rustls", optional = true } +rust-tls = { version = "0.17.0", package = "rustls", optional = true } [dev-dependencies] actix = "0.10.0-alpha.1" diff --git a/actix-http/Cargo.toml b/actix-http/Cargo.toml index 9efe16996..df9653aa3 100644 --- a/actix-http/Cargo.toml +++ b/actix-http/Cargo.toml @@ -102,7 +102,7 @@ futures = "0.3.1" env_logger = "0.7" serde_derive = "1.0" open-ssl = { version="0.10", package = "openssl" } -rust-tls = { version="0.16", package = "rustls" } +rust-tls = { version="0.17", package = "rustls" } [[bench]] name = "content-length" diff --git a/awc/Cargo.toml b/awc/Cargo.toml index 99f0e3eba..d27615f7a 100644 --- a/awc/Cargo.toml +++ b/awc/Cargo.toml @@ -51,7 +51,7 @@ serde = "1.0" serde_json = "1.0" serde_urlencoded = "0.6.1" open-ssl = { version="0.10", package="openssl", optional = true } -rust-tls = { version = "0.16.0", package="rustls", optional = true, features = ["dangerous_configuration"] } +rust-tls = { version = "0.17.0", package="rustls", optional = true, features = ["dangerous_configuration"] } [dev-dependencies] actix-connect = { version = "2.0.0-alpha.1", features=["openssl"] } From 9d661dc4f3edf9deca8e13d517f95151bdeb4111 Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Wed, 4 Mar 2020 15:20:14 +0900 Subject: [PATCH 04/27] Update changelog --- CHANGES.md | 4 ++-- actix-http/CHANGES.md | 10 +++++++--- test-server/CHANGES.md | 1 + 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index ab9caa7bd..da4a77a80 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -10,10 +10,10 @@ ### Changed * Use `sha-1` crate instead of unmaintained `sha1` crate - * Skip empty chunks when returning response from a `Stream` #1308 - * Update the `time` dependency to 0.2.7 +* Update `actix-tls` dependency to 2.0.0-alpha.1 +* Update `rustls` dependency to 0.17 ## [2.0.0] - 2019-12-25 diff --git a/actix-http/CHANGES.md b/actix-http/CHANGES.md index 229fcbbae..4ec981174 100644 --- a/actix-http/CHANGES.md +++ b/actix-http/CHANGES.md @@ -1,15 +1,19 @@ # Changes +## [2.0.0-alpha.2] - someday + +### Changed + +* Update `actix-connect` and `actix-tls` dependency to 2.0.0-alpha.1 + + ## [2.0.0-alpha.1] - 2020-02-27 ### Changed * Update the `time` dependency to 0.2.7. - * Moved actors messages support from actix crate, enabled with feature `actors`. - * Breaking change: trait MessageBody requires Unpin and accepting Pin<&mut Self> instead of &mut self in the poll_next(). - * MessageBody is not implemented for &'static [u8] anymore. ### Fixed diff --git a/test-server/CHANGES.md b/test-server/CHANGES.md index 96c010355..3a990a594 100644 --- a/test-server/CHANGES.md +++ b/test-server/CHANGES.md @@ -3,6 +3,7 @@ ## [Unreleased] - 2020-xx-xx * Update the `time` dependency to 0.2.7 +* Update `actix-connect` dependency to 2.0.0-alpha.1 ## [1.0.0] - 2019-12-13 From e90950fee137f3e161a975bbb27b5aab5d25306f Mon Sep 17 00:00:00 2001 From: Aaron Hill Date: Wed, 4 Mar 2020 11:27:58 -0500 Subject: [PATCH 05/27] Re-apply commit 2cf7b3ad20fb823314426a5e33b0805045ec1d8a This ended up getting reverted by #1367, which re-introduced an unsound use of `Pin::new_unchecked` See my original PR #1374 for the reasoning behind this change. --- actix-http/src/h1/dispatcher.rs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/actix-http/src/h1/dispatcher.rs b/actix-http/src/h1/dispatcher.rs index 6276653d3..ffdcd8d9b 100644 --- a/actix-http/src/h1/dispatcher.rs +++ b/actix-http/src/h1/dispatcher.rs @@ -73,7 +73,7 @@ where U::Error: fmt::Display, { Normal(#[pin] InnerDispatcher), - Upgrade(#[pin] U::Future), + Upgrade(Pin>), } #[pin_project] @@ -123,8 +123,8 @@ where B: MessageBody, { None, - ExpectCall(#[pin] X::Future), - ServiceCall(#[pin] S::Future), + ExpectCall(Pin>), + ServiceCall(Pin>), SendPayload(#[pin] ResponseBody), } @@ -391,11 +391,11 @@ where } None => None, }, - State::ExpectCall(fut) => match fut.poll(cx) { + State::ExpectCall(fut) => match fut.as_mut().poll(cx) { Poll::Ready(Ok(req)) => { self.as_mut().send_continue(); this = self.as_mut().project(); - this.state.set(State::ServiceCall(this.service.call(req))); + this.state.set(State::ServiceCall(Box::pin(this.service.call(req)))); continue; } Poll::Ready(Err(e)) => { @@ -405,7 +405,7 @@ where } Poll::Pending => None, }, - State::ServiceCall(fut) => match fut.poll(cx) { + State::ServiceCall(fut) => match fut.as_mut().poll(cx) { Poll::Ready(Ok(res)) => { let (res, body) = res.into().replace_body(()); let state = self.as_mut().send_response(res, body)?; @@ -485,8 +485,8 @@ where ) -> Result, DispatchError> { // Handle `EXPECT: 100-Continue` header let req = if req.head().expect() { - let mut task = self.as_mut().project().expect.call(req); - match unsafe { Pin::new_unchecked(&mut task) }.poll(cx) { + let mut task = Box::pin(self.as_mut().project().expect.call(req)); + match task.as_mut().poll(cx) { Poll::Ready(Ok(req)) => { self.as_mut().send_continue(); req @@ -504,8 +504,8 @@ where }; // Call service - let mut task = self.as_mut().project().service.call(req); - match unsafe { Pin::new_unchecked(&mut task) }.poll(cx) { + let mut task = Box::pin(self.as_mut().project().service.call(req)); + match task.as_mut().poll(cx) { Poll::Ready(Ok(res)) => { let (res, body) = res.into().replace_body(()); self.send_response(res, body) @@ -807,7 +807,7 @@ where self.as_mut() .project() .inner - .set(DispatcherState::Upgrade(upgrade)); + .set(DispatcherState::Upgrade(Box::pin(upgrade))); return self.poll(cx); } @@ -855,7 +855,7 @@ where } } } - DispatcherState::Upgrade(fut) => fut.poll(cx).map_err(|e| { + DispatcherState::Upgrade(fut) => fut.as_mut().poll(cx).map_err(|e| { error!("Upgrade handler error: {}", e); DispatchError::Upgrade }), From 10e3e72595f14fd416ab471fff6e23f11661cc4e Mon Sep 17 00:00:00 2001 From: Maxim Vorobjov Date: Sat, 7 Mar 2020 04:09:31 +0200 Subject: [PATCH 06/27] Http2 client configuration to improve performance (#1394) * add defaults for http2 client configuration * fix spaces * Add changes text for extended H2 defaults buffers * client: configurable H2 window sizes and max_http_version * add H2 window size configuration and max_http_version to awc::ClientBuilder * add awc::ClientBuilder H2 window sizes and max_http_version * add test for H2 window size settings * cleanup comment * Apply code review fixes * Code review fix for awc ClientBuilder * Remove unnecessary comments on code review * pin quote version to resolve build issue * max_http_version to accept http::Version * revert fix for quote broken build --- actix-http/CHANGES.md | 5 + actix-http/src/client/config.rs | 39 ++++++++ actix-http/src/client/connector.rs | 146 ++++++++++++++++------------- actix-http/src/client/h2proto.rs | 22 ++++- actix-http/src/client/mod.rs | 1 + actix-http/src/client/pool.rs | 46 +++++---- awc/CHANGES.md | 6 ++ awc/src/builder.rs | 86 +++++++++++++---- awc/tests/test_connector.rs | 61 ++++++++++++ 9 files changed, 302 insertions(+), 110 deletions(-) create mode 100644 actix-http/src/client/config.rs create mode 100644 awc/tests/test_connector.rs diff --git a/actix-http/CHANGES.md b/actix-http/CHANGES.md index 4ec981174..ccfdc81d6 100644 --- a/actix-http/CHANGES.md +++ b/actix-http/CHANGES.md @@ -6,6 +6,11 @@ * Update `actix-connect` and `actix-tls` dependency to 2.0.0-alpha.1 +* Change default initial window size and connection window size for HTTP2 to 2MB and 1MB respectively to improve download speed for awc when downloading large objects. + +* client::Connector accepts initial_window_size and initial_connection_window_size HTTP2 configuration + +* client::Connector allowing to set max_http_version to limit HTTP version to be used ## [2.0.0-alpha.1] - 2020-02-27 diff --git a/actix-http/src/client/config.rs b/actix-http/src/client/config.rs new file mode 100644 index 000000000..c86c697a2 --- /dev/null +++ b/actix-http/src/client/config.rs @@ -0,0 +1,39 @@ +use std::time::Duration; + +// These values are taken from hyper/src/proto/h2/client.rs +const DEFAULT_H2_CONN_WINDOW: u32 = 1024 * 1024 * 2; // 2mb +const DEFAULT_H2_STREAM_WINDOW: u32 = 1024 * 1024; // 1mb + +/// Connector configuration +#[derive(Clone)] +pub(crate) struct ConnectorConfig { + pub(crate) timeout: Duration, + pub(crate) conn_lifetime: Duration, + pub(crate) conn_keep_alive: Duration, + pub(crate) disconnect_timeout: Option, + pub(crate) limit: usize, + pub(crate) conn_window_size: u32, + pub(crate) stream_window_size: u32, +} + +impl Default for ConnectorConfig { + fn default() -> Self { + Self { + timeout: Duration::from_secs(1), + conn_lifetime: Duration::from_secs(75), + conn_keep_alive: Duration::from_secs(15), + disconnect_timeout: Some(Duration::from_millis(3000)), + limit: 100, + conn_window_size: DEFAULT_H2_CONN_WINDOW, + stream_window_size: DEFAULT_H2_STREAM_WINDOW, + } + } +} + +impl ConnectorConfig { + pub(crate) fn no_disconnect_timeout(&self) -> Self { + let mut res = self.clone(); + res.disconnect_timeout = None; + res + } +} diff --git a/actix-http/src/client/connector.rs b/actix-http/src/client/connector.rs index 055d4276d..adb88bbed 100644 --- a/actix-http/src/client/connector.rs +++ b/actix-http/src/client/connector.rs @@ -11,6 +11,7 @@ use actix_service::{apply_fn, Service}; use actix_utils::timeout::{TimeoutError, TimeoutService}; use http::Uri; +use super::config::ConnectorConfig; use super::connection::Connection; use super::error::ConnectError; use super::pool::{ConnectionPool, Protocol}; @@ -48,11 +49,7 @@ type SslConnector = (); /// ``` pub struct Connector { connector: T, - timeout: Duration, - conn_lifetime: Duration, - conn_keep_alive: Duration, - disconnect_timeout: Duration, - limit: usize, + config: ConnectorConfig, #[allow(dead_code)] ssl: SslConnector, _t: PhantomData, @@ -71,42 +68,49 @@ impl Connector<(), ()> { > + Clone, TcpStream, > { - let ssl = { - #[cfg(feature = "openssl")] - { - use actix_connect::ssl::openssl::SslMethod; - - let mut ssl = OpensslConnector::builder(SslMethod::tls()).unwrap(); - let _ = ssl - .set_alpn_protos(b"\x02h2\x08http/1.1") - .map_err(|e| error!("Can not set alpn protocol: {:?}", e)); - SslConnector::Openssl(ssl.build()) - } - #[cfg(all(not(feature = "openssl"), feature = "rustls"))] - { - let protos = vec![b"h2".to_vec(), b"http/1.1".to_vec()]; - let mut config = ClientConfig::new(); - config.set_protocols(&protos); - config - .root_store - .add_server_trust_anchors(&actix_tls::rustls::TLS_SERVER_ROOTS); - SslConnector::Rustls(Arc::new(config)) - } - #[cfg(not(any(feature = "openssl", feature = "rustls")))] - {} - }; - Connector { - ssl, + ssl: Self::build_ssl(vec![b"h2".to_vec(), b"http/1.1".to_vec()]), connector: default_connector(), - timeout: Duration::from_secs(1), - conn_lifetime: Duration::from_secs(75), - conn_keep_alive: Duration::from_secs(15), - disconnect_timeout: Duration::from_millis(3000), - limit: 100, + config: ConnectorConfig::default(), _t: PhantomData, } } + + // Build Ssl connector with openssl, based on supplied alpn protocols + #[cfg(feature = "openssl")] + fn build_ssl(protocols: Vec>) -> SslConnector + { + use actix_connect::ssl::openssl::SslMethod; + use bytes::{BufMut, BytesMut}; + + let mut alpn = BytesMut::with_capacity(20); + for proto in protocols.iter() { + alpn.put_u8(proto.len() as u8); + alpn.put(proto.as_slice()); + } + + let mut ssl = OpensslConnector::builder(SslMethod::tls()).unwrap(); + let _ = ssl + .set_alpn_protos(&alpn) + .map_err(|e| error!("Can not set alpn protocol: {:?}", e)); + SslConnector::Openssl(ssl.build()) + } + + // Build Ssl connector with rustls, based on supplied alpn protocols + #[cfg(all(not(feature = "openssl"), feature = "rustls"))] + fn build_ssl(protocols: Vec>) -> SslConnector + { + let mut config = ClientConfig::new(); + config.set_protocols(&protocols); + config + .root_store + .add_server_trust_anchors(&actix_tls::rustls::TLS_SERVER_ROOTS); + SslConnector::Rustls(Arc::new(config)) + } + + // ssl turned off, provides empty ssl connector + #[cfg(not(any(feature = "openssl", feature = "rustls")))] + fn build_ssl(_: Vec>) -> SslConnector {} } impl Connector { @@ -122,11 +126,7 @@ impl Connector { { Connector { connector, - timeout: self.timeout, - conn_lifetime: self.conn_lifetime, - conn_keep_alive: self.conn_keep_alive, - disconnect_timeout: self.disconnect_timeout, - limit: self.limit, + config: self.config, ssl: self.ssl, _t: PhantomData, } @@ -146,7 +146,7 @@ where /// Connection timeout, i.e. max time to connect to remote host including dns name resolution. /// Set to 1 second by default. pub fn timeout(mut self, timeout: Duration) -> Self { - self.timeout = timeout; + self.config.timeout = timeout; self } @@ -163,12 +163,42 @@ where self } + /// Maximum supported http major version + /// Supported versions http/1.1, http/2 + pub fn max_http_version(mut self, val: http::Version) -> Self { + let versions = match val { + http::Version::HTTP_11 => vec![b"http/1.1".to_vec()], + http::Version::HTTP_2 => vec![b"h2".to_vec(), b"http/1.1".to_vec()], + _ => unimplemented!("actix-http:client: supported versions http/1.1, http/2"), + }; + self.ssl = Connector::build_ssl(versions); + self + } + + /// Indicates the initial window size (in octets) for + /// HTTP2 stream-level flow control for received data. + /// + /// The default value is 65,535 and is good for APIs, but not for big objects. + pub fn initial_window_size(mut self, size: u32) -> Self { + self.config.stream_window_size = size; + self + } + + /// Indicates the initial window size (in octets) for + /// HTTP2 connection-level flow control for received data. + /// + /// The default value is 65,535 and is good for APIs, but not for big objects. + pub fn initial_connection_window_size(mut self, size: u32) -> Self { + self.config.conn_window_size = size; + self + } + /// Set total number of simultaneous connections per type of scheme. /// /// If limit is 0, the connector has no limit. /// The default limit size is 100. pub fn limit(mut self, limit: usize) -> Self { - self.limit = limit; + self.config.limit = limit; self } @@ -179,7 +209,7 @@ where /// exceeds this period, the connection is closed. /// Default keep-alive period is 15 seconds. pub fn conn_keep_alive(mut self, dur: Duration) -> Self { - self.conn_keep_alive = dur; + self.config.conn_keep_alive = dur; self } @@ -189,7 +219,7 @@ where /// until it is closed regardless of keep-alive period. /// Default lifetime period is 75 seconds. pub fn conn_lifetime(mut self, dur: Duration) -> Self { - self.conn_lifetime = dur; + self.config.conn_lifetime = dur; self } @@ -202,7 +232,7 @@ where /// /// By default disconnect timeout is set to 3000 milliseconds. pub fn disconnect_timeout(mut self, dur: Duration) -> Self { - self.disconnect_timeout = dur; + self.config.disconnect_timeout = Some(dur); self } @@ -216,7 +246,7 @@ where #[cfg(not(any(feature = "openssl", feature = "rustls")))] { let connector = TimeoutService::new( - self.timeout, + self.config.timeout, apply_fn(self.connector, |msg: Connect, srv| { srv.call(TcpConnect::new(msg.uri).set_addr(msg.addr)) }) @@ -231,10 +261,7 @@ where connect_impl::InnerConnector { tcp_pool: ConnectionPool::new( connector, - self.conn_lifetime, - self.conn_keep_alive, - None, - self.limit, + self.config.no_disconnect_timeout(), ), } } @@ -248,7 +275,7 @@ where use actix_service::{boxed::service, pipeline}; let ssl_service = TimeoutService::new( - self.timeout, + self.config.timeout, pipeline( apply_fn(self.connector.clone(), |msg: Connect, srv| { srv.call(TcpConnect::new(msg.uri).set_addr(msg.addr)) @@ -301,7 +328,7 @@ where }); let tcp_service = TimeoutService::new( - self.timeout, + self.config.timeout, apply_fn(self.connector, |msg: Connect, srv| { srv.call(TcpConnect::new(msg.uri).set_addr(msg.addr)) }) @@ -316,18 +343,9 @@ where connect_impl::InnerConnector { tcp_pool: ConnectionPool::new( tcp_service, - self.conn_lifetime, - self.conn_keep_alive, - None, - self.limit, - ), - ssl_pool: ConnectionPool::new( - ssl_service, - self.conn_lifetime, - self.conn_keep_alive, - Some(self.disconnect_timeout), - self.limit, + self.config.no_disconnect_timeout(), ), + ssl_pool: ConnectionPool::new(ssl_service, self.config), } } } diff --git a/actix-http/src/client/h2proto.rs b/actix-http/src/client/h2proto.rs index 69d20752a..2afd2d80b 100644 --- a/actix-http/src/client/h2proto.rs +++ b/actix-http/src/client/h2proto.rs @@ -1,11 +1,15 @@ use std::convert::TryFrom; +use std::future::Future; use std::time; use actix_codec::{AsyncRead, AsyncWrite}; use bytes::Bytes; use futures_util::future::poll_fn; use futures_util::pin_mut; -use h2::{client::SendRequest, SendStream}; +use h2::{ + client::{Builder, Connection, SendRequest}, + SendStream, +}; use http::header::{HeaderValue, CONNECTION, CONTENT_LENGTH, TRANSFER_ENCODING}; use http::{request::Request, Method, Version}; @@ -14,6 +18,7 @@ use crate::header::HeaderMap; use crate::message::{RequestHeadType, ResponseHead}; use crate::payload::Payload; +use super::config::ConnectorConfig; use super::connection::{ConnectionType, IoConnection}; use super::error::SendRequestError; use super::pool::Acquired; @@ -185,3 +190,18 @@ fn release( } } } + +pub(crate) fn handshake( + io: Io, + config: &ConnectorConfig, +) -> impl Future, Connection), h2::Error>> +where + Io: AsyncRead + AsyncWrite + Unpin + 'static, +{ + let mut builder = Builder::new(); + builder + .initial_window_size(config.stream_window_size) + .initial_connection_window_size(config.conn_window_size) + .enable_push(false); + builder.handshake(io) +} diff --git a/actix-http/src/client/mod.rs b/actix-http/src/client/mod.rs index a45aebcd5..dd1e9b25a 100644 --- a/actix-http/src/client/mod.rs +++ b/actix-http/src/client/mod.rs @@ -1,6 +1,7 @@ //! Http client api use http::Uri; +mod config; mod connection; mod connector; mod error; diff --git a/actix-http/src/client/pool.rs b/actix-http/src/client/pool.rs index 38a51b558..983396f92 100644 --- a/actix-http/src/client/pool.rs +++ b/actix-http/src/client/pool.rs @@ -13,14 +13,16 @@ use actix_utils::{oneshot, task::LocalWaker}; use bytes::Bytes; use futures_util::future::{poll_fn, FutureExt, LocalBoxFuture}; use fxhash::FxHashMap; -use h2::client::{handshake, Connection, SendRequest}; +use h2::client::{Connection, SendRequest}; use http::uri::Authority; use indexmap::IndexSet; use pin_project::pin_project; use slab::Slab; +use super::config::ConnectorConfig; use super::connection::{ConnectionType, IoConnection}; use super::error::ConnectError; +use super::h2proto::handshake; use super::Connect; #[derive(Clone, Copy, PartialEq)] @@ -50,20 +52,11 @@ where T: Service + 'static, { - pub(crate) fn new( - connector: T, - conn_lifetime: Duration, - conn_keep_alive: Duration, - disconnect_timeout: Option, - limit: usize, - ) -> Self { + pub(crate) fn new(connector: T, config: ConnectorConfig) -> Self { ConnectionPool( Rc::new(RefCell::new(connector)), Rc::new(RefCell::new(Inner { - conn_lifetime, - conn_keep_alive, - disconnect_timeout, - limit, + config, acquired: 0, waiters: Slab::new(), waiters_queue: IndexSet::new(), @@ -129,6 +122,8 @@ where // open tcp connection let (io, proto) = connector.call(req).await?; + let config = inner.borrow().config.clone(); + let guard = OpenGuard::new(key, inner); if proto == Protocol::Http1 { @@ -138,7 +133,7 @@ where Some(guard.consume()), )) } else { - let (snd, connection) = handshake(io).await?; + let (snd, connection) = handshake(io, &config).await?; actix_rt::spawn(connection.map(|_| ())); Ok(IoConnection::new( ConnectionType::H2(snd), @@ -255,10 +250,7 @@ struct AvailableConnection { } pub(crate) struct Inner { - conn_lifetime: Duration, - conn_keep_alive: Duration, - disconnect_timeout: Option, - limit: usize, + config: ConnectorConfig, acquired: usize, available: FxHashMap>>, waiters: Slab< @@ -311,7 +303,7 @@ where fn acquire(&mut self, key: &Key, cx: &mut Context<'_>) -> Acquire { // check limits - if self.limit > 0 && self.acquired >= self.limit { + if self.config.limit > 0 && self.acquired >= self.config.limit { return Acquire::NotAvailable; } @@ -323,10 +315,10 @@ where let now = Instant::now(); while let Some(conn) = connections.pop_back() { // check if it still usable - if (now - conn.used) > self.conn_keep_alive - || (now - conn.created) > self.conn_lifetime + if (now - conn.used) > self.config.conn_keep_alive + || (now - conn.created) > self.config.conn_lifetime { - if let Some(timeout) = self.disconnect_timeout { + if let Some(timeout) = self.config.disconnect_timeout { if let ConnectionType::H1(io) = conn.io { actix_rt::spawn(CloseConnection::new(io, timeout)) } @@ -338,7 +330,7 @@ where match Pin::new(s).poll_read(cx, &mut buf) { Poll::Pending => (), Poll::Ready(Ok(n)) if n > 0 => { - if let Some(timeout) = self.disconnect_timeout { + if let Some(timeout) = self.config.disconnect_timeout { if let ConnectionType::H1(io) = io { actix_rt::spawn(CloseConnection::new( io, timeout, @@ -372,7 +364,7 @@ where fn release_close(&mut self, io: ConnectionType) { self.acquired -= 1; - if let Some(timeout) = self.disconnect_timeout { + if let Some(timeout) = self.config.disconnect_timeout { if let ConnectionType::H1(io) = io { actix_rt::spawn(CloseConnection::new(io, timeout)) } @@ -381,7 +373,7 @@ where } fn check_availibility(&self) { - if !self.waiters_queue.is_empty() && self.acquired < self.limit { + if !self.waiters_queue.is_empty() && self.acquired < self.config.limit { self.waker.wake(); } } @@ -480,6 +472,7 @@ where tx, this.inner.clone(), this.connector.call(connect), + inner.config.clone(), ); } } @@ -506,6 +499,7 @@ where >, rx: Option, ConnectError>>>, inner: Option>>>, + config: ConnectorConfig, } impl OpenWaitingConnection @@ -518,6 +512,7 @@ where rx: oneshot::Sender, ConnectError>>, inner: Rc>>, fut: F, + config: ConnectorConfig, ) { actix_rt::spawn(OpenWaitingConnection { key, @@ -525,6 +520,7 @@ where h2: None, rx: Some(rx), inner: Some(inner), + config, }) } } @@ -594,7 +590,7 @@ where ))); Poll::Ready(()) } else { - *this.h2 = Some(handshake(io).boxed_local()); + *this.h2 = Some(handshake(io, this.config).boxed_local()); self.poll(cx) } } diff --git a/awc/CHANGES.md b/awc/CHANGES.md index d410ae514..1d6e03708 100644 --- a/awc/CHANGES.md +++ b/awc/CHANGES.md @@ -1,5 +1,11 @@ # Changes +## [NEXT] + +* ClientBuilder accepts initial_window_size and initial_connection_window_size HTTP2 configuration + +* ClientBuilder allowing to set max_http_version to limit HTTP version to be used + ## [1.0.1] - 2019-12-15 * Fix compilation with default features off diff --git a/awc/src/builder.rs b/awc/src/builder.rs index 7bd0171ec..2b2e5df9f 100644 --- a/awc/src/builder.rs +++ b/awc/src/builder.rs @@ -4,11 +4,11 @@ use std::fmt; use std::rc::Rc; use std::time::Duration; -use actix_http::client::{Connect, ConnectError, Connection, Connector}; -use actix_http::http::{header, Error as HttpError, HeaderMap, HeaderName}; +use actix_http::client::{Connect as HttpConnect, ConnectError, Connection, Connector}; +use actix_http::http::{header, Error as HttpError, HeaderMap, HeaderName, self}; use actix_service::Service; -use crate::connect::ConnectorWrapper; +use crate::connect::{ConnectorWrapper, Connect}; use crate::{Client, ClientConfig}; /// An HTTP Client builder @@ -16,10 +16,15 @@ use crate::{Client, ClientConfig}; /// This type can be used to construct an instance of `Client` through a /// builder-like pattern. pub struct ClientBuilder { - config: ClientConfig, default_headers: bool, allow_redirects: bool, max_redirects: usize, + max_http_version: Option, + stream_window_size: Option, + conn_window_size: Option, + headers: HeaderMap, + timeout: Option, + connector: Option>>, } impl Default for ClientBuilder { @@ -34,25 +39,24 @@ impl ClientBuilder { default_headers: true, allow_redirects: true, max_redirects: 10, - config: ClientConfig { - headers: HeaderMap::new(), - timeout: Some(Duration::from_secs(5)), - connector: RefCell::new(Box::new(ConnectorWrapper( - Connector::new().finish(), - ))), - }, + headers: HeaderMap::new(), + timeout: Some(Duration::from_secs(5)), + connector: None, + max_http_version: None, + stream_window_size: None, + conn_window_size: None, } } /// Use custom connector service. pub fn connector(mut self, connector: T) -> Self where - T: Service + 'static, + T: Service + 'static, T::Response: Connection, ::Future: 'static, T::Future: 'static, { - self.config.connector = RefCell::new(Box::new(ConnectorWrapper(connector))); + self.connector = Some(RefCell::new(Box::new(ConnectorWrapper(connector)))); self } @@ -61,13 +65,13 @@ impl ClientBuilder { /// Request timeout is the total time before a response must be received. /// Default value is 5 seconds. pub fn timeout(mut self, timeout: Duration) -> Self { - self.config.timeout = Some(timeout); + self.timeout = Some(timeout); self } /// Disable request timeout. pub fn disable_timeout(mut self) -> Self { - self.config.timeout = None; + self.timeout = None; self } @@ -79,6 +83,31 @@ impl ClientBuilder { self } + /// Maximum supported http major version + /// Supported versions http/1.1, http/2 + pub fn max_http_version(mut self, val: http::Version) -> Self { + self.max_http_version = Some(val); + self + } + + /// Indicates the initial window size (in octets) for + /// HTTP2 stream-level flow control for received data. + /// + /// The default value is 65,535 and is good for APIs, but not for big objects. + pub fn initial_window_size(mut self, size: u32) -> Self { + self.stream_window_size = Some(size); + self + } + + /// Indicates the initial window size (in octets) for + /// HTTP2 connection-level flow control for received data. + /// + /// The default value is 65,535 and is good for APIs, but not for big objects. + pub fn initial_connection_window_size(mut self, size: u32) -> Self { + self.conn_window_size = Some(size); + self + } + /// Set max number of redirects. /// /// Max redirects is set to 10 by default. @@ -106,7 +135,7 @@ impl ClientBuilder { match HeaderName::try_from(key) { Ok(key) => match value.try_into() { Ok(value) => { - self.config.headers.append(key, value); + self.headers.append(key, value); } Err(e) => log::error!("Header value error: {:?}", e), }, @@ -140,7 +169,27 @@ impl ClientBuilder { /// Finish build process and create `Client` instance. pub fn finish(self) -> Client { - Client(Rc::new(self.config)) + let connector = if let Some(connector) = self.connector { + connector + } else { + let mut connector = Connector::new(); + if let Some(val) = self.max_http_version { + connector = connector.max_http_version(val) + }; + if let Some(val) = self.conn_window_size { + connector = connector.initial_connection_window_size(val) + }; + if let Some(val) = self.stream_window_size { + connector = connector.initial_window_size(val) + }; + RefCell::new(Box::new(ConnectorWrapper(connector.finish())) as Box) + }; + let config = ClientConfig { + headers: self.headers, + timeout: self.timeout, + connector, + }; + Client(Rc::new(config)) } } @@ -153,7 +202,6 @@ mod tests { let client = ClientBuilder::new().basic_auth("username", Some("password")); assert_eq!( client - .config .headers .get(header::AUTHORIZATION) .unwrap() @@ -165,7 +213,6 @@ mod tests { let client = ClientBuilder::new().basic_auth("username", None); assert_eq!( client - .config .headers .get(header::AUTHORIZATION) .unwrap() @@ -180,7 +227,6 @@ mod tests { let client = ClientBuilder::new().bearer_auth("someS3cr3tAutht0k3n"); assert_eq!( client - .config .headers .get(header::AUTHORIZATION) .unwrap() diff --git a/awc/tests/test_connector.rs b/awc/tests/test_connector.rs new file mode 100644 index 000000000..8b295cda7 --- /dev/null +++ b/awc/tests/test_connector.rs @@ -0,0 +1,61 @@ +#![cfg(feature = "openssl")] +use actix_http::HttpService; +use actix_http_test::test_server; +use actix_service::{map_config, ServiceFactory}; +use actix_web::http::Version; +use actix_web::{dev::AppConfig, web, App, HttpResponse}; +use open_ssl::ssl::{SslAcceptor, SslConnector, SslFiletype, SslMethod, SslVerifyMode}; + +fn ssl_acceptor() -> SslAcceptor { + // load ssl keys + let mut builder = SslAcceptor::mozilla_intermediate(SslMethod::tls()).unwrap(); + builder + .set_private_key_file("../tests/key.pem", SslFiletype::PEM) + .unwrap(); + builder + .set_certificate_chain_file("../tests/cert.pem") + .unwrap(); + builder.set_alpn_select_callback(|_, protos| { + const H2: &[u8] = b"\x02h2"; + if protos.windows(3).any(|window| window == H2) { + Ok(b"h2") + } else { + Err(open_ssl::ssl::AlpnError::NOACK) + } + }); + builder.set_alpn_protos(b"\x02h2").unwrap(); + builder.build() +} + +#[actix_rt::test] +async fn test_connection_window_size() { + let srv = test_server(move || { + HttpService::build() + .h2(map_config( + App::new().service( + web::resource("/").route(web::to(|| HttpResponse::Ok())), + ), + |_| AppConfig::default(), + )) + .openssl(ssl_acceptor()) + .map_err(|_| ()) + }); + + // disable ssl verification + let mut builder = SslConnector::builder(SslMethod::tls()).unwrap(); + builder.set_verify(SslVerifyMode::NONE); + let _ = builder + .set_alpn_protos(b"\x02h2\x08http/1.1") + .map_err(|e| log::error!("Can not set alpn protocol: {:?}", e)); + + let client = awc::Client::build() + .connector(awc::Connector::new().ssl(builder.build()).finish()) + .initial_window_size(100) + .initial_connection_window_size(100) + .finish(); + + let request = client.get(srv.surl("/")).send(); + let response = request.await.unwrap(); + assert!(response.status().is_success()); + assert_eq!(response.version(), Version::HTTP_2); +} From cf721c5fff098af5d45ac5a1680ef421fc0f1bf4 Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Sun, 8 Mar 2020 00:43:01 +0900 Subject: [PATCH 07/27] Update README example --- actix-http/README.md | 39 +++++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/actix-http/README.md b/actix-http/README.md index d75e822ba..9acad3e6d 100644 --- a/actix-http/README.md +++ b/actix-http/README.md @@ -14,19 +14,34 @@ Actix http ```rust // see examples/framed_hello.rs for complete list of used crates. -extern crate actix_http; -use actix_http::{h1, Response, ServiceConfig}; +use std::{env, io}; -fn main() { - Server::new().bind("framed_hello", "127.0.0.1:8080", || { - IntoFramed::new(|| h1::Codec::new(ServiceConfig::default())) // <- create h1 codec - .and_then(TakeItem::new().map_err(|_| ())) // <- read one request - .and_then(|(_req, _framed): (_, Framed<_, _>)| { // <- send response and close conn - SendResponse::send(_framed, Response::Ok().body("Hello world!")) - .map_err(|_| ()) - .map(|_| ()) - }) - }).unwrap().run(); +use actix_http::{HttpService, Response}; +use actix_server::Server; +use futures::future; +use http::header::HeaderValue; +use log::info; + +#[actix_rt::main] +async fn main() -> io::Result<()> { + env::set_var("RUST_LOG", "hello_world=info"); + env_logger::init(); + + Server::build() + .bind("hello-world", "127.0.0.1:8080", || { + HttpService::build() + .client_timeout(1000) + .client_disconnect(1000) + .finish(|_req| { + info!("{:?}", _req); + let mut res = Response::Ok(); + res.header("x-head", HeaderValue::from_static("dummy value!")); + future::ok::<_, ()>(res.body("Hello world!")) + }) + .tcp() + })? + .run() + .await } ``` From 7172885beb1edef4985157d6f9abd5c726d3af99 Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Sun, 8 Mar 2020 00:43:17 +0900 Subject: [PATCH 08/27] Update changelog --- actix-http/CHANGES.md | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/actix-http/CHANGES.md b/actix-http/CHANGES.md index ccfdc81d6..fb1c3a329 100644 --- a/actix-http/CHANGES.md +++ b/actix-http/CHANGES.md @@ -1,16 +1,20 @@ # Changes -## [2.0.0-alpha.2] - someday +## [2.0.0-alpha.2] - 2020-03-07 ### Changed -* Update `actix-connect` and `actix-tls` dependency to 2.0.0-alpha.1 +* Update `actix-connect` and `actix-tls` dependency to 2.0.0-alpha.1. [#1395] -* Change default initial window size and connection window size for HTTP2 to 2MB and 1MB respectively to improve download speed for awc when downloading large objects. +* Change default initial window size and connection window size for HTTP2 to 2MB and 1MB respectively + to improve download speed for awc when downloading large objects. [#1394] -* client::Connector accepts initial_window_size and initial_connection_window_size HTTP2 configuration +* client::Connector accepts initial_window_size and initial_connection_window_size HTTP2 configuration. [#1394] -* client::Connector allowing to set max_http_version to limit HTTP version to be used +* client::Connector allowing to set max_http_version to limit HTTP version to be used. [#1394] + +[#1394]: https://github.com/actix/actix-web/pull/1394 +[#1395]: https://github.com/actix/actix-web/pull/1395 ## [2.0.0-alpha.1] - 2020-02-27 From 6f63acaf01cacf1b36f622f0177a58c613656552 Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Sun, 8 Mar 2020 00:48:45 +0900 Subject: [PATCH 09/27] Bump up to 2.0.0-alpha.2 --- actix-http/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/actix-http/Cargo.toml b/actix-http/Cargo.toml index df9653aa3..c8b6d7d7d 100644 --- a/actix-http/Cargo.toml +++ b/actix-http/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "actix-http" -version = "2.0.0-alpha.1" +version = "2.0.0-alpha.2" authors = ["Nikolay Kim "] description = "Actix http primitives" readme = "README.md" From 7941594f94545d0a4b3a4e4a86faa9fcc8b2dfb9 Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Sun, 8 Mar 2020 00:50:20 +0900 Subject: [PATCH 10/27] Update `actix-http` dependency --- Cargo.toml | 2 +- actix-files/Cargo.toml | 2 +- actix-framed/Cargo.toml | 2 +- actix-multipart/Cargo.toml | 2 +- actix-web-actors/Cargo.toml | 2 +- awc/Cargo.toml | 4 ++-- test-server/Cargo.toml | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index fa29c225f..0cb0506ca 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -71,7 +71,7 @@ actix-threadpool = "0.3.1" actix-tls = "2.0.0-alpha.1" actix-web-codegen = "0.2.0" -actix-http = "2.0.0-alpha.1" +actix-http = "2.0.0-alpha.2" awc = { version = "1.0.1", default-features = false } bytes = "0.5.3" diff --git a/actix-files/Cargo.toml b/actix-files/Cargo.toml index 269ea5371..c37d023f6 100644 --- a/actix-files/Cargo.toml +++ b/actix-files/Cargo.toml @@ -19,7 +19,7 @@ path = "src/lib.rs" [dependencies] actix-web = { version = "2.0.0-rc", default-features = false } -actix-http = "2.0.0-alpha.1" +actix-http = "2.0.0-alpha.2" actix-service = "1.0.1" bitflags = "1" bytes = "0.5.3" diff --git a/actix-framed/Cargo.toml b/actix-framed/Cargo.toml index 133b8083d..4389fe69b 100644 --- a/actix-framed/Cargo.toml +++ b/actix-framed/Cargo.toml @@ -23,7 +23,7 @@ actix-codec = "0.2.0" actix-service = "1.0.1" actix-router = "0.2.1" actix-rt = "1.0.0" -actix-http = "2.0.0-alpha.1" +actix-http = "2.0.0-alpha.2" bytes = "0.5.3" futures = "0.3.1" diff --git a/actix-multipart/Cargo.toml b/actix-multipart/Cargo.toml index a1d91c6a4..3c8fe6de1 100644 --- a/actix-multipart/Cargo.toml +++ b/actix-multipart/Cargo.toml @@ -29,4 +29,4 @@ twoway = "0.2" [dev-dependencies] actix-rt = "1.0.0" -actix-http = "2.0.0-alpha.1" +actix-http = "2.0.0-alpha.2" diff --git a/actix-web-actors/Cargo.toml b/actix-web-actors/Cargo.toml index 333edb8c0..7941e192c 100644 --- a/actix-web-actors/Cargo.toml +++ b/actix-web-actors/Cargo.toml @@ -18,7 +18,7 @@ path = "src/lib.rs" [dependencies] actix = "0.10.0-alpha.1" actix-web = "2.0.0" -actix-http = "2.0.0-alpha.1" +actix-http = "2.0.0-alpha.2" actix-codec = "0.2.0" bytes = "0.5.2" futures = "0.3.1" diff --git a/awc/Cargo.toml b/awc/Cargo.toml index d27615f7a..efbe0abd6 100644 --- a/awc/Cargo.toml +++ b/awc/Cargo.toml @@ -36,7 +36,7 @@ compress = ["actix-http/compress"] [dependencies] actix-codec = "0.2.0" actix-service = "1.0.1" -actix-http = "2.0.0-alpha.1" +actix-http = "2.0.0-alpha.2" actix-rt = "1.0.0" base64 = "0.11" @@ -56,7 +56,7 @@ rust-tls = { version = "0.17.0", package="rustls", optional = true, features = [ [dev-dependencies] actix-connect = { version = "2.0.0-alpha.1", features=["openssl"] } actix-web = { version = "2.0.0", features=["openssl"] } -actix-http = { version = "2.0.0-alpha.1", features=["openssl"] } +actix-http = { version = "2.0.0-alpha.2", features=["openssl"] } actix-http-test = { version = "1.0.0", features=["openssl"] } actix-utils = "1.0.3" actix-server = "1.0.0" diff --git a/test-server/Cargo.toml b/test-server/Cargo.toml index ba8e1c9ea..894099720 100644 --- a/test-server/Cargo.toml +++ b/test-server/Cargo.toml @@ -56,4 +56,4 @@ open-ssl = { version="0.10", package="openssl", optional = true } [dev-dependencies] actix-web = "2.0.0" -actix-http = "2.0.0-alpha.1" +actix-http = "2.0.0-alpha.2" From 0d5646a8b6f870b3182033313b644c613a0f667f Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Sun, 8 Mar 2020 00:52:39 +0900 Subject: [PATCH 11/27] Run rustfmt --- actix-http/src/client/connector.rs | 10 +++++----- actix-http/src/h1/dispatcher.rs | 3 ++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/actix-http/src/client/connector.rs b/actix-http/src/client/connector.rs index adb88bbed..e1aed6382 100644 --- a/actix-http/src/client/connector.rs +++ b/actix-http/src/client/connector.rs @@ -78,8 +78,7 @@ impl Connector<(), ()> { // Build Ssl connector with openssl, based on supplied alpn protocols #[cfg(feature = "openssl")] - fn build_ssl(protocols: Vec>) -> SslConnector - { + fn build_ssl(protocols: Vec>) -> SslConnector { use actix_connect::ssl::openssl::SslMethod; use bytes::{BufMut, BytesMut}; @@ -98,8 +97,7 @@ impl Connector<(), ()> { // Build Ssl connector with rustls, based on supplied alpn protocols #[cfg(all(not(feature = "openssl"), feature = "rustls"))] - fn build_ssl(protocols: Vec>) -> SslConnector - { + fn build_ssl(protocols: Vec>) -> SslConnector { let mut config = ClientConfig::new(); config.set_protocols(&protocols); config @@ -169,7 +167,9 @@ where let versions = match val { http::Version::HTTP_11 => vec![b"http/1.1".to_vec()], http::Version::HTTP_2 => vec![b"h2".to_vec(), b"http/1.1".to_vec()], - _ => unimplemented!("actix-http:client: supported versions http/1.1, http/2"), + _ => { + unimplemented!("actix-http:client: supported versions http/1.1, http/2") + } }; self.ssl = Connector::build_ssl(versions); self diff --git a/actix-http/src/h1/dispatcher.rs b/actix-http/src/h1/dispatcher.rs index ffdcd8d9b..ec01261e5 100644 --- a/actix-http/src/h1/dispatcher.rs +++ b/actix-http/src/h1/dispatcher.rs @@ -395,7 +395,8 @@ where Poll::Ready(Ok(req)) => { self.as_mut().send_continue(); this = self.as_mut().project(); - this.state.set(State::ServiceCall(Box::pin(this.service.call(req)))); + this.state + .set(State::ServiceCall(Box::pin(this.service.call(req)))); continue; } Poll::Ready(Err(e)) => { From 6b626c7d7762b8b19122618b08d93d18cd07422c Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Sun, 1 Mar 2020 10:44:26 +0900 Subject: [PATCH 12/27] dev-deps: Update `env_logger` to 0.7 --- awc/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/awc/Cargo.toml b/awc/Cargo.toml index efbe0abd6..1db869f8a 100644 --- a/awc/Cargo.toml +++ b/awc/Cargo.toml @@ -64,5 +64,5 @@ actix-tls = { version = "2.0.0-alpha.1", features=["openssl", "rustls"] } brotli2 = "0.3.2" flate2 = "1.0.13" futures = "0.3.1" -env_logger = "0.6" +env_logger = "0.7" webpki = "0.21" From 294523a32fc58f01ba37ad3bd7f36498f8611a6c Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Sun, 1 Mar 2020 10:45:26 +0900 Subject: [PATCH 13/27] Bump up to 2.0.0-alpha.1 --- awc/CHANGES.md | 5 +++-- awc/Cargo.toml | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/awc/CHANGES.md b/awc/CHANGES.md index 1d6e03708..b3df19e56 100644 --- a/awc/CHANGES.md +++ b/awc/CHANGES.md @@ -1,9 +1,10 @@ # Changes -## [NEXT] +## [2.0.0-alpha.1] - 2020-03-08 +* Update `actix-http` dependency to 2.0.0-alpha.2 +* Update `rustls` dependency to 0.17 * ClientBuilder accepts initial_window_size and initial_connection_window_size HTTP2 configuration - * ClientBuilder allowing to set max_http_version to limit HTTP version to be used ## [1.0.1] - 2019-12-15 diff --git a/awc/Cargo.toml b/awc/Cargo.toml index 1db869f8a..23c22e76e 100644 --- a/awc/Cargo.toml +++ b/awc/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "awc" -version = "1.0.1" +version = "2.0.0-alpha.1" authors = ["Nikolay Kim "] description = "Actix http client." readme = "README.md" From 6f33b7ea4248e2286de295b42aef95a716ad9d95 Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Sun, 1 Mar 2020 10:47:24 +0900 Subject: [PATCH 14/27] Update `awc` dependency --- Cargo.toml | 2 +- test-server/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 0cb0506ca..44e7f9aef 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -72,7 +72,7 @@ actix-tls = "2.0.0-alpha.1" actix-web-codegen = "0.2.0" actix-http = "2.0.0-alpha.2" -awc = { version = "1.0.1", default-features = false } +awc = { version = "2.0.0-alpha.1", default-features = false } bytes = "0.5.3" derive_more = "0.99.2" diff --git a/test-server/Cargo.toml b/test-server/Cargo.toml index 894099720..32efafd48 100644 --- a/test-server/Cargo.toml +++ b/test-server/Cargo.toml @@ -37,7 +37,7 @@ actix-utils = "1.0.3" actix-rt = "1.0.0" actix-server = "1.0.0" actix-testing = "1.0.0" -awc = "1.0.1" +awc = "2.0.0-alpha.1" base64 = "0.11" bytes = "0.5.3" From b93e1555ec63e482763ae5d1accc4a36ae508c66 Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Sun, 8 Mar 2020 15:23:38 +0900 Subject: [PATCH 15/27] Update `actix-connect` to 2.0.0-alpha.2 --- actix-framed/Cargo.toml | 2 +- actix-http/Cargo.toml | 4 ++-- awc/Cargo.toml | 2 +- test-server/CHANGES.md | 2 +- test-server/Cargo.toml | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/actix-framed/Cargo.toml b/actix-framed/Cargo.toml index 4389fe69b..adcda1422 100644 --- a/actix-framed/Cargo.toml +++ b/actix-framed/Cargo.toml @@ -32,6 +32,6 @@ log = "0.4" [dev-dependencies] actix-server = "1.0.0" -actix-connect = { version = "2.0.0-alpha.1", features=["openssl"] } +actix-connect = { version = "2.0.0-alpha.2", features=["openssl"] } actix-http-test = { version = "1.0.0", features=["openssl"] } actix-utils = "1.0.3" diff --git a/actix-http/Cargo.toml b/actix-http/Cargo.toml index c8b6d7d7d..e78c74624 100644 --- a/actix-http/Cargo.toml +++ b/actix-http/Cargo.toml @@ -45,7 +45,7 @@ actors = ["actix"] [dependencies] actix-service = "1.0.5" actix-codec = "0.2.0" -actix-connect = "2.0.0-alpha.1" +actix-connect = "2.0.0-alpha.2" actix-utils = "1.0.6" actix-rt = "1.0.0" actix-threadpool = "0.3.1" @@ -94,7 +94,7 @@ fail-ure = { version = "0.1.5", package="failure", optional = true } [dev-dependencies] actix-server = "1.0.1" -actix-connect = { version = "2.0.0-alpha.1", features=["openssl"] } +actix-connect = { version = "2.0.0-alpha.2", features=["openssl"] } actix-http-test = { version = "1.0.0", features=["openssl"] } actix-tls = { version = "2.0.0-alpha.1", features=["openssl"] } criterion = "0.3" diff --git a/awc/Cargo.toml b/awc/Cargo.toml index 23c22e76e..5f4b493f8 100644 --- a/awc/Cargo.toml +++ b/awc/Cargo.toml @@ -54,7 +54,7 @@ open-ssl = { version="0.10", package="openssl", optional = true } rust-tls = { version = "0.17.0", package="rustls", optional = true, features = ["dangerous_configuration"] } [dev-dependencies] -actix-connect = { version = "2.0.0-alpha.1", features=["openssl"] } +actix-connect = { version = "2.0.0-alpha.2", features=["openssl"] } actix-web = { version = "2.0.0", features=["openssl"] } actix-http = { version = "2.0.0-alpha.2", features=["openssl"] } actix-http-test = { version = "1.0.0", features=["openssl"] } diff --git a/test-server/CHANGES.md b/test-server/CHANGES.md index 3a990a594..4a1a0cfcd 100644 --- a/test-server/CHANGES.md +++ b/test-server/CHANGES.md @@ -3,7 +3,7 @@ ## [Unreleased] - 2020-xx-xx * Update the `time` dependency to 0.2.7 -* Update `actix-connect` dependency to 2.0.0-alpha.1 +* Update `actix-connect` dependency to 2.0.0-alpha.2 ## [1.0.0] - 2019-12-13 diff --git a/test-server/Cargo.toml b/test-server/Cargo.toml index 32efafd48..c34446fc8 100644 --- a/test-server/Cargo.toml +++ b/test-server/Cargo.toml @@ -32,7 +32,7 @@ openssl = ["open-ssl", "awc/openssl"] [dependencies] actix-service = "1.0.1" actix-codec = "0.2.0" -actix-connect = "2.0.0-alpha.1" +actix-connect = "2.0.0-alpha.2" actix-utils = "1.0.3" actix-rt = "1.0.0" actix-server = "1.0.0" From a9a475d5554a4cb891c3d3e6a019a6249d997f64 Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Sun, 8 Mar 2020 16:42:26 +0900 Subject: [PATCH 16/27] Make `test_server` `async` fn --- test-server/CHANGES.md | 1 + test-server/src/lib.rs | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/test-server/CHANGES.md b/test-server/CHANGES.md index 4a1a0cfcd..35552030c 100644 --- a/test-server/CHANGES.md +++ b/test-server/CHANGES.md @@ -4,6 +4,7 @@ * Update the `time` dependency to 0.2.7 * Update `actix-connect` dependency to 2.0.0-alpha.2 +* Make `test_server` `async` fn. ## [1.0.0] - 2019-12-13 diff --git a/test-server/src/lib.rs b/test-server/src/lib.rs index 27326c67a..c36cc706f 100644 --- a/test-server/src/lib.rs +++ b/test-server/src/lib.rs @@ -43,7 +43,7 @@ pub use actix_testing::*; /// assert!(response.status().is_success()); /// } /// ``` -pub fn test_server>(factory: F) -> TestServer { +pub async fn test_server>(factory: F) -> TestServer { let (tx, rx) = mpsc::channel(); // run server in separate thread @@ -92,7 +92,7 @@ pub fn test_server>(factory: F) -> TestServer { Client::build().connector(connector).finish() }; - actix_connect::start_default_resolver(); + actix_connect::start_default_resolver().await.unwrap(); TestServer { addr, From e718f6512183d4c3d2515bfc378874d2c32dd91d Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Sun, 8 Mar 2020 16:42:45 +0900 Subject: [PATCH 17/27] Update tests --- actix-framed/tests/test_server.rs | 6 ++- actix-http/tests/test_client.rs | 9 ++-- actix-http/tests/test_openssl.rs | 41 +++++++++++------ actix-http/tests/test_rustls.rs | 47 +++++++++++++------- actix-http/tests/test_server.rs | 74 ++++++++++++++++++++----------- actix-http/tests/test_ws.rs | 3 +- awc/src/builder.rs | 8 ++-- awc/tests/test_client.rs | 33 +++++++------- awc/tests/test_connector.rs | 8 ++-- awc/tests/test_rustls_client.rs | 3 +- awc/tests/test_ssl_client.rs | 3 +- awc/tests/test_ws.rs | 3 +- 12 files changed, 151 insertions(+), 87 deletions(-) diff --git a/actix-framed/tests/test_server.rs b/actix-framed/tests/test_server.rs index 7d6fc08a6..150fc10f3 100644 --- a/actix-framed/tests/test_server.rs +++ b/actix-framed/tests/test_server.rs @@ -47,7 +47,8 @@ async fn test_simple() { ) .finish(|_| future::ok::<_, Error>(Response::NotFound())) .tcp() - }); + }) + .await; assert!(srv.ws_at("/test").await.is_err()); @@ -108,7 +109,8 @@ async fn test_service() { .map_err(|_| ()), ), ) - }); + }) + .await; // non ws request let res = srv.get("/index.html").send().await.unwrap(); diff --git a/actix-http/tests/test_client.rs b/actix-http/tests/test_client.rs index 9da3b04a2..5347971a6 100644 --- a/actix-http/tests/test_client.rs +++ b/actix-http/tests/test_client.rs @@ -33,7 +33,8 @@ async fn test_h1_v2() { HttpService::build() .finish(|_| future::ok::<_, ()>(Response::Ok().body(STR))) .tcp() - }); + }) + .await; let response = srv.get("/").send().await.unwrap(); assert!(response.status().is_success()); @@ -61,7 +62,8 @@ async fn test_connection_close() { .finish(|_| ok::<_, ()>(Response::Ok().body(STR))) .tcp() .map(|_| ()) - }); + }) + .await; let response = srv.get("/").force_close().send().await.unwrap(); assert!(response.status().is_success()); @@ -80,7 +82,8 @@ async fn test_with_query_parameter() { }) .tcp() .map(|_| ()) - }); + }) + .await; let request = srv.request(http::Method::GET, srv.url("/?qp=5")); let response = request.send().await.unwrap(); diff --git a/actix-http/tests/test_openssl.rs b/actix-http/tests/test_openssl.rs index 77caa045b..4af3a0a47 100644 --- a/actix-http/tests/test_openssl.rs +++ b/actix-http/tests/test_openssl.rs @@ -67,7 +67,8 @@ async fn test_h2() -> io::Result<()> { .h2(|_| ok::<_, Error>(Response::Ok().finish())) .openssl(ssl_acceptor()) .map_err(|_| ()) - }); + }) + .await; let response = srv.sget("/").send().await.unwrap(); assert!(response.status().is_success()); @@ -85,7 +86,8 @@ async fn test_h2_1() -> io::Result<()> { }) .openssl(ssl_acceptor()) .map_err(|_| ()) - }); + }) + .await; let response = srv.sget("/").send().await.unwrap(); assert!(response.status().is_success()); @@ -103,7 +105,8 @@ async fn test_h2_body() -> io::Result<()> { }) .openssl(ssl_acceptor()) .map_err(|_| ()) - }); + }) + .await; let response = srv.sget("/").send_body(data.clone()).await.unwrap(); assert!(response.status().is_success()); @@ -131,7 +134,8 @@ async fn test_h2_content_length() { }) .openssl(ssl_acceptor()) .map_err(|_| ()) - }); + }) + .await; let header = HeaderName::from_static("content-length"); let value = HeaderValue::from_static("0"); @@ -192,7 +196,7 @@ async fn test_h2_headers() { }) .openssl(ssl_acceptor()) .map_err(|_| ()) - }); + }).await; let response = srv.sget("/").send().await.unwrap(); assert!(response.status().is_success()); @@ -231,7 +235,8 @@ async fn test_h2_body2() { .h2(|_| ok::<_, ()>(Response::Ok().body(STR))) .openssl(ssl_acceptor()) .map_err(|_| ()) - }); + }) + .await; let response = srv.sget("/").send().await.unwrap(); assert!(response.status().is_success()); @@ -248,7 +253,8 @@ async fn test_h2_head_empty() { .finish(|_| ok::<_, ()>(Response::Ok().body(STR))) .openssl(ssl_acceptor()) .map_err(|_| ()) - }); + }) + .await; let response = srv.shead("/").send().await.unwrap(); assert!(response.status().is_success()); @@ -273,7 +279,8 @@ async fn test_h2_head_binary() { }) .openssl(ssl_acceptor()) .map_err(|_| ()) - }); + }) + .await; let response = srv.shead("/").send().await.unwrap(); assert!(response.status().is_success()); @@ -295,7 +302,8 @@ async fn test_h2_head_binary2() { .h2(|_| ok::<_, ()>(Response::Ok().body(STR))) .openssl(ssl_acceptor()) .map_err(|_| ()) - }); + }) + .await; let response = srv.shead("/").send().await.unwrap(); assert!(response.status().is_success()); @@ -318,7 +326,8 @@ async fn test_h2_body_length() { }) .openssl(ssl_acceptor()) .map_err(|_| ()) - }); + }) + .await; let response = srv.sget("/").send().await.unwrap(); assert!(response.status().is_success()); @@ -342,7 +351,8 @@ async fn test_h2_body_chunked_explicit() { }) .openssl(ssl_acceptor()) .map_err(|_| ()) - }); + }) + .await; let response = srv.sget("/").send().await.unwrap(); assert!(response.status().is_success()); @@ -369,7 +379,8 @@ async fn test_h2_response_http_error_handling() { })) .openssl(ssl_acceptor()) .map_err(|_| ()) - }); + }) + .await; let response = srv.sget("/").send().await.unwrap(); assert_eq!(response.status(), StatusCode::INTERNAL_SERVER_ERROR); @@ -386,7 +397,8 @@ async fn test_h2_service_error() { .h2(|_| err::(ErrorBadRequest("error"))) .openssl(ssl_acceptor()) .map_err(|_| ()) - }); + }) + .await; let response = srv.sget("/").send().await.unwrap(); assert_eq!(response.status(), StatusCode::BAD_REQUEST); @@ -407,7 +419,8 @@ async fn test_h2_on_connect() { }) .openssl(ssl_acceptor()) .map_err(|_| ()) - }); + }) + .await; let response = srv.sget("/").send().await.unwrap(); assert!(response.status().is_success()); diff --git a/actix-http/tests/test_rustls.rs b/actix-http/tests/test_rustls.rs index 933a6c894..1c5583b08 100644 --- a/actix-http/tests/test_rustls.rs +++ b/actix-http/tests/test_rustls.rs @@ -45,7 +45,8 @@ async fn test_h1() -> io::Result<()> { HttpService::build() .h1(|_| future::ok::<_, Error>(Response::Ok().finish())) .rustls(ssl_acceptor()) - }); + }) + .await; let response = srv.sget("/").send().await.unwrap(); assert!(response.status().is_success()); @@ -58,7 +59,8 @@ async fn test_h2() -> io::Result<()> { HttpService::build() .h2(|_| future::ok::<_, Error>(Response::Ok().finish())) .rustls(ssl_acceptor()) - }); + }) + .await; let response = srv.sget("/").send().await.unwrap(); assert!(response.status().is_success()); @@ -75,7 +77,8 @@ async fn test_h1_1() -> io::Result<()> { future::ok::<_, Error>(Response::Ok().finish()) }) .rustls(ssl_acceptor()) - }); + }) + .await; let response = srv.sget("/").send().await.unwrap(); assert!(response.status().is_success()); @@ -92,7 +95,8 @@ async fn test_h2_1() -> io::Result<()> { future::ok::<_, Error>(Response::Ok().finish()) }) .rustls(ssl_acceptor()) - }); + }) + .await; let response = srv.sget("/").send().await.unwrap(); assert!(response.status().is_success()); @@ -109,7 +113,8 @@ async fn test_h2_body1() -> io::Result<()> { Ok::<_, Error>(Response::Ok().body(body)) }) .rustls(ssl_acceptor()) - }); + }) + .await; let response = srv.sget("/").send_body(data.clone()).await.unwrap(); assert!(response.status().is_success()); @@ -136,7 +141,8 @@ async fn test_h2_content_length() { future::ok::<_, ()>(Response::new(statuses[indx])) }) .rustls(ssl_acceptor()) - }); + }) + .await; let header = HeaderName::from_static("content-length"); let value = HeaderValue::from_static("0"); @@ -195,7 +201,7 @@ async fn test_h2_headers() { future::ok::<_, ()>(config.body(data.clone())) }) .rustls(ssl_acceptor()) - }); + }).await; let response = srv.sget("/").send().await.unwrap(); assert!(response.status().is_success()); @@ -233,7 +239,8 @@ async fn test_h2_body2() { HttpService::build() .h2(|_| future::ok::<_, ()>(Response::Ok().body(STR))) .rustls(ssl_acceptor()) - }); + }) + .await; let response = srv.sget("/").send().await.unwrap(); assert!(response.status().is_success()); @@ -249,7 +256,8 @@ async fn test_h2_head_empty() { HttpService::build() .finish(|_| ok::<_, ()>(Response::Ok().body(STR))) .rustls(ssl_acceptor()) - }); + }) + .await; let response = srv.shead("/").send().await.unwrap(); assert!(response.status().is_success()); @@ -276,7 +284,8 @@ async fn test_h2_head_binary() { ok::<_, ()>(Response::Ok().content_length(STR.len() as u64).body(STR)) }) .rustls(ssl_acceptor()) - }); + }) + .await; let response = srv.shead("/").send().await.unwrap(); assert!(response.status().is_success()); @@ -300,7 +309,8 @@ async fn test_h2_head_binary2() { HttpService::build() .h2(|_| ok::<_, ()>(Response::Ok().body(STR))) .rustls(ssl_acceptor()) - }); + }) + .await; let response = srv.shead("/").send().await.unwrap(); assert!(response.status().is_success()); @@ -325,7 +335,8 @@ async fn test_h2_body_length() { ) }) .rustls(ssl_acceptor()) - }); + }) + .await; let response = srv.sget("/").send().await.unwrap(); assert!(response.status().is_success()); @@ -348,7 +359,8 @@ async fn test_h2_body_chunked_explicit() { ) }) .rustls(ssl_acceptor()) - }); + }) + .await; let response = srv.sget("/").send().await.unwrap(); assert!(response.status().is_success()); @@ -376,7 +388,8 @@ async fn test_h2_response_http_error_handling() { })) })) .rustls(ssl_acceptor()) - }); + }) + .await; let response = srv.sget("/").send().await.unwrap(); assert_eq!(response.status(), http::StatusCode::INTERNAL_SERVER_ERROR); @@ -392,7 +405,8 @@ async fn test_h2_service_error() { HttpService::build() .h2(|_| err::(error::ErrorBadRequest("error"))) .rustls(ssl_acceptor()) - }); + }) + .await; let response = srv.sget("/").send().await.unwrap(); assert_eq!(response.status(), http::StatusCode::BAD_REQUEST); @@ -408,7 +422,8 @@ async fn test_h1_service_error() { HttpService::build() .h1(|_| err::(error::ErrorBadRequest("error"))) .rustls(ssl_acceptor()) - }); + }) + .await; let response = srv.sget("/").send().await.unwrap(); assert_eq!(response.status(), http::StatusCode::BAD_REQUEST); diff --git a/actix-http/tests/test_server.rs b/actix-http/tests/test_server.rs index a84692f9d..1ec819434 100644 --- a/actix-http/tests/test_server.rs +++ b/actix-http/tests/test_server.rs @@ -27,7 +27,8 @@ async fn test_h1() { future::ok::<_, ()>(Response::Ok().finish()) }) .tcp() - }); + }) + .await; let response = srv.get("/").send().await.unwrap(); assert!(response.status().is_success()); @@ -46,7 +47,8 @@ async fn test_h1_2() { future::ok::<_, ()>(Response::Ok().finish()) }) .tcp() - }); + }) + .await; let response = srv.get("/").send().await.unwrap(); assert!(response.status().is_success()); @@ -65,7 +67,8 @@ async fn test_expect_continue() { })) .finish(|_| future::ok::<_, ()>(Response::Ok().finish())) .tcp() - }); + }) + .await; let mut stream = net::TcpStream::connect(srv.addr()).unwrap(); let _ = stream.write_all(b"GET /test HTTP/1.1\r\nexpect: 100-continue\r\n\r\n"); @@ -95,7 +98,8 @@ async fn test_expect_continue_h1() { })) .h1(fn_service(|_| future::ok::<_, ()>(Response::Ok().finish()))) .tcp() - }); + }) + .await; let mut stream = net::TcpStream::connect(srv.addr()).unwrap(); let _ = stream.write_all(b"GET /test HTTP/1.1\r\nexpect: 100-continue\r\n\r\n"); @@ -130,7 +134,8 @@ async fn test_chunked_payload() { }) })) .tcp() - }); + }) + .await; let returned_size = { let mut stream = net::TcpStream::connect(srv.addr()).unwrap(); @@ -172,7 +177,8 @@ async fn test_slow_request() { .client_timeout(100) .finish(|_| future::ok::<_, ()>(Response::Ok().finish())) .tcp() - }); + }) + .await; let mut stream = net::TcpStream::connect(srv.addr()).unwrap(); let _ = stream.write_all(b"GET /test/tests/test HTTP/1.1\r\n"); @@ -187,7 +193,8 @@ async fn test_http1_malformed_request() { HttpService::build() .h1(|_| future::ok::<_, ()>(Response::Ok().finish())) .tcp() - }); + }) + .await; let mut stream = net::TcpStream::connect(srv.addr()).unwrap(); let _ = stream.write_all(b"GET /test/tests/test HTTP1.1\r\n"); @@ -202,7 +209,8 @@ async fn test_http1_keepalive() { HttpService::build() .h1(|_| future::ok::<_, ()>(Response::Ok().finish())) .tcp() - }); + }) + .await; let mut stream = net::TcpStream::connect(srv.addr()).unwrap(); let _ = stream.write_all(b"GET /test/tests/test HTTP/1.1\r\n\r\n"); @@ -223,7 +231,8 @@ async fn test_http1_keepalive_timeout() { .keep_alive(1) .h1(|_| future::ok::<_, ()>(Response::Ok().finish())) .tcp() - }); + }) + .await; let mut stream = net::TcpStream::connect(srv.addr()).unwrap(); let _ = stream.write_all(b"GET /test/tests/test HTTP/1.1\r\n\r\n"); @@ -243,7 +252,8 @@ async fn test_http1_keepalive_close() { HttpService::build() .h1(|_| future::ok::<_, ()>(Response::Ok().finish())) .tcp() - }); + }) + .await; let mut stream = net::TcpStream::connect(srv.addr()).unwrap(); let _ = @@ -263,7 +273,8 @@ async fn test_http10_keepalive_default_close() { HttpService::build() .h1(|_| future::ok::<_, ()>(Response::Ok().finish())) .tcp() - }); + }) + .await; let mut stream = net::TcpStream::connect(srv.addr()).unwrap(); let _ = stream.write_all(b"GET /test/tests/test HTTP/1.0\r\n\r\n"); @@ -282,7 +293,8 @@ async fn test_http10_keepalive() { HttpService::build() .h1(|_| future::ok::<_, ()>(Response::Ok().finish())) .tcp() - }); + }) + .await; let mut stream = net::TcpStream::connect(srv.addr()).unwrap(); let _ = stream @@ -309,7 +321,8 @@ async fn test_http1_keepalive_disabled() { .keep_alive(KeepAlive::Disabled) .h1(|_| future::ok::<_, ()>(Response::Ok().finish())) .tcp() - }); + }) + .await; let mut stream = net::TcpStream::connect(srv.addr()).unwrap(); let _ = stream.write_all(b"GET /test/tests/test HTTP/1.1\r\n\r\n"); @@ -344,7 +357,8 @@ async fn test_content_length() { future::ok::<_, ()>(Response::new(statuses[indx])) }) .tcp() - }); + }) + .await; let header = HeaderName::from_static("content-length"); let value = HeaderValue::from_static("0"); @@ -397,7 +411,7 @@ async fn test_h1_headers() { } future::ok::<_, ()>(builder.body(data.clone())) }).tcp() - }); + }).await; let response = srv.get("/").send().await.unwrap(); assert!(response.status().is_success()); @@ -435,7 +449,8 @@ async fn test_h1_body() { HttpService::build() .h1(|_| ok::<_, ()>(Response::Ok().body(STR))) .tcp() - }); + }) + .await; let response = srv.get("/").send().await.unwrap(); assert!(response.status().is_success()); @@ -451,7 +466,8 @@ async fn test_h1_head_empty() { HttpService::build() .h1(|_| ok::<_, ()>(Response::Ok().body(STR))) .tcp() - }); + }) + .await; let response = srv.head("/").send().await.unwrap(); assert!(response.status().is_success()); @@ -477,7 +493,8 @@ async fn test_h1_head_binary() { ok::<_, ()>(Response::Ok().content_length(STR.len() as u64).body(STR)) }) .tcp() - }); + }) + .await; let response = srv.head("/").send().await.unwrap(); assert!(response.status().is_success()); @@ -501,7 +518,8 @@ async fn test_h1_head_binary2() { HttpService::build() .h1(|_| ok::<_, ()>(Response::Ok().body(STR))) .tcp() - }); + }) + .await; let response = srv.head("/").send().await.unwrap(); assert!(response.status().is_success()); @@ -526,7 +544,8 @@ async fn test_h1_body_length() { ) }) .tcp() - }); + }) + .await; let response = srv.get("/").send().await.unwrap(); assert!(response.status().is_success()); @@ -549,7 +568,8 @@ async fn test_h1_body_chunked_explicit() { ) }) .tcp() - }); + }) + .await; let response = srv.get("/").send().await.unwrap(); assert!(response.status().is_success()); @@ -579,7 +599,8 @@ async fn test_h1_body_chunked_implicit() { ok::<_, ()>(Response::Ok().streaming(body)) }) .tcp() - }); + }) + .await; let response = srv.get("/").send().await.unwrap(); assert!(response.status().is_success()); @@ -611,7 +632,8 @@ async fn test_h1_response_http_error_handling() { ) })) .tcp() - }); + }) + .await; let response = srv.get("/").send().await.unwrap(); assert_eq!(response.status(), http::StatusCode::INTERNAL_SERVER_ERROR); @@ -627,7 +649,8 @@ async fn test_h1_service_error() { HttpService::build() .h1(|_| future::err::(error::ErrorBadRequest("error"))) .tcp() - }); + }) + .await; let response = srv.get("/").send().await.unwrap(); assert_eq!(response.status(), http::StatusCode::BAD_REQUEST); @@ -647,7 +670,8 @@ async fn test_h1_on_connect() { future::ok::<_, ()>(Response::Ok().finish()) }) .tcp() - }); + }) + .await; let response = srv.get("/").send().await.unwrap(); assert!(response.status().is_success()); diff --git a/actix-http/tests/test_ws.rs b/actix-http/tests/test_ws.rs index 7152fee48..4b4b8f089 100644 --- a/actix-http/tests/test_ws.rs +++ b/actix-http/tests/test_ws.rs @@ -93,7 +93,8 @@ async fn test_simple() { .finish(|_| future::ok::<_, ()>(Response::NotFound())) .tcp() } - }); + }) + .await; // client service let mut framed = srv.ws().await.unwrap(); diff --git a/awc/src/builder.rs b/awc/src/builder.rs index 2b2e5df9f..7cd659c38 100644 --- a/awc/src/builder.rs +++ b/awc/src/builder.rs @@ -5,10 +5,10 @@ use std::rc::Rc; use std::time::Duration; use actix_http::client::{Connect as HttpConnect, ConnectError, Connection, Connector}; -use actix_http::http::{header, Error as HttpError, HeaderMap, HeaderName, self}; +use actix_http::http::{self, header, Error as HttpError, HeaderMap, HeaderName}; use actix_service::Service; -use crate::connect::{ConnectorWrapper, Connect}; +use crate::connect::{Connect, ConnectorWrapper}; use crate::{Client, ClientConfig}; /// An HTTP Client builder @@ -182,7 +182,9 @@ impl ClientBuilder { if let Some(val) = self.stream_window_size { connector = connector.initial_window_size(val) }; - RefCell::new(Box::new(ConnectorWrapper(connector.finish())) as Box) + RefCell::new( + Box::new(ConnectorWrapper(connector.finish())) as Box + ) }; let config = ClientConfig { headers: self.headers, diff --git a/awc/tests/test_client.rs b/awc/tests/test_client.rs index 8fb04b005..449734a9f 100644 --- a/awc/tests/test_client.rs +++ b/awc/tests/test_client.rs @@ -107,17 +107,15 @@ async fn test_form() { #[actix_rt::test] async fn test_timeout() { let srv = test::start(|| { - App::new().service(web::resource("/").route(web::to(|| { - async { - actix_rt::time::delay_for(Duration::from_millis(200)).await; - Ok::<_, Error>(HttpResponse::Ok().body(STR)) - } + App::new().service(web::resource("/").route(web::to(|| async { + actix_rt::time::delay_for(Duration::from_millis(200)).await; + Ok::<_, Error>(HttpResponse::Ok().body(STR)) }))) }); let connector = awc::Connector::new() .connector(actix_connect::new_connector( - actix_connect::start_default_resolver(), + actix_connect::start_default_resolver().await.unwrap(), )) .timeout(Duration::from_secs(15)) .finish(); @@ -137,11 +135,9 @@ async fn test_timeout() { #[actix_rt::test] async fn test_timeout_override() { let srv = test::start(|| { - App::new().service(web::resource("/").route(web::to(|| { - async { - actix_rt::time::delay_for(Duration::from_millis(200)).await; - Ok::<_, Error>(HttpResponse::Ok().body(STR)) - } + App::new().service(web::resource("/").route(web::to(|| async { + actix_rt::time::delay_for(Duration::from_millis(200)).await; + Ok::<_, Error>(HttpResponse::Ok().body(STR)) }))) }); @@ -177,7 +173,8 @@ async fn test_connection_reuse() { )) .tcp(), ) - }); + }) + .await; let client = awc::Client::default(); @@ -214,7 +211,8 @@ async fn test_connection_force_close() { )) .tcp(), ) - }); + }) + .await; let client = awc::Client::default(); @@ -253,7 +251,8 @@ async fn test_connection_server_close() { )) .tcp(), ) - }); + }) + .await; let client = awc::Client::default(); @@ -291,7 +290,8 @@ async fn test_connection_wait_queue() { )) .tcp(), ) - }); + }) + .await; let client = awc::Client::build() .connector(awc::Connector::new().limit(1).finish()) @@ -339,7 +339,8 @@ async fn test_connection_wait_queue_force_close() { )) .tcp(), ) - }); + }) + .await; let client = awc::Client::build() .connector(awc::Connector::new().limit(1).finish()) diff --git a/awc/tests/test_connector.rs b/awc/tests/test_connector.rs index 8b295cda7..b352eaab4 100644 --- a/awc/tests/test_connector.rs +++ b/awc/tests/test_connector.rs @@ -32,14 +32,14 @@ async fn test_connection_window_size() { let srv = test_server(move || { HttpService::build() .h2(map_config( - App::new().service( - web::resource("/").route(web::to(|| HttpResponse::Ok())), - ), + App::new() + .service(web::resource("/").route(web::to(|| HttpResponse::Ok()))), |_| AppConfig::default(), )) .openssl(ssl_acceptor()) .map_err(|_| ()) - }); + }) + .await; // disable ssl verification let mut builder = SslConnector::builder(SslMethod::tls()).unwrap(); diff --git a/awc/tests/test_rustls_client.rs b/awc/tests/test_rustls_client.rs index 8863dfcbe..7407a33fc 100644 --- a/awc/tests/test_rustls_client.rs +++ b/awc/tests/test_rustls_client.rs @@ -72,7 +72,8 @@ async fn _test_connection_reuse_h2() { .openssl(ssl_acceptor()) .map_err(|_| ()), ) - }); + }) + .await; // disable ssl verification let mut config = ClientConfig::new(); diff --git a/awc/tests/test_ssl_client.rs b/awc/tests/test_ssl_client.rs index d3995b4be..8e128ad0c 100644 --- a/awc/tests/test_ssl_client.rs +++ b/awc/tests/test_ssl_client.rs @@ -53,7 +53,8 @@ async fn test_connection_reuse_h2() { .openssl(ssl_acceptor()) .map_err(|_| ()), ) - }); + }) + .await; // disable ssl verification let mut builder = SslConnector::builder(SslMethod::tls()).unwrap(); diff --git a/awc/tests/test_ws.rs b/awc/tests/test_ws.rs index ee937e43e..779a4301c 100644 --- a/awc/tests/test_ws.rs +++ b/awc/tests/test_ws.rs @@ -38,7 +38,8 @@ async fn test_simple() { }) .finish(|_| ok::<_, Error>(Response::NotFound())) .tcp() - }); + }) + .await; // client service let mut framed = srv.ws().await.unwrap(); From ce1e996b411bd7fa3855c6ee7a406d08fe710834 Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Wed, 11 Mar 2020 20:42:45 +0900 Subject: [PATCH 18/27] Update release date --- awc/CHANGES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/awc/CHANGES.md b/awc/CHANGES.md index b3df19e56..e6f731540 100644 --- a/awc/CHANGES.md +++ b/awc/CHANGES.md @@ -1,6 +1,6 @@ # Changes -## [2.0.0-alpha.1] - 2020-03-08 +## [2.0.0-alpha.1] - 2020-03-11 * Update `actix-http` dependency to 2.0.0-alpha.2 * Update `rustls` dependency to 0.17 From 95f9a12a5e3fc5759b4ba2f9ea474a4d7735d01e Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Thu, 12 Mar 2020 02:58:22 +0900 Subject: [PATCH 19/27] dev-deps: Update `env_logger` to 0.7 --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 44e7f9aef..3cd6a5a61 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -95,7 +95,7 @@ rust-tls = { version = "0.17.0", package = "rustls", optional = true } [dev-dependencies] actix = "0.10.0-alpha.1" rand = "0.7" -env_logger = "0.6" +env_logger = "0.7" serde_derive = "1.0" brotli2 = "0.3.2" flate2 = "1.0.13" From c147b9483290a9707253d0b5c1f0c3e7d042c08d Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Thu, 12 Mar 2020 03:03:22 +0900 Subject: [PATCH 20/27] Bump up to 3.0.0-alpha.1 --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 3cd6a5a61..4d50f50ce 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "actix-web" -version = "2.0.0" +version = "3.0.0-alpha.1" authors = ["Nikolay Kim "] description = "Actix web is a simple, pragmatic and extremely fast web framework for Rust." readme = "README.md" From 1b28a5d48bc54490096589cc08e866ffb39594f3 Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Thu, 12 Mar 2020 03:03:50 +0900 Subject: [PATCH 21/27] Update `actix-web` dependency to 3.0.0-alpha.1 --- actix-files/Cargo.toml | 4 ++-- actix-multipart/Cargo.toml | 2 +- actix-web-actors/Cargo.toml | 2 +- actix-web-codegen/Cargo.toml | 2 +- awc/Cargo.toml | 2 +- test-server/Cargo.toml | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/actix-files/Cargo.toml b/actix-files/Cargo.toml index c37d023f6..ed887e323 100644 --- a/actix-files/Cargo.toml +++ b/actix-files/Cargo.toml @@ -18,7 +18,7 @@ name = "actix_files" path = "src/lib.rs" [dependencies] -actix-web = { version = "2.0.0-rc", default-features = false } +actix-web = { version = "3.0.0-alpha.1", default-features = false } actix-http = "2.0.0-alpha.2" actix-service = "1.0.1" bitflags = "1" @@ -33,4 +33,4 @@ v_htmlescape = "0.4" [dev-dependencies] actix-rt = "1.0.0" -actix-web = { version = "2.0.0-rc", features=["openssl"] } +actix-web = { version = "3.0.0-alpha.1", features=["openssl"] } diff --git a/actix-multipart/Cargo.toml b/actix-multipart/Cargo.toml index 3c8fe6de1..e81b07cb7 100644 --- a/actix-multipart/Cargo.toml +++ b/actix-multipart/Cargo.toml @@ -16,7 +16,7 @@ name = "actix_multipart" path = "src/lib.rs" [dependencies] -actix-web = { version = "2.0.0", default-features = false } +actix-web = { version = "3.0.0-alpha.1", default-features = false } actix-service = "1.0.1" actix-utils = "1.0.3" bytes = "0.5.3" diff --git a/actix-web-actors/Cargo.toml b/actix-web-actors/Cargo.toml index 7941e192c..7e24d8c99 100644 --- a/actix-web-actors/Cargo.toml +++ b/actix-web-actors/Cargo.toml @@ -17,7 +17,7 @@ path = "src/lib.rs" [dependencies] actix = "0.10.0-alpha.1" -actix-web = "2.0.0" +actix-web = "3.0.0-alpha.1" actix-http = "2.0.0-alpha.2" actix-codec = "0.2.0" bytes = "0.5.2" diff --git a/actix-web-codegen/Cargo.toml b/actix-web-codegen/Cargo.toml index 0b926b807..42befc0dd 100644 --- a/actix-web-codegen/Cargo.toml +++ b/actix-web-codegen/Cargo.toml @@ -18,5 +18,5 @@ proc-macro2 = "^1" [dev-dependencies] actix-rt = "1.0.0" -actix-web = "2.0.0" +actix-web = "3.0.0-alpha.1" futures = "0.3.1" diff --git a/awc/Cargo.toml b/awc/Cargo.toml index 5f4b493f8..fde136eb0 100644 --- a/awc/Cargo.toml +++ b/awc/Cargo.toml @@ -55,7 +55,7 @@ rust-tls = { version = "0.17.0", package="rustls", optional = true, features = [ [dev-dependencies] actix-connect = { version = "2.0.0-alpha.2", features=["openssl"] } -actix-web = { version = "2.0.0", features=["openssl"] } +actix-web = { version = "3.0.0-alpha.1", features=["openssl"] } actix-http = { version = "2.0.0-alpha.2", features=["openssl"] } actix-http-test = { version = "1.0.0", features=["openssl"] } actix-utils = "1.0.3" diff --git a/test-server/Cargo.toml b/test-server/Cargo.toml index c34446fc8..29896898e 100644 --- a/test-server/Cargo.toml +++ b/test-server/Cargo.toml @@ -55,5 +55,5 @@ time = { version = "0.2.7", default-features = false, features = ["std"] } open-ssl = { version="0.10", package="openssl", optional = true } [dev-dependencies] -actix-web = "2.0.0" +actix-web = "3.0.0-alpha.1" actix-http = "2.0.0-alpha.2" From a6a47b95ee6ffb27d9a6ff903cfa986f02e9a6e7 Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Thu, 12 Mar 2020 03:04:31 +0900 Subject: [PATCH 22/27] Exclude `actix-cors` --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 4d50f50ce..1ab2561e7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,7 +30,7 @@ members = [ ".", "awc", "actix-http", - "actix-cors", +# "actix-cors", "actix-files", "actix-framed", # "actix-session", From 0152cedc5df4e41cd9f694ee17523b742ba67157 Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Thu, 12 Mar 2020 03:24:15 +0900 Subject: [PATCH 23/27] Update changelog --- CHANGES.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index da4a77a80..460b24f57 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,7 +1,6 @@ # Changes - -## [2.0.NEXT] - 2020-01-xx +## [3.0.0-alpha.1] - 2020-03-11 ### Added @@ -10,11 +9,13 @@ ### Changed * Use `sha-1` crate instead of unmaintained `sha1` crate -* Skip empty chunks when returning response from a `Stream` #1308 +* Skip empty chunks when returning response from a `Stream` [#1308] * Update the `time` dependency to 0.2.7 * Update `actix-tls` dependency to 2.0.0-alpha.1 * Update `rustls` dependency to 0.17 +[#1308]: https://github.com/actix/actix-web/pull/1308 + ## [2.0.0] - 2019-12-25 ### Changed From c02d3e205b68983c4033c9fe578f4ae1bfaf8e61 Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Thu, 12 Mar 2020 07:57:20 +0900 Subject: [PATCH 24/27] Clean-up metadata --- Cargo.toml | 3 --- 1 file changed, 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 1ab2561e7..6bd36279a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -111,9 +111,6 @@ actix-web = { path = "." } actix-http = { path = "actix-http" } actix-http-test = { path = "test-server" } actix-web-codegen = { path = "actix-web-codegen" } -actix-cors = { path = "actix-cors" } -actix-identity = { path = "actix-identity" } -actix-session = { path = "actix-session" } actix-files = { path = "actix-files" } actix-multipart = { path = "actix-multipart" } awc = { path = "awc" } From 51518721e531983616460578fed647bcdf9a7673 Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Thu, 12 Mar 2020 07:57:38 +0900 Subject: [PATCH 25/27] Add notes to READMEs --- actix-cors/README.md | 2 ++ actix-identity/README.md | 2 ++ actix-session/README.md | 2 ++ 3 files changed, 6 insertions(+) diff --git a/actix-cors/README.md b/actix-cors/README.md index a77f6c6d3..c860ec5ae 100644 --- a/actix-cors/README.md +++ b/actix-cors/README.md @@ -1,5 +1,7 @@ # Cors Middleware for actix web framework [![Build Status](https://travis-ci.org/actix/actix-web.svg?branch=master)](https://travis-ci.org/actix/actix-web) [![codecov](https://codecov.io/gh/actix/actix-web/branch/master/graph/badge.svg)](https://codecov.io/gh/actix/actix-web) [![crates.io](https://meritbadge.herokuapp.com/actix-cors)](https://crates.io/crates/actix-cors) [![Join the chat at https://gitter.im/actix/actix](https://badges.gitter.im/actix/actix.svg)](https://gitter.im/actix/actix?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) +**This crate moved to https://github.com/actix/actix-extras.** + ## Documentation & community resources * [User Guide](https://actix.rs/docs/) diff --git a/actix-identity/README.md b/actix-identity/README.md index 60b615c76..62a40137f 100644 --- a/actix-identity/README.md +++ b/actix-identity/README.md @@ -1,5 +1,7 @@ # Identity service for actix web framework [![Build Status](https://travis-ci.org/actix/actix-web.svg?branch=master)](https://travis-ci.org/actix/actix-web) [![codecov](https://codecov.io/gh/actix/actix-web/branch/master/graph/badge.svg)](https://codecov.io/gh/actix/actix-web) [![crates.io](https://meritbadge.herokuapp.com/actix-identity)](https://crates.io/crates/actix-identity) [![Join the chat at https://gitter.im/actix/actix](https://badges.gitter.im/actix/actix.svg)](https://gitter.im/actix/actix?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) +**This crate moved to https://github.com/actix/actix-extras.** + ## Documentation & community resources * [User Guide](https://actix.rs/docs/) diff --git a/actix-session/README.md b/actix-session/README.md index 0aee756fd..00e580120 100644 --- a/actix-session/README.md +++ b/actix-session/README.md @@ -1,5 +1,7 @@ # Session for actix web framework [![Build Status](https://travis-ci.org/actix/actix-web.svg?branch=master)](https://travis-ci.org/actix/actix-web) [![codecov](https://codecov.io/gh/actix/actix-web/branch/master/graph/badge.svg)](https://codecov.io/gh/actix/actix-web) [![crates.io](https://meritbadge.herokuapp.com/actix-session)](https://crates.io/crates/actix-session) [![Join the chat at https://gitter.im/actix/actix](https://badges.gitter.im/actix/actix.svg)](https://gitter.im/actix/actix?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) +**This crate moved to https://github.com/actix/actix-extras.** + ## Documentation & community resources * [User Guide](https://actix.rs/docs/) From 7e0d898d5aff2439623af0ad08e8307a69cb48e7 Mon Sep 17 00:00:00 2001 From: Otavio Salvador Date: Thu, 12 Mar 2020 00:52:21 -0300 Subject: [PATCH 26/27] Fix clippy warnings Signed-off-by: Otavio Salvador --- awc/src/sender.rs | 1 - src/types/json.rs | 1 - src/types/query.rs | 1 - tests/test_weird_poll.rs | 2 +- 4 files changed, 1 insertion(+), 4 deletions(-) diff --git a/awc/src/sender.rs b/awc/src/sender.rs index ec18f12e3..983e730e1 100644 --- a/awc/src/sender.rs +++ b/awc/src/sender.rs @@ -9,7 +9,6 @@ use bytes::Bytes; use derive_more::From; use futures_core::{Future, Stream}; use serde::Serialize; -use serde_json; use actix_http::body::{Body, BodyStream}; use actix_http::http::header::{self, IntoHeaderValue}; diff --git a/src/types/json.rs b/src/types/json.rs index fb00bf7a6..ead2d0c9a 100644 --- a/src/types/json.rs +++ b/src/types/json.rs @@ -11,7 +11,6 @@ use futures::future::{err, ok, FutureExt, LocalBoxFuture, Ready}; use futures::StreamExt; use serde::de::DeserializeOwned; use serde::Serialize; -use serde_json; use actix_http::http::{header::CONTENT_LENGTH, StatusCode}; use actix_http::{HttpMessage, Payload, Response}; diff --git a/src/types/query.rs b/src/types/query.rs index a6c18d9be..73ea14f17 100644 --- a/src/types/query.rs +++ b/src/types/query.rs @@ -6,7 +6,6 @@ use std::{fmt, ops}; use actix_http::error::Error; use futures::future::{err, ok, Ready}; use serde::de; -use serde_urlencoded; use crate::dev::Payload; use crate::error::QueryPayloadError; diff --git a/tests/test_weird_poll.rs b/tests/test_weird_poll.rs index 571b69f45..7e4300901 100644 --- a/tests/test_weird_poll.rs +++ b/tests/test_weird_poll.rs @@ -1,11 +1,11 @@ // Regression test for #/1321 +/* use futures::task::{noop_waker, Context}; use futures::stream::once; use actix_http::body::{MessageBody, BodyStream}; use bytes::Bytes; -/* Disable weird poll until actix-web is based on actix-http 2.0.0 #[test] From d602a7e3863fbc8fcd7e0bf950c3c72ede529fd8 Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Fri, 13 Mar 2020 05:52:58 +0900 Subject: [PATCH 27/27] Fix `read_body` doc --- src/test.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test.rs b/src/test.rs index 0eb02ff7c..15e66a230 100644 --- a/src/test.rs +++ b/src/test.rs @@ -187,7 +187,7 @@ where /// .to_request(); /// /// let resp = test::call_service(&mut app, req).await; -/// let result = test::read_body(resp); +/// let result = test::read_body(resp).await; /// assert_eq!(result, Bytes::from_static(b"welcome!")); /// } /// ```