diff --git a/Cargo.toml b/Cargo.toml index fa29c225..0cb0506c 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 269ea537..c37d023f 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 133b8083..4389fe69 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-http/CHANGES.md b/actix-http/CHANGES.md index ccfdc81d..fb1c3a32 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 diff --git a/actix-http/Cargo.toml b/actix-http/Cargo.toml index df9653aa..c8b6d7d7 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" diff --git a/actix-http/README.md b/actix-http/README.md index d75e822b..9acad3e6 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 } ``` diff --git a/actix-http/src/client/connector.rs b/actix-http/src/client/connector.rs index adb88bbe..e1aed638 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 ffdcd8d9..ec01261e 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)) => { diff --git a/actix-multipart/Cargo.toml b/actix-multipart/Cargo.toml index a1d91c6a..3c8fe6de 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 333edb8c..7941e192 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 d27615f7..efbe0abd 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 ba8e1c9e..89409972 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"