From bf53fe5a22449bb99da2192f2b3cc363f7302969 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Fri, 11 Sep 2020 12:09:52 +0100 Subject: [PATCH] bump actix dependency to v0.10 (#1666) --- Cargo.toml | 5 +- actix-http/Cargo.toml | 2 +- .../src/header/common/content_disposition.rs | 6 +- actix-web-actors/Cargo.toml | 2 +- src/lib.rs | 2 +- src/test.rs | 93 ++++++++++--------- 6 files changed, 56 insertions(+), 54 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 11559bcae..8d55ffe11 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -92,7 +92,7 @@ mime = "0.3" socket2 = "0.3" pin-project = "0.4.17" regex = "1.3" -serde = { version = "1.0", features=["derive"] } +serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" serde_urlencoded = "0.6.1" time = { version = "0.2.7", default-features = false, features = ["std"] } @@ -102,7 +102,8 @@ rust-tls = { package = "rustls", version = "0.18.0", optional = true } tinyvec = { version = "0.3", features = ["alloc"] } [dev-dependencies] -actix = "0.10.0-alpha.1" +actix = "0.10.0" +actix-http = { version = "2.0.0-beta.4", features = ["actors"] } rand = "0.7" env_logger = "0.7" serde_derive = "1.0" diff --git a/actix-http/Cargo.toml b/actix-http/Cargo.toml index 6d8d143ed..fa002b309 100644 --- a/actix-http/Cargo.toml +++ b/actix-http/Cargo.toml @@ -47,7 +47,7 @@ actix-utils = "2.0.0" actix-rt = "1.0.0" actix-threadpool = "0.3.1" actix-tls = { version = "2.0.0", optional = true } -actix = { version = "0.10.0-alpha.1", optional = true } +actix = { version = "0.10.0", optional = true } base64 = "0.12" bitflags = "1.2" diff --git a/actix-http/src/header/common/content_disposition.rs b/actix-http/src/header/common/content_disposition.rs index 051dcfe80..37da830ca 100644 --- a/actix-http/src/header/common/content_disposition.rs +++ b/actix-http/src/header/common/content_disposition.rs @@ -283,11 +283,11 @@ impl DispositionParam { /// Some("\u{1f600}.svg".as_bytes())); /// ``` /// -/// # WARN +/// # Security Note +/// /// If "filename" parameter is supplied, do not use the file name blindly, check and possibly /// change to match local file system conventions if applicable, and do not use directory path -/// information that may be present. See [RFC2183](https://tools.ietf.org/html/rfc2183#section-2.3) -/// . +/// information that may be present. See [RFC2183](https://tools.ietf.org/html/rfc2183#section-2.3). #[derive(Clone, Debug, PartialEq)] pub struct ContentDisposition { /// The disposition type diff --git a/actix-web-actors/Cargo.toml b/actix-web-actors/Cargo.toml index cb7fd3a80..917f0cd94 100644 --- a/actix-web-actors/Cargo.toml +++ b/actix-web-actors/Cargo.toml @@ -16,7 +16,7 @@ name = "actix_web_actors" path = "src/lib.rs" [dependencies] -actix = "0.10.0-alpha.2" +actix = "0.10.0" actix-web = { version = "3.0.0-beta.4", default-features = false } actix-http = "2.0.0-beta.4" actix-codec = "0.3.0" diff --git a/src/lib.rs b/src/lib.rs index 97141599c..0eced5b42 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -59,7 +59,7 @@ //! * Middlewares ([Logger, Session, CORS, etc](https://actix.rs/docs/middleware/)) //! * Includes an async [HTTP client](https://actix.rs/actix-web/actix_web/client/index.html) //! * Supports [Actix actor framework](https://github.com/actix/actix) -//! * Runs on stable Rust 1.41+ +//! * Runs on stable Rust 1.42+ //! //! ## Crate Features //! diff --git a/src/test.rs b/src/test.rs index 2620e190e..ee51b71ee 100644 --- a/src/test.rs +++ b/src/test.rs @@ -1281,53 +1281,54 @@ mod tests { assert!(res.status().is_success()); } - /* + #[actix_rt::test] + async fn test_actor() { + use crate::Error; + use actix::prelude::*; - Comment out until actix decoupled of actix-http: - https://github.com/actix/actix/issues/321 + struct MyActor; - use futures::FutureExt; - - #[actix_rt::test] - async fn test_actor() { - use actix::Actor; - - struct MyActor; - - struct Num(usize); - impl actix::Message for Num { - type Result = usize; - } - impl actix::Actor for MyActor { - type Context = actix::Context; - } - impl actix::Handler for MyActor { - type Result = usize; - fn handle(&mut self, msg: Num, _: &mut Self::Context) -> Self::Result { - msg.0 - } - } - - - let mut app = init_service(App::new().service(web::resource("/index.html").to( - move || { - addr.send(Num(1)).map(|res| match res { - Ok(res) => { - if res == 1 { - Ok(HttpResponse::Ok()) - } else { - Ok(HttpResponse::BadRequest()) - } - } - Err(err) => Err(err), - }) - }, - ))) - .await; - - let req = TestRequest::post().uri("/index.html").to_request(); - let res = app.call(req).await.unwrap(); - assert!(res.status().is_success()); + impl Actor for MyActor { + type Context = Context; } - */ + + struct Num(usize); + + impl Message for Num { + type Result = usize; + } + + impl Handler for MyActor { + type Result = usize; + + fn handle(&mut self, msg: Num, _: &mut Self::Context) -> Self::Result { + msg.0 + } + } + + let addr = MyActor.start(); + + async fn actor_handler( + addr: Data>, + ) -> Result { + // `?` operator tests "actors" feature flag on actix-http + let res = addr.send(Num(1)).await?; + + if res == 1 { + Ok(HttpResponse::Ok()) + } else { + Ok(HttpResponse::BadRequest()) + } + } + + let srv = App::new() + .data(addr.clone()) + .service(web::resource("/").to(actor_handler)); + + let mut app = init_service(srv).await; + + let req = TestRequest::post().uri("/").to_request(); + let res = app.call(req).await.unwrap(); + assert!(res.status().is_success()); + } }