From 3bb081852ce9deae03b0ce62f056841a1cd83bbb Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Sun, 12 May 2019 10:53:21 -0700 Subject: [PATCH 1/3] prep actix-session release --- actix-session/CHANGES.md | 4 ++++ actix-session/Cargo.toml | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/actix-session/CHANGES.md b/actix-session/CHANGES.md index 8e06a5624..5f2bdadd1 100644 --- a/actix-session/CHANGES.md +++ b/actix-session/CHANGES.md @@ -1,5 +1,9 @@ # Changes +## [0.1.0-beta.4] - 2019-05-12 + +* Use actix-web 1.0.0-beta.4 + ## [0.1.0-beta.2] - 2019-04-28 * Add helper trait `UserSession` which allows to get session for ServiceRequest and HttpRequest diff --git a/actix-session/Cargo.toml b/actix-session/Cargo.toml index 4af0fc29a..f74d23f02 100644 --- a/actix-session/Cargo.toml +++ b/actix-session/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "actix-session" -version = "0.1.0-beta.2" +version = "0.1.0-beta.4" authors = ["Nikolay Kim "] description = "Session for actix web framework." readme = "README.md" @@ -24,7 +24,7 @@ default = ["cookie-session"] cookie-session = ["actix-web/secure-cookies"] [dependencies] -actix-web = "1.0.0-beta.2" +actix-web = "1.0.0-beta.4" actix-service = "0.4.0" bytes = "0.4" derive_more = "0.14" From 36d017dcc6b27c1442a2d013b588d3119f692957 Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Sun, 12 May 2019 11:41:43 -0700 Subject: [PATCH 2/3] update deps --- Cargo.toml | 2 +- actix-files/CHANGES.md | 4 ++++ actix-files/Cargo.toml | 6 +++--- actix-web-actors/Cargo.toml | 4 ++-- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 23b388279..513c9add4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -101,7 +101,7 @@ rustls = { version = "^0.15", optional = true } [dev-dependencies] actix-http = { version = "0.2.0", features=["ssl", "brotli", "flate2-zlib"] } actix-http-test = { version = "0.2.0", features=["ssl"] } -actix-files = { version = "0.1.0-betsa.1" } +actix-files = { version = "0.1.0-beta.4" } rand = "0.6" env_logger = "0.6" serde_derive = "1.0" diff --git a/actix-files/CHANGES.md b/actix-files/CHANGES.md index 05a5e5805..6b4ab57b8 100644 --- a/actix-files/CHANGES.md +++ b/actix-files/CHANGES.md @@ -1,5 +1,9 @@ # Changes +## [0.1.0-beta.4] - 2019-05-12 + +* Update actix-web to beta.4 + ## [0.1.0-beta.1] - 2019-04-20 * Update actix-web to beta.1 diff --git a/actix-files/Cargo.toml b/actix-files/Cargo.toml index a0cbba366..c75b3515d 100644 --- a/actix-files/Cargo.toml +++ b/actix-files/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "actix-files" -version = "0.1.0-betsa.1" +version = "0.1.0-beta.4" authors = ["Nikolay Kim "] description = "Static files support for actix web." readme = "README.md" @@ -18,7 +18,7 @@ name = "actix_files" path = "src/lib.rs" [dependencies] -actix-web = "1.0.0-beta.1" +actix-web = "1.0.0-beta.4" actix-service = "0.4.0" bitflags = "1" bytes = "0.4" @@ -31,4 +31,4 @@ percent-encoding = "1.0" v_htmlescape = "0.4" [dev-dependencies] -actix-web = { version = "1.0.0-beta.1", features=["ssl"] } +actix-web = { version = "1.0.0-beta.4", features=["ssl"] } diff --git a/actix-web-actors/Cargo.toml b/actix-web-actors/Cargo.toml index f2309d196..6d87b5ef7 100644 --- a/actix-web-actors/Cargo.toml +++ b/actix-web-actors/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "actix-web-actors" -version = "1.0.0-alpha.3" +version = "1.0.0-beta.4" authors = ["Nikolay Kim "] description = "Actix actors support for actix web framework." readme = "README.md" @@ -19,7 +19,7 @@ path = "src/lib.rs" [dependencies] actix = "0.8.0" -actix-web = "1.0.0-beta.1" +actix-web = "1.0.0-beta.4" actix-http = "0.2.0" actix-codec = "0.1.2" bytes = "0.4" From 2350a2dc68ad2093fa4b95ff26a47bab86d54868 Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Sun, 12 May 2019 11:43:05 -0700 Subject: [PATCH 3/3] Handle cancellation of uploads #834 #736 --- actix-multipart/CHANGES.md | 6 ++++++ actix-multipart/Cargo.toml | 4 ++-- actix-multipart/src/error.rs | 3 +++ actix-multipart/src/server.rs | 17 ++++++++++++++--- 4 files changed, 25 insertions(+), 5 deletions(-) diff --git a/actix-multipart/CHANGES.md b/actix-multipart/CHANGES.md index 9f8fa052a..5ee1d6201 100644 --- a/actix-multipart/CHANGES.md +++ b/actix-multipart/CHANGES.md @@ -1,5 +1,11 @@ # Changes +## [0.1.0-beta.4] - 2019-05-12 + +* Handle cancellation of uploads #834 #736 + +* Upgrade to actix-web 1.0.0-beta.4 + ## [0.1.0-beta.1] - 2019-04-21 * Do not support nested multipart diff --git a/actix-multipart/Cargo.toml b/actix-multipart/Cargo.toml index 6e3f6dc76..e88c642bc 100644 --- a/actix-multipart/Cargo.toml +++ b/actix-multipart/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "actix-multipart" -version = "0.1.0-beta.1" +version = "0.1.0-beta.4" authors = ["Nikolay Kim "] description = "Multipart support for actix web framework." readme = "README.md" @@ -18,7 +18,7 @@ name = "actix_multipart" path = "src/lib.rs" [dependencies] -actix-web = "1.0.0-beta.1" +actix-web = "1.0.0-beta.4" actix-service = "0.4.0" bytes = "0.4" derive_more = "0.14" diff --git a/actix-multipart/src/error.rs b/actix-multipart/src/error.rs index 995585850..32c740a1a 100644 --- a/actix-multipart/src/error.rs +++ b/actix-multipart/src/error.rs @@ -28,6 +28,9 @@ pub enum MultipartError { /// Payload error #[display(fmt = "{}", _0)] Payload(PayloadError), + /// Not consumed + #[display(fmt = "Multipart stream is not consumed")] + NotConsumed, } /// Return `BadRequest` for `MultipartError` diff --git a/actix-multipart/src/server.rs b/actix-multipart/src/server.rs index 82b0b5ace..7d746ea2f 100644 --- a/actix-multipart/src/server.rs +++ b/actix-multipart/src/server.rs @@ -1,5 +1,5 @@ //! Multipart payload support -use std::cell::{RefCell, UnsafeCell}; +use std::cell::{Cell, RefCell, UnsafeCell}; use std::marker::PhantomData; use std::rc::Rc; use std::{cmp, fmt}; @@ -116,6 +116,8 @@ impl Stream for Multipart { payload.poll_stream()?; } inner.poll(&self.safety) + } else if !self.safety.is_clean() { + Err(MultipartError::NotConsumed) } else { Ok(Async::NotReady) } @@ -415,6 +417,8 @@ impl Stream for Field { } inner.poll(&self.safety) + } else if !self.safety.is_clean() { + return Err(MultipartError::NotConsumed); } else { Ok(Async::NotReady) } @@ -655,6 +659,7 @@ struct Safety { task: Option, level: usize, payload: Rc>, + clean: Rc>, } impl Safety { @@ -663,12 +668,17 @@ impl Safety { Safety { task: None, level: Rc::strong_count(&payload), + clean: Rc::new(Cell::new(true)), payload, } } fn current(&self) -> bool { - Rc::strong_count(&self.payload) == self.level + Rc::strong_count(&self.payload) == self.level && self.clean.get() + } + + fn is_clean(&self) -> bool { + self.clean.get() } } @@ -678,6 +688,7 @@ impl Clone for Safety { Safety { task: Some(current_task()), level: Rc::strong_count(&payload), + clean: self.clean.clone(), payload, } } @@ -687,7 +698,7 @@ impl Drop for Safety { fn drop(&mut self) { // parent task is dead if Rc::strong_count(&self.payload) != self.level { - panic!("Safety get dropped but it is not from top-most task"); + self.clean.set(true); } if let Some(task) = self.task.take() { task.notify()