From 535b407ac0628b71016a9dc181aa2d92104d195d Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Sat, 23 Mar 2019 10:06:54 -0700 Subject: [PATCH] make cookies optional --- Cargo.toml | 13 ++++++------- src/request.rs | 2 ++ src/test.rs | 2 ++ 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index d98c926b..6920bc09 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -34,10 +34,10 @@ members = [ ] [package.metadata.docs.rs] -features = ["ssl", "tls", "rust-tls", "session"] +features = ["ssl", "tls", "rust-tls", "brotli", "flate2-c", "cookies"] [features] -default = ["brotli", "flate2-c", "session"] +default = ["brotli", "flate2-c", "cookies"] # brotli encoding, requires c compiler brotli = ["brotli2"] @@ -49,7 +49,7 @@ flate2-c = ["flate2/miniz-sys"] flate2-rust = ["flate2/rust_backend"] # sessions feature, session require "ring" crate and c compiler -session = ["cookie/secure"] +cookies = ["cookie", "actix-http/cookies"] # tls tls = ["native-tls", "actix-server/ssl"] @@ -67,12 +67,11 @@ actix-utils = "0.3.4" actix-router = "0.1.0" actix-rt = "0.2.1" actix-web-codegen = { path="actix-web-codegen" } -actix-http = { git = "https://github.com/actix/actix-http.git" } +actix-http = { git = "https://github.com/actix/actix-http.git", features=["fail"] } actix-server = "0.4.1" actix-server-config = "0.1.0" bytes = "0.4" -cookie = { version="0.11", features=["percent-encode"] } derive_more = "0.14" encoding = "0.2" futures = "0.1" @@ -88,8 +87,8 @@ serde_urlencoded = "^0.5.3" time = "0.1" url = { version="1.7", features=["query_encoding"] } -# middlewares -# actix-session = { path="session", optional = true } +# cookies support +cookie = { version="0.11", features=["secure", "percent-encode"], optional = true } # compression brotli2 = { version="^0.3.2", optional = true } diff --git a/src/request.rs b/src/request.rs index 5517302f..1722925f 100644 --- a/src/request.rs +++ b/src/request.rs @@ -251,12 +251,14 @@ mod tests { } #[test] + #[cfg(feature = "cookies")] fn test_no_request_cookies() { let req = TestRequest::default().to_http_request(); assert!(req.cookies().unwrap().is_empty()); } #[test] + #[cfg(feature = "cookies")] fn test_request_cookies() { let req = TestRequest::default() .header(header::COOKIE, "cookie1=value1") diff --git a/src/test.rs b/src/test.rs index fe9fb024..ed9cf27c 100644 --- a/src/test.rs +++ b/src/test.rs @@ -11,6 +11,7 @@ use actix_rt::Runtime; use actix_server_config::ServerConfig; use actix_service::{IntoNewService, NewService, Service}; use bytes::Bytes; +#[cfg(feature = "cookies")] use cookie::Cookie; use futures::future::{lazy, Future}; @@ -262,6 +263,7 @@ impl TestRequest { self } + #[cfg(feature = "cookies")] /// Set cookie for this request pub fn cookie(mut self, cookie: Cookie) -> Self { self.req.cookie(cookie);