From 87b71624734b57f416c234ee8a24b422a2a21b44 Mon Sep 17 00:00:00 2001 From: Roberto Huertas Date: Fri, 16 Aug 2019 02:21:30 +0200 Subject: [PATCH 1/6] chore(readme): fix copy paste error (#1040) Fix actix-cors README --- actix-cors/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/actix-cors/README.md b/actix-cors/README.md index 980d98ca1..a77f6c6d3 100644 --- a/actix-cors/README.md +++ b/actix-cors/README.md @@ -1,4 +1,4 @@ -# 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) +# 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) ## Documentation & community resources From 23d768a77b42c5df45ef76bbc1f84cfee62ee09c Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Sat, 17 Aug 2019 02:45:44 +0900 Subject: [PATCH 2/6] Add explicit `dyn`s (#1041) * Add explicit `dyn`s * Remove unnecessary lines --- actix-http/src/client/connector.rs | 8 ++++---- actix-http/src/error.rs | 2 +- src/middleware/normalize.rs | 1 - src/resource.rs | 1 - src/types/form.rs | 1 - 5 files changed, 5 insertions(+), 8 deletions(-) diff --git a/actix-http/src/client/connector.rs b/actix-http/src/client/connector.rs index 7d6fca25a..98e8618c3 100644 --- a/actix-http/src/client/connector.rs +++ b/actix-http/src/client/connector.rs @@ -269,9 +269,9 @@ where .map(|protos| protos.windows(2).any(|w| w == H2)) .unwrap_or(false); if h2 { - (Box::new(sock) as Box, Protocol::Http2) + (Box::new(sock) as Box, Protocol::Http2) } else { - (Box::new(sock) as Box, Protocol::Http1) + (Box::new(sock) as Box, Protocol::Http1) } }), ), @@ -288,9 +288,9 @@ where .map(|protos| protos.windows(2).any(|w| w == H2)) .unwrap_or(false); if h2 { - (Box::new(sock) as Box, Protocol::Http2) + (Box::new(sock) as Box, Protocol::Http2) } else { - (Box::new(sock) as Box, Protocol::Http1) + (Box::new(sock) as Box, Protocol::Http1) } }), ), diff --git a/actix-http/src/error.rs b/actix-http/src/error.rs index dcbc3cc93..2c01c86db 100644 --- a/actix-http/src/error.rs +++ b/actix-http/src/error.rs @@ -1072,7 +1072,7 @@ mod tests { #[test] fn test_error_casting() { let err = PayloadError::Overflow; - let resp_err: &ResponseError = &err; + let resp_err: &dyn ResponseError = &err; let err = resp_err.downcast_ref::().unwrap(); assert_eq!(err.to_string(), "A payload reached size limit."); let not_err = resp_err.downcast_ref::(); diff --git a/src/middleware/normalize.rs b/src/middleware/normalize.rs index 427f954fe..9cfbefb30 100644 --- a/src/middleware/normalize.rs +++ b/src/middleware/normalize.rs @@ -151,5 +151,4 @@ mod tests { let res = block_on(normalize.call(req)).unwrap(); assert!(res.status().is_success()); } - } diff --git a/src/resource.rs b/src/resource.rs index 0af43a424..b872049d0 100644 --- a/src/resource.rs +++ b/src/resource.rs @@ -763,5 +763,4 @@ mod tests { let resp = call_service(&mut srv, req); assert_eq!(resp.status(), StatusCode::NO_CONTENT); } - } diff --git a/src/types/form.rs b/src/types/form.rs index ec6e6cd09..9ab98b17b 100644 --- a/src/types/form.rs +++ b/src/types/form.rs @@ -482,5 +482,4 @@ mod tests { use crate::responder::tests::BodyTest; assert_eq!(resp.body().bin_ref(), b"hello=world&counter=123"); } - } From 61e492e7e31fa1543f475b3cde465c89cc77f3b7 Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Sun, 18 Aug 2019 10:39:22 +0900 Subject: [PATCH 3/6] Prepare actix-multipart 0.1.3 release --- actix-multipart/CHANGES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/actix-multipart/CHANGES.md b/actix-multipart/CHANGES.md index b0d8f285e..27333f4c4 100644 --- a/actix-multipart/CHANGES.md +++ b/actix-multipart/CHANGES.md @@ -1,6 +1,6 @@ # Changes -## [0.1.3] - 2019-06-06 +## [0.1.3] - 2019-08-18 * Fix ring dependency from actix-web default features for #741. From a07cdd6533cb1e29c730da5811ba6d9928e3bbc9 Mon Sep 17 00:00:00 2001 From: Erlend Langseth Date: Fri, 23 Aug 2019 17:02:03 +0200 Subject: [PATCH 4/6] Data::into_inner --- CHANGES.md | 2 ++ src/data.rs | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 3aadc8f1e..192323460 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -8,6 +8,8 @@ * Form immplements Responder, returning a `application/x-www-form-urlencoded` response +* Add `into_inner` to `Data` + ### Changed * `Query` payload made `pub`. Allows user to pattern-match the payload. diff --git a/src/data.rs b/src/data.rs index 3461d24f3..14e293bc2 100644 --- a/src/data.rs +++ b/src/data.rs @@ -77,6 +77,11 @@ impl Data { pub fn get_ref(&self) -> &T { self.0.as_ref() } + + /// Convert to the internal Arc + pub fn into_inner(self) -> Arc { + self.0 + } } impl Deref for Data { From c19313790547c7b7a3ea42d0a16b9fcfec208f05 Mon Sep 17 00:00:00 2001 From: Leland Jansen Date: Wed, 28 Aug 2019 08:32:17 -0700 Subject: [PATCH 5/6] actix_web::test::TestRequest::set_form (#1058) --- CHANGES.md | 3 +++ src/test.rs | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 192323460..aeb270b9c 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -10,6 +10,9 @@ * Add `into_inner` to `Data` +* Add `test::TestRequest::set_form()` convenience method to automatically serialize data and set + the header in test requests. + ### Changed * `Query` payload made `pub`. Allows user to pattern-match the payload. diff --git a/src/test.rs b/src/test.rs index 562fdf436..903679cad 100644 --- a/src/test.rs +++ b/src/test.rs @@ -478,6 +478,16 @@ impl TestRequest { self } + /// Serialize `data` to a URL encoded form and set it as the request payload. The `Content-Type` + /// header is set to `application/x-www-form-urlencoded`. + pub fn set_form(mut self, data: &T) -> Self { + let bytes = serde_urlencoded::to_string(data) + .expect("Failed to serialize test data as a urlencoded form"); + self.req.set_payload(bytes); + self.req.set(ContentType::form_url_encoded()); + self + } + /// Serialize `data` to JSON and set it as the request payload. The `Content-Type` header is /// set to `application/json`. pub fn set_json(mut self, data: &T) -> Self { @@ -670,6 +680,31 @@ mod tests { assert_eq!(&result.id, "12345"); } + #[test] + fn test_request_response_form() { + let mut app = init_service(App::new().service(web::resource("/people").route( + web::post().to(|person: web::Form| { + HttpResponse::Ok().json(person.into_inner()) + }), + ))); + + let payload = Person { + id: "12345".to_string(), + name: "User name".to_string(), + }; + + let req = TestRequest::post() + .uri("/people") + .set_form(&payload) + .to_request(); + + assert_eq!(req.content_type(), "application/x-www-form-urlencoded"); + + let result: Person = read_response_json(&mut app, req); + assert_eq!(&result.id, "12345"); + assert_eq!(&result.name, "User name"); + } + #[test] fn test_request_response_json() { let mut app = init_service(App::new().service(web::resource("/people").route( From 98bf8ab0984356a78c15b2a02d8974e0063867eb Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Wed, 28 Aug 2019 21:40:24 +0600 Subject: [PATCH 6/6] enable rust-tls feature for actix_web::client #1045 --- CHANGES.md | 4 +++- Cargo.toml | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index aeb270b9c..158c8dc9a 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,6 +1,6 @@ # Changes -## [1.0.6] - 2019-xx-xx +## [1.0.6] - 2019-08-28 ### Added @@ -17,6 +17,8 @@ * `Query` payload made `pub`. Allows user to pattern-match the payload. +* Enable `rust-tls` feature for client #1045 + * Update serde_urlencoded to 0.6.1 * Update url to 2.1 diff --git a/Cargo.toml b/Cargo.toml index 7c630cc7f..5a73bf263 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "actix-web" -version = "1.0.5" +version = "1.0.6" authors = ["Nikolay Kim "] description = "Actix web is a simple, pragmatic and extremely fast web framework for Rust." readme = "README.md" @@ -66,7 +66,7 @@ fail = ["actix-http/fail"] ssl = ["openssl", "actix-server/ssl", "awc/ssl"] # rustls -rust-tls = ["rustls", "actix-server/rust-tls"] +rust-tls = ["rustls", "actix-server/rust-tls", "awc/rust-tls"] # unix domain sockets support uds = ["actix-server/uds"]