diff --git a/CHANGES.md b/CHANGES.md index d5f36a9cb..739f1b13c 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,6 +1,6 @@ # Changes -## [Unreleased] +## [3.0.0-alpha.3] - 2020-05-21 ### Added diff --git a/Cargo.toml b/Cargo.toml index f9f0491ba..83d64f8f1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "actix-web" -version = "3.0.0-alpha.2" +version = "3.0.0-alpha.3" authors = ["Nikolay Kim "] description = "Actix web is a simple, pragmatic and extremely fast web framework for Rust." readme = "README.md" diff --git a/actix-files/Cargo.toml b/actix-files/Cargo.toml index d3d1ce073..f84a70fe5 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 = "3.0.0-alpha.2", default-features = false } +actix-web = { version = "3.0.0-alpha.3", default-features = false } actix-http = "2.0.0-alpha.4" actix-service = "1.0.1" bitflags = "1" @@ -34,4 +34,4 @@ v_htmlescape = "0.4" [dev-dependencies] actix-rt = "1.0.0" -actix-web = { version = "3.0.0-alpha.2", features = ["openssl"] } +actix-web = { version = "3.0.0-alpha.3", features = ["openssl"] } diff --git a/actix-multipart/Cargo.toml b/actix-multipart/Cargo.toml index 0bc79e5fa..e12c07bf1 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 = "3.0.0-alpha.2", default-features = false } +actix-web = { version = "3.0.0-alpha.3", 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 45d506940..20fd3743d 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.2" -actix-web = "3.0.0-alpha.2" +actix-web = "3.0.0-alpha.3" actix-http = "2.0.0-alpha.4" actix-codec = "0.2.0" bytes = "0.5.2" diff --git a/actix-web-codegen/Cargo.toml b/actix-web-codegen/Cargo.toml index c7b06e311..d57022d4d 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 = "3.0.0-alpha.2" +actix-web = "3.0.0-alpha.3" futures-util = { version = "0.3.5", default-features = false } diff --git a/awc/Cargo.toml b/awc/Cargo.toml index a8f3a3fa4..5e720ca87 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 = "3.0.0-alpha.2", features = ["openssl"] } +actix-web = { version = "3.0.0-alpha.3", features = ["openssl"] } actix-http = { version = "2.0.0-alpha.4", features = ["openssl"] } actix-http-test = { version = "1.0.0", features = ["openssl"] } actix-utils = "1.0.3" diff --git a/src/app.rs b/src/app.rs index 9e38f5bc9..8178d57fe 100644 --- a/src/app.rs +++ b/src/app.rs @@ -474,13 +474,15 @@ where mod tests { use actix_service::Service; use bytes::Bytes; - use futures_util::future::{ok, err}; + use futures_util::future::{err, ok}; use super::*; use crate::http::{header, HeaderValue, Method, StatusCode}; use crate::middleware::DefaultHeaders; use crate::service::ServiceRequest; - use crate::test::{call_service, init_service, try_init_service, read_body, TestRequest}; + use crate::test::{ + call_service, init_service, read_body, try_init_service, TestRequest, + }; use crate::{web, HttpRequest, HttpResponse}; #[actix_rt::test] @@ -556,7 +558,7 @@ mod tests { web::resource("/").to(|_: web::Data| HttpResponse::Ok()), )) .await; - + assert!(srv.is_err()); } diff --git a/src/middleware/logger.rs b/src/middleware/logger.rs index e63efc832..8b881c0a4 100644 --- a/src/middleware/logger.rs +++ b/src/middleware/logger.rs @@ -273,13 +273,15 @@ impl PinnedDrop for StreamLog { } } - impl MessageBody for StreamLog { fn size(&self) -> BodySize { self.body.size() } - fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll>> { + fn poll_next( + self: Pin<&mut Self>, + cx: &mut Context<'_>, + ) -> Poll>> { let this = self.project(); match this.body.poll_next(cx) { Poll::Ready(Some(Ok(chunk))) => { @@ -324,11 +326,13 @@ impl Format { if let Some(key) = cap.get(2) { results.push(match cap.get(3).unwrap().as_str() { - "a" => if key.as_str() == "r" { - FormatText::RealIPRemoteAddr - } else { - unreachable!() - }, + "a" => { + if key.as_str() == "r" { + FormatText::RealIPRemoteAddr + } else { + unreachable!() + } + } "i" => FormatText::RequestHeader( HeaderName::try_from(key.as_str()).unwrap(), ), @@ -481,7 +485,8 @@ impl FormatText { *self = s; } FormatText::RealIPRemoteAddr => { - let s = if let Some(remote) = req.connection_info().realip_remote_addr() { + let s = if let Some(remote) = req.connection_info().realip_remote_addr() + { FormatText::Str(remote.to_string()) } else { FormatText::Str("-".to_string()) @@ -630,7 +635,9 @@ mod tests { let req = TestRequest::with_header( header::FORWARDED, - header::HeaderValue::from_static("for=192.0.2.60;proto=http;by=203.0.113.43"), + header::HeaderValue::from_static( + "for=192.0.2.60;proto=http;by=203.0.113.43", + ), ) .to_srv_request(); diff --git a/src/middleware/normalize.rs b/src/middleware/normalize.rs index 139ec892e..d23f03445 100644 --- a/src/middleware/normalize.rs +++ b/src/middleware/normalize.rs @@ -74,7 +74,7 @@ where fn call(&mut self, mut req: ServiceRequest) -> Self::Future { let head = req.head_mut(); - + // always add trailing slash, might be an extra one let path = head.uri.path().to_string() + "/"; let original_len = path.len(); @@ -177,7 +177,7 @@ mod tests { assert!(res.status().is_success()); } - #[actix_rt::test] + #[actix_rt::test] async fn should_normalize_nothing_notrail() { const URI: &str = "/v1/something"; diff --git a/src/route.rs b/src/route.rs index 8da9aec1b..2763f3b1a 100644 --- a/src/route.rs +++ b/src/route.rs @@ -362,31 +362,23 @@ mod tests { .service( web::resource("/test") .route(web::get().to(|| HttpResponse::Ok())) - .route(web::put().to(|| { - async { - Err::(error::ErrorBadRequest("err")) - } + .route(web::put().to(|| async { + Err::(error::ErrorBadRequest("err")) })) - .route(web::post().to(|| { - async { - delay_for(Duration::from_millis(100)).await; - HttpResponse::Created() - } + .route(web::post().to(|| async { + delay_for(Duration::from_millis(100)).await; + HttpResponse::Created() })) - .route(web::delete().to(|| { - async { - delay_for(Duration::from_millis(100)).await; - Err::(error::ErrorBadRequest("err")) - } + .route(web::delete().to(|| async { + delay_for(Duration::from_millis(100)).await; + Err::(error::ErrorBadRequest("err")) })), ) - .service(web::resource("/json").route(web::get().to(|| { - async { - delay_for(Duration::from_millis(25)).await; - web::Json(MyObject { - name: "test".to_string(), - }) - } + .service(web::resource("/json").route(web::get().to(|| async { + delay_for(Duration::from_millis(25)).await; + web::Json(MyObject { + name: "test".to_string(), + }) }))), ) .await; diff --git a/src/test.rs b/src/test.rs index 684e9c116..a64ec3a73 100644 --- a/src/test.rs +++ b/src/test.rs @@ -89,7 +89,9 @@ where >, S::InitError: std::fmt::Debug, { - try_init_service(app).await.expect("service initilization failed") + try_init_service(app) + .await + .expect("service initilization failed") } /// Fallible version of init_service that allows testing data factory errors. @@ -913,7 +915,8 @@ impl TestServerConfig { /// Get first available unused address pub fn unused_addr() -> net::SocketAddr { let addr: net::SocketAddr = "127.0.0.1:0".parse().unwrap(); - let socket = Socket::new(Domain::ipv4(), Type::stream(), Some(Protocol::tcp())).unwrap(); + let socket = + Socket::new(Domain::ipv4(), Type::stream(), Some(Protocol::tcp())).unwrap(); socket.bind(&addr.into()).unwrap(); socket.set_reuse_address(true).unwrap(); let tcp = socket.into_tcp_listener(); diff --git a/test-server/Cargo.toml b/test-server/Cargo.toml index 09d1a9195..2fa0691c3 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 = "3.0.0-alpha.2" +actix-web = "3.0.0-alpha.3" actix-http = "2.0.0-alpha.4" diff --git a/tests/test_server.rs b/tests/test_server.rs index 926b211ee..0ac4b0232 100644 --- a/tests/test_server.rs +++ b/tests/test_server.rs @@ -349,9 +349,10 @@ async fn test_body_br_streaming() { #[actix_rt::test] async fn test_head_binary() { let srv = test::start_with(test::config().h1(), || { - App::new().service(web::resource("/").route( - web::head().to(move || HttpResponse::Ok().body(STR)), - )) + App::new().service( + web::resource("/") + .route(web::head().to(move || HttpResponse::Ok().body(STR))), + ) }); let mut response = srv.head("/").send().await.unwrap();