diff --git a/actix-http/CHANGES.md b/actix-http/CHANGES.md index a6bca0696..0a92c415b 100644 --- a/actix-http/CHANGES.md +++ b/actix-http/CHANGES.md @@ -1,5 +1,15 @@ # Changes +## [NEXT] - 2020-02-27 + +### Changed + +* 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 ### Changed @@ -12,12 +22,6 @@ * MessageBody is not implemented for &'static [u8] anymore. -* 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 - ### Fixed * Allow `SameSite=None` cookies to be sent in a response. diff --git a/actix-http/src/client/config.rs b/actix-http/src/client/config.rs index 2844849df..c86c697a2 100644 --- a/actix-http/src/client/config.rs +++ b/actix-http/src/client/config.rs @@ -2,7 +2,7 @@ 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 * 1; // 1mb +const DEFAULT_H2_STREAM_WINDOW: u32 = 1024 * 1024; // 1mb /// Connector configuration #[derive(Clone)] diff --git a/actix-http/src/client/connector.rs b/actix-http/src/client/connector.rs index 65c49cad9..1fcb0f08e 100644 --- a/actix-http/src/client/connector.rs +++ b/actix-http/src/client/connector.rs @@ -83,37 +83,41 @@ impl Connector<(), ()> { } } - // Build Ssl connector based on features config and supplied alpn protocols - fn build_ssl(protocols: Vec>) -> SslConnector { - #[cfg(feature = "openssl")] - { - use actix_connect::ssl::openssl::SslMethod; - use bytes::{BufMut, BytesMut}; + // 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 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()) - } - #[cfg(all(not(feature = "openssl"), feature = "rustls"))] - { - 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)) - } - #[cfg(not(any(feature = "openssl", feature = "rustls")))] - {} + 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 {