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 diff --git a/Cargo.toml b/Cargo.toml index 0cb0506ca..6bd36279a 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" @@ -30,7 +30,7 @@ members = [ ".", "awc", "actix-http", - "actix-cors", +# "actix-cors", "actix-files", "actix-framed", # "actix-session", @@ -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" @@ -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" @@ -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" } 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-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-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-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/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/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/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-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-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/) 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/actix-web-codegen/src/lib.rs b/actix-web-codegen/src/lib.rs index 0a727ed69..affb4dfec 100644 --- a/actix-web-codegen/src/lib.rs +++ b/actix-web-codegen/src/lib.rs @@ -45,6 +45,8 @@ extern crate proc_macro; mod route; use proc_macro::TokenStream; +use quote::ToTokens; +use route::Route; use syn::parse_macro_input; /// Creates route handler with `GET` method guard. @@ -58,11 +60,10 @@ use syn::parse_macro_input; #[proc_macro_attribute] pub fn get(args: TokenStream, input: TokenStream) -> TokenStream { let args = parse_macro_input!(args as syn::AttributeArgs); - let gen = match route::Route::new(args, input, route::GuardType::Get) { - Ok(gen) => gen, - Err(err) => return err.to_compile_error().into(), - }; - gen.generate() + match Route::new(args, input, route::GuardType::Get) { + Ok(route) => route.into_token_stream().into(), + Err(err) => err.to_compile_error().into(), + } } /// Creates route handler with `POST` method guard. @@ -73,11 +74,10 @@ pub fn get(args: TokenStream, input: TokenStream) -> TokenStream { #[proc_macro_attribute] pub fn post(args: TokenStream, input: TokenStream) -> TokenStream { let args = parse_macro_input!(args as syn::AttributeArgs); - let gen = match route::Route::new(args, input, route::GuardType::Post) { - Ok(gen) => gen, - Err(err) => return err.to_compile_error().into(), - }; - gen.generate() + match Route::new(args, input, route::GuardType::Post) { + Ok(route) => route.into_token_stream().into(), + Err(err) => err.to_compile_error().into(), + } } /// Creates route handler with `PUT` method guard. @@ -88,11 +88,10 @@ pub fn post(args: TokenStream, input: TokenStream) -> TokenStream { #[proc_macro_attribute] pub fn put(args: TokenStream, input: TokenStream) -> TokenStream { let args = parse_macro_input!(args as syn::AttributeArgs); - let gen = match route::Route::new(args, input, route::GuardType::Put) { - Ok(gen) => gen, - Err(err) => return err.to_compile_error().into(), - }; - gen.generate() + match Route::new(args, input, route::GuardType::Put) { + Ok(route) => route.into_token_stream().into(), + Err(err) => err.to_compile_error().into(), + } } /// Creates route handler with `DELETE` method guard. @@ -103,11 +102,10 @@ pub fn put(args: TokenStream, input: TokenStream) -> TokenStream { #[proc_macro_attribute] pub fn delete(args: TokenStream, input: TokenStream) -> TokenStream { let args = parse_macro_input!(args as syn::AttributeArgs); - let gen = match route::Route::new(args, input, route::GuardType::Delete) { - Ok(gen) => gen, - Err(err) => return err.to_compile_error().into(), - }; - gen.generate() + match Route::new(args, input, route::GuardType::Delete) { + Ok(route) => route.into_token_stream().into(), + Err(err) => err.to_compile_error().into(), + } } /// Creates route handler with `HEAD` method guard. @@ -118,11 +116,10 @@ pub fn delete(args: TokenStream, input: TokenStream) -> TokenStream { #[proc_macro_attribute] pub fn head(args: TokenStream, input: TokenStream) -> TokenStream { let args = parse_macro_input!(args as syn::AttributeArgs); - let gen = match route::Route::new(args, input, route::GuardType::Head) { - Ok(gen) => gen, - Err(err) => return err.to_compile_error().into(), - }; - gen.generate() + match Route::new(args, input, route::GuardType::Head) { + Ok(route) => route.into_token_stream().into(), + Err(err) => err.to_compile_error().into(), + } } /// Creates route handler with `CONNECT` method guard. @@ -133,11 +130,10 @@ pub fn head(args: TokenStream, input: TokenStream) -> TokenStream { #[proc_macro_attribute] pub fn connect(args: TokenStream, input: TokenStream) -> TokenStream { let args = parse_macro_input!(args as syn::AttributeArgs); - let gen = match route::Route::new(args, input, route::GuardType::Connect) { - Ok(gen) => gen, - Err(err) => return err.to_compile_error().into(), - }; - gen.generate() + match Route::new(args, input, route::GuardType::Connect) { + Ok(route) => route.into_token_stream().into(), + Err(err) => err.to_compile_error().into(), + } } /// Creates route handler with `OPTIONS` method guard. @@ -148,11 +144,10 @@ pub fn connect(args: TokenStream, input: TokenStream) -> TokenStream { #[proc_macro_attribute] pub fn options(args: TokenStream, input: TokenStream) -> TokenStream { let args = parse_macro_input!(args as syn::AttributeArgs); - let gen = match route::Route::new(args, input, route::GuardType::Options) { - Ok(gen) => gen, - Err(err) => return err.to_compile_error().into(), - }; - gen.generate() + match Route::new(args, input, route::GuardType::Options) { + Ok(route) => route.into_token_stream().into(), + Err(err) => err.to_compile_error().into(), + } } /// Creates route handler with `TRACE` method guard. @@ -163,11 +158,10 @@ pub fn options(args: TokenStream, input: TokenStream) -> TokenStream { #[proc_macro_attribute] pub fn trace(args: TokenStream, input: TokenStream) -> TokenStream { let args = parse_macro_input!(args as syn::AttributeArgs); - let gen = match route::Route::new(args, input, route::GuardType::Trace) { - Ok(gen) => gen, - Err(err) => return err.to_compile_error().into(), - }; - gen.generate() + match Route::new(args, input, route::GuardType::Trace) { + Ok(route) => route.into_token_stream().into(), + Err(err) => err.to_compile_error().into(), + } } /// Creates route handler with `PATCH` method guard. @@ -178,9 +172,8 @@ pub fn trace(args: TokenStream, input: TokenStream) -> TokenStream { #[proc_macro_attribute] pub fn patch(args: TokenStream, input: TokenStream) -> TokenStream { let args = parse_macro_input!(args as syn::AttributeArgs); - let gen = match route::Route::new(args, input, route::GuardType::Patch) { - Ok(gen) => gen, - Err(err) => return err.to_compile_error().into(), - }; - gen.generate() + match Route::new(args, input, route::GuardType::Patch) { + Ok(route) => route.into_token_stream().into(), + Err(err) => err.to_compile_error().into(), + } } diff --git a/actix-web-codegen/src/route.rs b/actix-web-codegen/src/route.rs index 60b829595..341329ea2 100644 --- a/actix-web-codegen/src/route.rs +++ b/actix-web-codegen/src/route.rs @@ -2,7 +2,7 @@ extern crate proc_macro; use proc_macro::TokenStream; use proc_macro2::{Span, TokenStream as TokenStream2}; -use quote::{quote, ToTokens, TokenStreamExt}; +use quote::{format_ident, quote, ToTokens, TokenStreamExt}; use syn::{AttributeArgs, Ident, NestedMeta}; enum ResourceType { @@ -12,11 +12,7 @@ enum ResourceType { impl ToTokens for ResourceType { fn to_tokens(&self, stream: &mut TokenStream2) { - let ident = match self { - ResourceType::Async => "to", - ResourceType::Sync => "to", - }; - let ident = Ident::new(ident, Span::call_site()); + let ident = format_ident!("to"); stream.append(ident); } } @@ -52,8 +48,7 @@ impl GuardType { impl ToTokens for GuardType { fn to_tokens(&self, stream: &mut TokenStream2) { - let ident = self.as_str(); - let ident = Ident::new(ident, Span::call_site()); + let ident = Ident::new(self.as_str(), Span::call_site()); stream.append(ident); } } @@ -93,12 +88,12 @@ impl Args { } else { return Err(syn::Error::new_spanned( nv.path, - "Unknown attribute key is specified. Allowed: guard", + "Unknown attribute key is specified. Allowed: guard.", )); } } arg => { - return Err(syn::Error::new_spanned(arg, "Unknown attribute")); + return Err(syn::Error::new_spanned(arg, "Unknown attribute.")); } } } @@ -181,15 +176,18 @@ impl Route { guard, }) } +} - pub fn generate(&self) -> TokenStream { - let name = &self.name; +impl ToTokens for Route { + fn to_tokens(&self, output: &mut TokenStream2) { + let Self { + name, + guard, + ast, + args: Args { path, guards }, + resource_type, + } = self; let resource_name = name.to_string(); - let guard = &self.guard; - let ast = &self.ast; - let path = &self.args.path; - let extra_guards = &self.args.guards; - let resource_type = &self.resource_type; let stream = quote! { #[allow(non_camel_case_types, missing_docs)] pub struct #name; @@ -200,13 +198,14 @@ impl Route { let __resource = actix_web::Resource::new(#path) .name(#resource_name) .guard(actix_web::guard::#guard()) - #(.guard(actix_web::guard::fn_guard(#extra_guards)))* + #(.guard(actix_web::guard::fn_guard(#guards)))* .#resource_type(#name); actix_web::dev::HttpServiceFactory::register(__resource, __config) } } }; - stream.into() + + output.extend(stream); } } diff --git a/awc/CHANGES.md b/awc/CHANGES.md index 1d6e03708..e6f731540 100644 --- a/awc/CHANGES.md +++ b/awc/CHANGES.md @@ -1,9 +1,10 @@ # Changes -## [NEXT] +## [2.0.0-alpha.1] - 2020-03-11 +* 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 efbe0abd6..fde136eb0 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" @@ -54,8 +54,8 @@ 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-web = { version = "2.0.0", features=["openssl"] } +actix-connect = { version = "2.0.0-alpha.2", 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" @@ -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" 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/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/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(); 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!")); /// } /// ``` diff --git a/src/types/json.rs b/src/types/json.rs index a87b368fb..0c704ad05 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/test-server/CHANGES.md b/test-server/CHANGES.md index 3a990a594..35552030c 100644 --- a/test-server/CHANGES.md +++ b/test-server/CHANGES.md @@ -3,7 +3,8 @@ ## [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 +* Make `test_server` `async` fn. ## [1.0.0] - 2019-12-13 diff --git a/test-server/Cargo.toml b/test-server/Cargo.toml index 894099720..29896898e 100644 --- a/test-server/Cargo.toml +++ b/test-server/Cargo.toml @@ -32,12 +32,12 @@ 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" actix-testing = "1.0.0" -awc = "1.0.1" +awc = "2.0.0-alpha.1" base64 = "0.11" bytes = "0.5.3" @@ -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" 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, 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]