diff --git a/CHANGES.md b/CHANGES.md index edf4380fb..87c021b1e 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -2,11 +2,25 @@ ## Unreleased - 2020-xx-xx ### Fixed -* Ensure `actix-http` dependency uses same `serde_urlencoded`. -* Removed an occasional `unwrap` on `None` panic in `NormalizePathNormalization`. -* Fix match_pattern() returning None for scope with resource of empty path. [#1798] +* added the actual parsing error to `test::read_body_json` [#1812] +[#1812]: https://github.com/actix/actix-web/pull/1812 + + + +## 3.3.2 - 2020-12-01 +### Fixed +* Removed an occasional `unwrap` on `None` panic in `NormalizePathNormalization`. [#1762] +* Fix `match_pattern()` returning `None` for scope with empty path resource. [#1798] +* Increase minimum `socket2` version. [#1803] + +[#1762]: https://github.com/actix/actix-web/pull/1762 [#1798]: https://github.com/actix/actix-web/pull/1798 +[#1803]: https://github.com/actix/actix-web/pull/1803 + + +## 3.3.1 - 2020-11-29 +* Ensure `actix-http` dependency uses same `serde_urlencoded`. ## 3.3.0 - 2020-11-25 diff --git a/Cargo.toml b/Cargo.toml index f8da9d90c..31c4cca7e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "actix-web" -version = "3.3.1" +version = "3.3.2" authors = ["Nikolay Kim "] description = "Actix Web is a powerful, pragmatic, and extremely fast web framework for Rust" readme = "README.md" @@ -34,7 +34,7 @@ members = [ "actix-multipart", "actix-web-actors", "actix-web-codegen", - "test-server", + "actix-http-test", ] [features] @@ -127,10 +127,10 @@ codegen-units = 1 [patch.crates-io] actix-web = { path = "." } actix-http = { path = "actix-http" } -actix-http-test = { path = "test-server" } +actix-http-test = { path = "actix-http-test" } actix-web-codegen = { path = "actix-web-codegen" } -actix-files = { path = "actix-files" } actix-multipart = { path = "actix-multipart" } +actix-files = { path = "actix-files" } awc = { path = "awc" } [[bench]] diff --git a/README.md b/README.md index f67da03c1..b9f2b7594 100644 --- a/README.md +++ b/README.md @@ -6,10 +6,10 @@

[![crates.io](https://img.shields.io/crates/v/actix-web?label=latest)](https://crates.io/crates/actix-web) -[![Documentation](https://docs.rs/actix-web/badge.svg?version=3.3.1)](https://docs.rs/actix-web/3.3.1) +[![Documentation](https://docs.rs/actix-web/badge.svg?version=3.3.2)](https://docs.rs/actix-web/3.3.2) [![Version](https://img.shields.io/badge/rustc-1.42+-ab6000.svg)](https://blog.rust-lang.org/2020/03/12/Rust-1.42.html) ![License](https://img.shields.io/crates/l/actix-web.svg) -[![Dependency Status](https://deps.rs/crate/actix-web/3.3.1/status.svg)](https://deps.rs/crate/actix-web/3.3.1) +[![Dependency Status](https://deps.rs/crate/actix-web/3.3.2/status.svg)](https://deps.rs/crate/actix-web/3.3.2)
[![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) diff --git a/test-server/CHANGES.md b/actix-http-test/CHANGES.md similarity index 100% rename from test-server/CHANGES.md rename to actix-http-test/CHANGES.md diff --git a/test-server/Cargo.toml b/actix-http-test/Cargo.toml similarity index 100% rename from test-server/Cargo.toml rename to actix-http-test/Cargo.toml diff --git a/test-server/LICENSE-APACHE b/actix-http-test/LICENSE-APACHE similarity index 100% rename from test-server/LICENSE-APACHE rename to actix-http-test/LICENSE-APACHE diff --git a/test-server/LICENSE-MIT b/actix-http-test/LICENSE-MIT similarity index 100% rename from test-server/LICENSE-MIT rename to actix-http-test/LICENSE-MIT diff --git a/test-server/README.md b/actix-http-test/README.md similarity index 100% rename from test-server/README.md rename to actix-http-test/README.md diff --git a/test-server/src/lib.rs b/actix-http-test/src/lib.rs similarity index 100% rename from test-server/src/lib.rs rename to actix-http-test/src/lib.rs diff --git a/actix-http/src/header/common/content_disposition.rs b/actix-http/src/header/common/content_disposition.rs index 37da830ca..826cfef63 100644 --- a/actix-http/src/header/common/content_disposition.rs +++ b/actix-http/src/header/common/content_disposition.rs @@ -550,8 +550,7 @@ impl fmt::Display for ContentDisposition { write!(f, "{}", self.disposition)?; self.parameters .iter() - .map(|param| write!(f, "; {}", param)) - .collect() + .try_for_each(|param| write!(f, "; {}", param)) } } diff --git a/actix-http/src/header/shared/entity.rs b/actix-http/src/header/shared/entity.rs index 3525a19c6..344cfb864 100644 --- a/actix-http/src/header/shared/entity.rs +++ b/actix-http/src/header/shared/entity.rs @@ -7,10 +7,12 @@ use crate::header::{HeaderValue, IntoHeaderValue, InvalidHeaderValue, Writer}; /// 1. `%x21`, or /// 2. in the range `%x23` to `%x7E`, or /// 3. above `%x80` +fn entity_validate_char(c: u8) -> bool { + c == 0x21 || (0x23..=0x7e).contains(&c) || (c >= 0x80) +} + fn check_slice_validity(slice: &str) -> bool { - slice - .bytes() - .all(|c| c == b'\x21' || (c >= b'\x23' && c <= b'\x7e') | (c >= b'\x80')) + slice.bytes().all(entity_validate_char) } /// An entity tag, defined in [RFC7232](https://tools.ietf.org/html/rfc7232#section-2.3) diff --git a/awc/CHANGES.md b/awc/CHANGES.md index dfd8e3704..7ca415336 100644 --- a/awc/CHANGES.md +++ b/awc/CHANGES.md @@ -1,6 +1,9 @@ # Changes ## Unreleased - 2020-xx-xx + + +## 2.0.3 - 2020-11-29 ### Fixed * Ensure `actix-http` dependency uses same `serde_urlencoded`. diff --git a/awc/src/ws.rs b/awc/src/ws.rs index 57e80bd46..aa474697b 100644 --- a/awc/src/ws.rs +++ b/awc/src/ws.rs @@ -70,9 +70,14 @@ impl WebsocketsRequest { >::Error: Into, { let mut err = None; - let mut head = RequestHead::default(); - head.method = Method::GET; - head.version = Version::HTTP_11; + + #[allow(clippy::field_reassign_with_default)] + let mut head = { + let mut head = RequestHead::default(); + head.method = Method::GET; + head.version = Version::HTTP_11; + head + }; match Uri::try_from(uri) { Ok(uri) => head.uri = uri, diff --git a/codecov.yml b/codecov.yml index 90cdfab47..102e8969d 100644 --- a/codecov.yml +++ b/codecov.yml @@ -1,4 +1,13 @@ -ignore: # ignore codecoverage on following paths +coverage: + status: + project: + default: + threshold: 10% # make CI green + patch: + default: + threshold: 10% # make CI green + +ignore: # ignore code coverage on following paths - "**/tests" - "test-server" - "**/benches" diff --git a/src/middleware/compress.rs b/src/middleware/compress.rs index fe3ba841c..7575d7455 100644 --- a/src/middleware/compress.rs +++ b/src/middleware/compress.rs @@ -192,10 +192,7 @@ impl AcceptEncoding { }; let quality = match parts.len() { 1 => encoding.quality(), - _ => match f64::from_str(parts[1]) { - Ok(q) => q, - Err(_) => 0.0, - }, + _ => f64::from_str(parts[1]).unwrap_or(0.0), }; Some(AcceptEncoding { encoding, quality }) } diff --git a/src/middleware/condition.rs b/src/middleware/condition.rs index ab1c69746..9061c7458 100644 --- a/src/middleware/condition.rs +++ b/src/middleware/condition.rs @@ -105,6 +105,7 @@ mod tests { use crate::test::{self, TestRequest}; use crate::HttpResponse; + #[allow(clippy::unnecessary_wraps)] fn render_500(mut res: ServiceResponse) -> Result> { res.response_mut() .headers_mut() diff --git a/src/middleware/errhandlers.rs b/src/middleware/errhandlers.rs index 93a5d3f22..c0cb9594e 100644 --- a/src/middleware/errhandlers.rs +++ b/src/middleware/errhandlers.rs @@ -154,6 +154,7 @@ mod tests { use crate::test::{self, TestRequest}; use crate::HttpResponse; + #[allow(clippy::unnecessary_wraps)] fn render_500(mut res: ServiceResponse) -> Result> { res.response_mut() .headers_mut() diff --git a/src/route.rs b/src/route.rs index e9e9d1f5d..45efd9e3c 100644 --- a/src/route.rs +++ b/src/route.rs @@ -16,24 +16,24 @@ use crate::responder::Responder; use crate::service::{ServiceRequest, ServiceResponse}; use crate::HttpResponse; -type BoxedRouteService = Box< +type BoxedRouteService = Box< dyn Service< - Request = Req, - Response = Res, + Request = ServiceRequest, + Response = ServiceResponse, Error = Error, - Future = LocalBoxFuture<'static, Result>, + Future = LocalBoxFuture<'static, Result>, >, >; -type BoxedRouteNewService = Box< +type BoxedRouteNewService = Box< dyn ServiceFactory< Config = (), - Request = Req, - Response = Res, + Request = ServiceRequest, + Response = ServiceResponse, Error = Error, InitError = (), - Service = BoxedRouteService, - Future = LocalBoxFuture<'static, Result, ()>>, + Service = BoxedRouteService, + Future = LocalBoxFuture<'static, Result>, >, >; @@ -42,7 +42,7 @@ type BoxedRouteNewService = Box< /// Route uses builder-like pattern for configuration. /// If handler is not explicitly set, default *404 Not Found* handler is used. pub struct Route { - service: BoxedRouteNewService, + service: BoxedRouteNewService, guards: Rc>>, } @@ -80,15 +80,8 @@ impl ServiceFactory for Route { } } -type RouteFuture = LocalBoxFuture< - 'static, - Result, ()>, ->; - -#[pin_project::pin_project] pub struct CreateRouteService { - #[pin] - fut: RouteFuture, + fut: LocalBoxFuture<'static, Result>, guards: Rc>>, } @@ -96,9 +89,9 @@ impl Future for CreateRouteService { type Output = Result; fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { - let this = self.project(); + let this = self.get_mut(); - match this.fut.poll(cx)? { + match this.fut.as_mut().poll(cx)? { Poll::Ready(service) => Poll::Ready(Ok(RouteService { service, guards: this.guards.clone(), @@ -109,7 +102,7 @@ impl Future for CreateRouteService { } pub struct RouteService { - service: BoxedRouteService, + service: BoxedRouteService, guards: Rc>>, } @@ -135,7 +128,7 @@ impl Service for RouteService { } fn call(&mut self, req: ServiceRequest) -> Self::Future { - self.service.call(req).boxed_local() + self.service.call(req) } } @@ -275,12 +268,12 @@ where T::Service: 'static, ::Future: 'static, { - type Config = (); type Request = ServiceRequest; type Response = ServiceResponse; type Error = Error; + type Config = (); + type Service = BoxedRouteService; type InitError = (); - type Service = BoxedRouteService; type Future = LocalBoxFuture<'static, Result>; fn new_service(&self, _: ()) -> Self::Future { @@ -288,8 +281,7 @@ where .new_service(()) .map(|result| match result { Ok(service) => { - let service: BoxedRouteService<_, _> = - Box::new(RouteServiceWrapper { service }); + let service = Box::new(RouteServiceWrapper { service }) as _; Ok(service) } Err(_) => Err(()), diff --git a/src/test.rs b/src/test.rs index ee51b71ee..cff6c3e51 100644 --- a/src/test.rs +++ b/src/test.rs @@ -269,8 +269,9 @@ where { let body = read_body(res).await; - serde_json::from_slice(&body) - .unwrap_or_else(|_| panic!("read_response_json failed during deserialization")) + serde_json::from_slice(&body).unwrap_or_else(|e| { + panic!("read_response_json failed during deserialization: {}", e) + }) } pub async fn load_stream(mut stream: S) -> Result diff --git a/src/types/payload.rs b/src/types/payload.rs index 4ff5ef4b4..fdc1f8c8a 100644 --- a/src/types/payload.rs +++ b/src/types/payload.rs @@ -241,9 +241,10 @@ pub struct PayloadConfig { impl PayloadConfig { /// Create `PayloadConfig` instance and set max size of payload. pub fn new(limit: usize) -> Self { - let mut cfg = Self::default(); - cfg.limit = limit; - cfg + Self { + limit, + ..Default::default() + } } /// Change max size of payload. By default max size is 256Kb