mirror of https://github.com/fafhrd91/actix-web
Apply code review fixes
This commit is contained in:
parent
cf70225216
commit
1c2f7d4e23
|
@ -1,5 +1,15 @@
|
||||||
# Changes
|
# 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
|
## [2.0.0-alpha.1] - 2020-02-27
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
@ -12,12 +22,6 @@
|
||||||
|
|
||||||
* MessageBody is not implemented for &'static [u8] anymore.
|
* 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
|
### Fixed
|
||||||
|
|
||||||
* Allow `SameSite=None` cookies to be sent in a response.
|
* Allow `SameSite=None` cookies to be sent in a response.
|
||||||
|
|
|
@ -2,7 +2,7 @@ use std::time::Duration;
|
||||||
|
|
||||||
// These values are taken from hyper/src/proto/h2/client.rs
|
// These values are taken from hyper/src/proto/h2/client.rs
|
||||||
const DEFAULT_H2_CONN_WINDOW: u32 = 1024 * 1024 * 2; // 2mb
|
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
|
/// Connector configuration
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
|
|
|
@ -83,37 +83,41 @@ impl Connector<(), ()> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build Ssl connector based on features config and supplied alpn protocols
|
// Build Ssl connector with openssl, based on supplied alpn protocols
|
||||||
fn build_ssl(protocols: Vec<Vec<u8>>) -> SslConnector {
|
#[cfg(feature = "openssl")]
|
||||||
#[cfg(feature = "openssl")]
|
fn build_ssl(protocols: Vec<Vec<u8>>) -> SslConnector
|
||||||
{
|
{
|
||||||
use actix_connect::ssl::openssl::SslMethod;
|
use actix_connect::ssl::openssl::SslMethod;
|
||||||
use bytes::{BufMut, BytesMut};
|
use bytes::{BufMut, BytesMut};
|
||||||
|
|
||||||
let mut alpn = BytesMut::with_capacity(20);
|
let mut alpn = BytesMut::with_capacity(20);
|
||||||
for proto in protocols.iter() {
|
for proto in protocols.iter() {
|
||||||
alpn.put_u8(proto.len() as u8);
|
alpn.put_u8(proto.len() as u8);
|
||||||
alpn.put(proto.as_slice());
|
alpn.put(proto.as_slice());
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut ssl = OpensslConnector::builder(SslMethod::tls()).unwrap();
|
let mut ssl = OpensslConnector::builder(SslMethod::tls()).unwrap();
|
||||||
let _ = ssl
|
let _ = ssl
|
||||||
.set_alpn_protos(&alpn)
|
.set_alpn_protos(&alpn)
|
||||||
.map_err(|e| error!("Can not set alpn protocol: {:?}", e));
|
.map_err(|e| error!("Can not set alpn protocol: {:?}", e));
|
||||||
SslConnector::Openssl(ssl.build())
|
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")))]
|
|
||||||
{}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Build Ssl connector with rustls, based on supplied alpn protocols
|
||||||
|
#[cfg(all(not(feature = "openssl"), feature = "rustls"))]
|
||||||
|
fn build_ssl(protocols: Vec<Vec<u8>>) -> 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<Vec<u8>>) -> SslConnector {}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T, U> Connector<T, U> {
|
impl<T, U> Connector<T, U> {
|
||||||
|
|
Loading…
Reference in New Issue