From 1ab676d7eb379cae62d9926808c82af2fe34a929 Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Wed, 7 Mar 2018 22:40:46 -0800 Subject: [PATCH] bump version and add some tests --- CHANGES.md | 6 ++++-- Cargo.toml | 2 +- src/client/response.rs | 17 +++++++++++++++++ src/httpresponse.rs | 12 ++++++++---- 4 files changed, 30 insertions(+), 7 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 289d97c74..434904bd9 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,8 @@ # Changes +## 0.4.6 (2018-03-xx) + + ## 0.4.5 (2018-03-07) * Fix compression #103 and #104 @@ -12,8 +15,7 @@ * Better support for `NamedFile` type -* Add `ResponseError` impl for `SendRequestError`. - This improves ergonomics of http client. +* Add `ResponseError` impl for `SendRequestError`. This improves ergonomics of the client. * Add native-tls support for client diff --git a/Cargo.toml b/Cargo.toml index a20e8621f..98df9176b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "actix-web" -version = "0.4.5" +version = "0.4.6-dev" authors = ["Nikolay Kim "] description = "Actix web is a simple, pragmatic, extremely fast, web framework for Rust." readme = "README.md" diff --git a/src/client/response.rs b/src/client/response.rs index d1d7370c0..1a82d64bd 100644 --- a/src/client/response.rs +++ b/src/client/response.rs @@ -129,3 +129,20 @@ impl Stream for ClientResponse { } } } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_debug() { + let resp = ClientResponse::new(ClientMessage::default()); + resp.as_mut().headers.insert( + header::COOKIE, HeaderValue::from_static("cookie1=value1")); + resp.as_mut().headers.insert( + header::COOKIE, HeaderValue::from_static("cookie2=value2")); + + let dbg = format!("{:?}", resp); + assert!(dbg.contains("ClientResponse")); + } +} diff --git a/src/httpresponse.rs b/src/httpresponse.rs index 6cf453db5..909b5ceca 100644 --- a/src/httpresponse.rs +++ b/src/httpresponse.rs @@ -781,7 +781,10 @@ mod tests { #[test] fn test_debug() { - let resp = HttpResponse::Ok().finish().unwrap(); + let resp = HttpResponse::Ok() + .header(COOKIE, HeaderValue::from_static("cookie1=value1; ")) + .header(COOKIE, HeaderValue::from_static("cookie2=value2; ")) + .finish().unwrap(); let dbg = format!("{:?}", resp); assert!(dbg.contains("HttpResponse")); } @@ -789,8 +792,8 @@ mod tests { #[test] fn test_response_cookies() { let mut headers = HeaderMap::new(); - headers.insert(COOKIE, - HeaderValue::from_static("cookie1=value1; cookie2=value2")); + headers.insert(COOKIE, HeaderValue::from_static("cookie1=value1; HttpOnly;")); + headers.insert(COOKIE, HeaderValue::from_static("cookie2=value2; HttpOnly;")); let req = HttpRequest::new( Method::GET, Uri::from_str("/").unwrap(), Version::HTTP_11, headers, None); @@ -813,7 +816,8 @@ mod tests { let mut val: Vec<_> = resp.headers().get_all("Set-Cookie") .iter().map(|v| v.to_str().unwrap().to_owned()).collect(); val.sort(); - assert!(val[0].starts_with("cookie1=; Max-Age=0;")); + println!("{:?}", val); + assert!(val[0].starts_with("cookie2=; HttpOnly; Max-Age=0;")); assert_eq!( val[1],"name=value; HttpOnly; Path=/test; Domain=www.rust-lang.org; Max-Age=86400"); }