From fdef224a0691df475337ddfc1693da32148cfba8 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Sat, 23 Dec 2023 18:49:17 +0000 Subject: [PATCH 001/151] docs: document internal Path fields --- actix-router/src/path.rs | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/actix-router/src/path.rs b/actix-router/src/path.rs index dc4150dd..467420cd 100644 --- a/actix-router/src/path.rs +++ b/actix-router/src/path.rs @@ -3,7 +3,7 @@ use std::{ ops::{DerefMut, Index}, }; -use serde::de; +use serde::{de, Deserialize}; use crate::{de::PathDeserializer, Resource, ResourcePath}; @@ -24,8 +24,13 @@ impl Default for PathItem { /// If resource path contains variable patterns, `Path` stores them. #[derive(Debug, Clone, Default)] pub struct Path { + /// Full path representation. path: T, + + /// Number of characters in `path` that have been processed into `segments`. pub(crate) skip: u16, + + /// List of processed dynamic segments; name->value pairs. pub(crate) segments: Vec<(Cow<'static, str>, PathItem)>, } @@ -83,8 +88,8 @@ impl Path { /// Set new path. #[inline] pub fn set(&mut self, path: T) { - self.skip = 0; self.path = path; + self.skip = 0; self.segments.clear(); } @@ -103,7 +108,7 @@ impl Path { pub(crate) fn add(&mut self, name: impl Into>, value: PathItem) { match value { - PathItem::Static(s) => self.segments.push((name.into(), PathItem::Static(s))), + PathItem::Static(seg) => self.segments.push((name.into(), PathItem::Static(seg))), PathItem::Segment(begin, end) => self.segments.push(( name.into(), PathItem::Segment(self.skip + begin, self.skip + end), @@ -168,9 +173,13 @@ impl Path { } } - /// Try to deserialize matching parameters to a specified type `U` - pub fn load<'de, U: serde::Deserialize<'de>>(&'de self) -> Result { - de::Deserialize::deserialize(PathDeserializer::new(self)) + /// Deserializes matching parameters to a specified type `U`. + /// + /// # Errors + /// + /// Returns error when dynamic path segments cannot be deserialized into a `U` type. + pub fn load<'de, U: Deserialize<'de>>(&'de self) -> Result { + Deserialize::deserialize(PathDeserializer::new(self)) } } From ff2904ee785698232fbcd01c20a9104ec7122ff2 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Sat, 23 Dec 2023 19:13:11 +0000 Subject: [PATCH 002/151] ci: prevent cargo-cache install failing MSRV builds --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5627865c..d71a03d1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -83,7 +83,7 @@ jobs: - name: Clear the cargo caches run: | - cargo install cargo-cache --version 0.8.3 --no-default-features --features ci-autoclean + cargo --locked install cargo-cache --version 0.8.3 --no-default-features --features ci-autoclean cargo-cache io-uring: From 0d9ca4d9390a4ae43f836c2e1752dea7b764cb7b Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Sat, 23 Dec 2023 19:17:56 +0000 Subject: [PATCH 003/151] chore(actix-http): prepare release 3.5.0 --- actix-http/CHANGES.md | 6 ++++-- actix-http/Cargo.toml | 2 +- actix-http/README.md | 4 ++-- actix-web/Cargo.toml | 2 +- awc/Cargo.toml | 4 ++-- scripts/bump | 3 ++- 6 files changed, 12 insertions(+), 9 deletions(-) diff --git a/actix-http/CHANGES.md b/actix-http/CHANGES.md index eadd5c51..3068b4ce 100644 --- a/actix-http/CHANGES.md +++ b/actix-http/CHANGES.md @@ -2,14 +2,16 @@ ## Unreleased +## 3.5.0 + ### Changed +- Implement `From` for `http::HeaderMap`. - Updated `zstd` dependency to `0.13`. -- Implemented `From` for `http::HeaderMap`. ### Fixed -- Do not encode zero-sized response bodies +- Prevent compression of zero-sized response bodies. ## 3.4.0 diff --git a/actix-http/Cargo.toml b/actix-http/Cargo.toml index 8476d908..93a6bcba 100644 --- a/actix-http/Cargo.toml +++ b/actix-http/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "actix-http" -version = "3.4.0" +version = "3.5.0" authors = [ "Nikolay Kim ", "Rob Ede ", diff --git a/actix-http/README.md b/actix-http/README.md index 7d499f4b..790de65f 100644 --- a/actix-http/README.md +++ b/actix-http/README.md @@ -5,11 +5,11 @@ [![crates.io](https://img.shields.io/crates/v/actix-http?label=latest)](https://crates.io/crates/actix-http) -[![Documentation](https://docs.rs/actix-http/badge.svg?version=3.4.0)](https://docs.rs/actix-http/3.4.0) +[![Documentation](https://docs.rs/actix-http/badge.svg?version=3.5.0)](https://docs.rs/actix-http/3.5.0) ![Version](https://img.shields.io/badge/rustc-1.68+-ab6000.svg) ![MIT or Apache 2.0 licensed](https://img.shields.io/crates/l/actix-http.svg)
-[![dependency status](https://deps.rs/crate/actix-http/3.4.0/status.svg)](https://deps.rs/crate/actix-http/3.4.0) +[![dependency status](https://deps.rs/crate/actix-http/3.5.0/status.svg)](https://deps.rs/crate/actix-http/3.5.0) [![Download](https://img.shields.io/crates/d/actix-http.svg)](https://crates.io/crates/actix-http) [![Chat on Discord](https://img.shields.io/discord/771444961383153695?label=chat&logo=discord)](https://discord.gg/NWpN5mmg3x) diff --git a/actix-web/Cargo.toml b/actix-web/Cargo.toml index d9cf0b94..200524d0 100644 --- a/actix-web/Cargo.toml +++ b/actix-web/Cargo.toml @@ -75,7 +75,7 @@ actix-service = "2" actix-utils = "3" actix-tls = { version = "3.1", default-features = false, optional = true } -actix-http = { version = "3.4", features = ["ws"] } +actix-http = { version = "3.5", features = ["ws"] } actix-router = "0.5" actix-web-codegen = { version = "4.2", optional = true } diff --git a/awc/Cargo.toml b/awc/Cargo.toml index 07811c97..294e1a56 100644 --- a/awc/Cargo.toml +++ b/awc/Cargo.toml @@ -61,7 +61,7 @@ dangerous-h2c = [] [dependencies] actix-codec = "0.5" actix-service = "2" -actix-http = { version = "3.4", features = ["http2", "ws"] } +actix-http = { version = "3.5", features = ["http2", "ws"] } actix-rt = { version = "2.1", default-features = false } actix-tls = { version = "3.1", features = ["connect", "uri"] } actix-utils = "3" @@ -94,7 +94,7 @@ tls-rustls-0_21 = { package = "rustls", version = "0.21", optional = true, featu trust-dns-resolver = { version = "0.23", optional = true } [dev-dependencies] -actix-http = { version = "3.4", features = ["openssl"] } +actix-http = { version = "3.5", features = ["openssl"] } actix-http-test = { version = "3", features = ["openssl"] } actix-server = "2" actix-test = { version = "0.1", features = ["openssl", "rustls-0_21"] } diff --git a/scripts/bump b/scripts/bump index 9d90542c..68f923e7 100755 --- a/scripts/bump +++ b/scripts/bump @@ -5,7 +5,7 @@ # requires github cli tool for automatic release draft creation -set -euo pipefail +set -eEuo pipefail DIR=$1 @@ -132,6 +132,7 @@ fi if [ $MACOS ]; then printf "chore($PACKAGE_NAME): prepare release $NEW_VERSION" | pbcopy + echo "placed the recommended commit message on the clipboard" else echo echo "commit message:" From 17060ed9930dd5cfb46b0c15602e75259265aaf6 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Sat, 23 Dec 2023 19:18:29 +0000 Subject: [PATCH 004/151] chore(awc): prepare release 3.3.0 --- awc/CHANGES.md | 2 ++ awc/Cargo.toml | 2 +- awc/README.md | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/awc/CHANGES.md b/awc/CHANGES.md index 3a1996cb..6f4212f9 100644 --- a/awc/CHANGES.md +++ b/awc/CHANGES.md @@ -2,6 +2,8 @@ ## Unreleased +## 3.3.0 + - Update `trust-dns-resolver` dependency to `0.23`. - Updated `zstd` dependency to `0.13`. diff --git a/awc/Cargo.toml b/awc/Cargo.toml index 294e1a56..14009fb4 100644 --- a/awc/Cargo.toml +++ b/awc/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "awc" -version = "3.2.0" +version = "3.3.0" authors = ["Nikolay Kim "] description = "Async HTTP and WebSocket client library" keywords = ["actix", "http", "framework", "async", "web"] diff --git a/awc/README.md b/awc/README.md index 1f31167e..035348fb 100644 --- a/awc/README.md +++ b/awc/README.md @@ -3,9 +3,9 @@ > Async HTTP and WebSocket client library. [![crates.io](https://img.shields.io/crates/v/awc?label=latest)](https://crates.io/crates/awc) -[![Documentation](https://docs.rs/awc/badge.svg?version=3.2.0)](https://docs.rs/awc/3.2.0) +[![Documentation](https://docs.rs/awc/badge.svg?version=3.3.0)](https://docs.rs/awc/3.3.0) ![MIT or Apache 2.0 licensed](https://img.shields.io/crates/l/awc) -[![Dependency Status](https://deps.rs/crate/awc/3.2.0/status.svg)](https://deps.rs/crate/awc/3.2.0) +[![Dependency Status](https://deps.rs/crate/awc/3.3.0/status.svg)](https://deps.rs/crate/awc/3.3.0) [![Chat on Discord](https://img.shields.io/discord/771444961383153695?label=chat&logo=discord)](https://discord.gg/NWpN5mmg3x) ## Documentation & Resources From 9dc3ad754e5a7a044dd6aeeba9d4ba3dd5a90db0 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Sat, 23 Dec 2023 19:19:10 +0000 Subject: [PATCH 005/151] chore(actix-web): prepare release 4.4.1 --- actix-web/CHANGES.md | 2 ++ actix-web/Cargo.toml | 2 +- actix-web/README.md | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/actix-web/CHANGES.md b/actix-web/CHANGES.md index 953befb7..674c834a 100644 --- a/actix-web/CHANGES.md +++ b/actix-web/CHANGES.md @@ -2,6 +2,8 @@ ## Unreleased +## 4.4.1 + ### Changed - Updated `zstd` dependency to `0.13`. diff --git a/actix-web/Cargo.toml b/actix-web/Cargo.toml index 200524d0..d1fc9c91 100644 --- a/actix-web/Cargo.toml +++ b/actix-web/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "actix-web" -version = "4.4.0" +version = "4.4.1" description = "Actix Web is a powerful, pragmatic, and extremely fast web framework for Rust" authors = [ "Nikolay Kim ", diff --git a/actix-web/README.md b/actix-web/README.md index e8339765..80ae2123 100644 --- a/actix-web/README.md +++ b/actix-web/README.md @@ -8,10 +8,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=4.4.0)](https://docs.rs/actix-web/4.4.0) +[![Documentation](https://docs.rs/actix-web/badge.svg?version=4.4.1)](https://docs.rs/actix-web/4.4.1) ![MSRV](https://img.shields.io/badge/rustc-1.68+-ab6000.svg) ![MIT or Apache 2.0 licensed](https://img.shields.io/crates/l/actix-web.svg) -[![Dependency Status](https://deps.rs/crate/actix-web/4.4.0/status.svg)](https://deps.rs/crate/actix-web/4.4.0) +[![Dependency Status](https://deps.rs/crate/actix-web/4.4.1/status.svg)](https://deps.rs/crate/actix-web/4.4.1)
[![CI](https://github.com/actix/actix-web/actions/workflows/ci.yml/badge.svg)](https://github.com/actix/actix-web/actions/workflows/ci.yml) [![codecov](https://codecov.io/gh/actix/actix-web/branch/master/graph/badge.svg)](https://codecov.io/gh/actix/actix-web) From 68597b5426a8ba81bb2674538bec3895cde05a00 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 23 Dec 2023 19:54:02 +0000 Subject: [PATCH 006/151] build(deps): bump taiki-e/install-action from 2.22.0 to 2.23.0 (#3228) Bumps [taiki-e/install-action](https://github.com/taiki-e/install-action) from 2.22.0 to 2.23.0. - [Release notes](https://github.com/taiki-e/install-action/releases) - [Changelog](https://github.com/taiki-e/install-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/taiki-e/install-action/compare/v2.22.0...v2.23.0) --- updated-dependencies: - dependency-name: taiki-e/install-action dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/ci-post-merge.yml | 6 +++--- .github/workflows/ci.yml | 2 +- .github/workflows/coverage.yml | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci-post-merge.yml b/.github/workflows/ci-post-merge.yml index 4c4a3404..72fb7dcf 100644 --- a/.github/workflows/ci-post-merge.yml +++ b/.github/workflows/ci-post-merge.yml @@ -45,7 +45,7 @@ jobs: toolchain: ${{ matrix.version.version }} - name: Install cargo-hack - uses: taiki-e/install-action@v2.22.0 + uses: taiki-e/install-action@v2.23.0 with: tool: cargo-hack @@ -85,7 +85,7 @@ jobs: uses: actions-rust-lang/setup-rust-toolchain@v1.6.0 - name: Install cargo-hack - uses: taiki-e/install-action@v2.22.0 + uses: taiki-e/install-action@v2.23.0 with: tool: cargo-hack @@ -106,7 +106,7 @@ jobs: uses: actions-rust-lang/setup-rust-toolchain@v1.6.0 - name: Install nextest - uses: taiki-e/install-action@v2.22.0 + uses: taiki-e/install-action@v2.23.0 with: tool: nextest diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d71a03d1..721fc037 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -50,7 +50,7 @@ jobs: toolchain: ${{ matrix.version.version }} - name: Install cargo-hack - uses: taiki-e/install-action@v2.22.0 + uses: taiki-e/install-action@v2.23.0 with: tool: cargo-hack diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index c451df22..927ac86b 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -23,7 +23,7 @@ jobs: components: llvm-tools-preview - name: Install cargo-llvm-cov - uses: taiki-e/install-action@v2.22.0 + uses: taiki-e/install-action@v2.23.0 with: tool: cargo-llvm-cov From f4851b39143dbb39587ad98f73da89eb7bab3cba Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Sun, 24 Dec 2023 16:47:46 +0000 Subject: [PATCH 007/151] chore(actix-router): prepare release 0.5.2 --- .github/workflows/ci-post-merge.yml | 2 +- actix-router/CHANGES.md | 2 ++ actix-router/Cargo.toml | 2 +- actix-router/README.md | 4 ++-- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci-post-merge.yml b/.github/workflows/ci-post-merge.yml index 72fb7dcf..f135cd17 100644 --- a/.github/workflows/ci-post-merge.yml +++ b/.github/workflows/ci-post-merge.yml @@ -71,7 +71,7 @@ jobs: - name: Clear the cargo caches run: | - cargo install cargo-cache --version 0.8.3 --no-default-features --features ci-autoclean + cargo --locked install cargo-cache --version 0.8.3 --no-default-features --features ci-autoclean cargo-cache ci_feature_powerset_check: diff --git a/actix-router/CHANGES.md b/actix-router/CHANGES.md index 31316ff4..a855c007 100644 --- a/actix-router/CHANGES.md +++ b/actix-router/CHANGES.md @@ -2,6 +2,8 @@ ## Unreleased +## 0.5.2 + - Minimum supported Rust version (MSRV) is now 1.68 due to transitive `time` dependency. ## 0.5.1 diff --git a/actix-router/Cargo.toml b/actix-router/Cargo.toml index 8a404dd2..de39944c 100644 --- a/actix-router/Cargo.toml +++ b/actix-router/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "actix-router" -version = "0.5.1" +version = "0.5.2" authors = [ "Nikolay Kim ", "Ali MJ Al-Nasrawy ", diff --git a/actix-router/README.md b/actix-router/README.md index 15a449c4..7dc0c901 100644 --- a/actix-router/README.md +++ b/actix-router/README.md @@ -1,11 +1,11 @@ # `actix-router` [![crates.io](https://img.shields.io/crates/v/actix-router?label=latest)](https://crates.io/crates/actix-router) -[![Documentation](https://docs.rs/actix-router/badge.svg?version=0.5.1)](https://docs.rs/actix-router/0.5.1) +[![Documentation](https://docs.rs/actix-router/badge.svg?version=0.5.2)](https://docs.rs/actix-router/0.5.2) ![Version](https://img.shields.io/badge/rustc-1.68+-ab6000.svg) ![MIT or Apache 2.0 licensed](https://img.shields.io/crates/l/actix-router.svg)
-[![dependency status](https://deps.rs/crate/actix-router/0.5.1/status.svg)](https://deps.rs/crate/actix-router/0.5.1) +[![dependency status](https://deps.rs/crate/actix-router/0.5.2/status.svg)](https://deps.rs/crate/actix-router/0.5.2) [![Download](https://img.shields.io/crates/d/actix-router.svg)](https://crates.io/crates/actix-router) [![Chat on Discord](https://img.shields.io/discord/771444961383153695?label=chat&logo=discord)](https://discord.gg/NWpN5mmg3x) From d14e98b62b866e75c84baa19e36bf2d0bb7d49e7 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Mon, 25 Dec 2023 02:27:51 +0000 Subject: [PATCH 008/151] prevent hang when compressing Sized(0) bodies fixes #3229 --- actix-http/CHANGES.md | 4 ++++ actix-http/src/encoding/encoder.rs | 17 ++++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/actix-http/CHANGES.md b/actix-http/CHANGES.md index 3068b4ce..053c4e51 100644 --- a/actix-http/CHANGES.md +++ b/actix-http/CHANGES.md @@ -2,6 +2,10 @@ ## Unreleased +## Fixed + +- Prevent hang when returning zero-sized response bodies through compression layer. + ## 3.5.0 ### Changed diff --git a/actix-http/src/encoding/encoder.rs b/actix-http/src/encoding/encoder.rs index e084aa56..180927ac 100644 --- a/actix-http/src/encoding/encoder.rs +++ b/actix-http/src/encoding/encoder.rs @@ -50,10 +50,21 @@ impl Encoder { } } + fn empty() -> Self { + Encoder { + body: EncoderBody::Full { body: Bytes::new() }, + encoder: None, + fut: None, + eof: true, + } + } + pub fn response(encoding: ContentEncoding, head: &mut ResponseHead, body: B) -> Self { - // no need to compress an empty body - if matches!(body.size(), BodySize::None | BodySize::Sized(0)) { - return Self::none(); + // no need to compress empty bodies + match body.size() { + BodySize::None => return Self::none(), + BodySize::Sized(0) => return Self::empty(), + _ => {} } let should_encode = !(head.headers().contains_key(&CONTENT_ENCODING) From f4f459d4209da58fe0c2794617c95b06fd9d0fc7 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Mon, 25 Dec 2023 02:30:14 +0000 Subject: [PATCH 009/151] chore(actix-http): prepare release 3.5.1 --- actix-http/CHANGES.md | 2 ++ actix-http/Cargo.toml | 2 +- actix-http/README.md | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/actix-http/CHANGES.md b/actix-http/CHANGES.md index 053c4e51..8a59f433 100644 --- a/actix-http/CHANGES.md +++ b/actix-http/CHANGES.md @@ -2,6 +2,8 @@ ## Unreleased +## 3.5.1 + ## Fixed - Prevent hang when returning zero-sized response bodies through compression layer. diff --git a/actix-http/Cargo.toml b/actix-http/Cargo.toml index 93a6bcba..6c53f35c 100644 --- a/actix-http/Cargo.toml +++ b/actix-http/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "actix-http" -version = "3.5.0" +version = "3.5.1" authors = [ "Nikolay Kim ", "Rob Ede ", diff --git a/actix-http/README.md b/actix-http/README.md index 790de65f..9d80c10c 100644 --- a/actix-http/README.md +++ b/actix-http/README.md @@ -5,11 +5,11 @@ [![crates.io](https://img.shields.io/crates/v/actix-http?label=latest)](https://crates.io/crates/actix-http) -[![Documentation](https://docs.rs/actix-http/badge.svg?version=3.5.0)](https://docs.rs/actix-http/3.5.0) +[![Documentation](https://docs.rs/actix-http/badge.svg?version=3.5.1)](https://docs.rs/actix-http/3.5.1) ![Version](https://img.shields.io/badge/rustc-1.68+-ab6000.svg) ![MIT or Apache 2.0 licensed](https://img.shields.io/crates/l/actix-http.svg)
-[![dependency status](https://deps.rs/crate/actix-http/3.5.0/status.svg)](https://deps.rs/crate/actix-http/3.5.0) +[![dependency status](https://deps.rs/crate/actix-http/3.5.1/status.svg)](https://deps.rs/crate/actix-http/3.5.1) [![Download](https://img.shields.io/crates/d/actix-http.svg)](https://crates.io/crates/actix-http) [![Chat on Discord](https://img.shields.io/discord/771444961383153695?label=chat&logo=discord)](https://discord.gg/NWpN5mmg3x) From 1c88af50c07ef704a8899d7b3eff954d9513a6d2 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Mon, 25 Dec 2023 02:35:22 +0000 Subject: [PATCH 010/151] docs: fix changelog --- actix-http/CHANGES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/actix-http/CHANGES.md b/actix-http/CHANGES.md index 8a59f433..bec36799 100644 --- a/actix-http/CHANGES.md +++ b/actix-http/CHANGES.md @@ -4,7 +4,7 @@ ## 3.5.1 -## Fixed +### Fixed - Prevent hang when returning zero-sized response bodies through compression layer. From ccb90dd5a195e278d3a00795454063c391daf990 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Mon, 25 Dec 2023 02:36:17 +0000 Subject: [PATCH 011/151] docs: update changelog --- actix-http/CHANGES.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/actix-http/CHANGES.md b/actix-http/CHANGES.md index bec36799..994c91a8 100644 --- a/actix-http/CHANGES.md +++ b/actix-http/CHANGES.md @@ -10,9 +10,12 @@ ## 3.5.0 -### Changed +### Added - Implement `From` for `http::HeaderMap`. + +### Changed + - Updated `zstd` dependency to `0.13`. ### Fixed From 561cc440b2405746d3de01f6983c9c8616a370fb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 Jan 2024 14:10:13 +0000 Subject: [PATCH 012/151] build(deps): bump taiki-e/install-action from 2.23.0 to 2.23.7 (#3232) Bumps [taiki-e/install-action](https://github.com/taiki-e/install-action) from 2.23.0 to 2.23.7. - [Release notes](https://github.com/taiki-e/install-action/releases) - [Changelog](https://github.com/taiki-e/install-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/taiki-e/install-action/compare/v2.23.0...v2.23.7) --- updated-dependencies: - dependency-name: taiki-e/install-action dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/ci-post-merge.yml | 6 +++--- .github/workflows/ci.yml | 2 +- .github/workflows/coverage.yml | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci-post-merge.yml b/.github/workflows/ci-post-merge.yml index f135cd17..df6f2168 100644 --- a/.github/workflows/ci-post-merge.yml +++ b/.github/workflows/ci-post-merge.yml @@ -45,7 +45,7 @@ jobs: toolchain: ${{ matrix.version.version }} - name: Install cargo-hack - uses: taiki-e/install-action@v2.23.0 + uses: taiki-e/install-action@v2.23.7 with: tool: cargo-hack @@ -85,7 +85,7 @@ jobs: uses: actions-rust-lang/setup-rust-toolchain@v1.6.0 - name: Install cargo-hack - uses: taiki-e/install-action@v2.23.0 + uses: taiki-e/install-action@v2.23.7 with: tool: cargo-hack @@ -106,7 +106,7 @@ jobs: uses: actions-rust-lang/setup-rust-toolchain@v1.6.0 - name: Install nextest - uses: taiki-e/install-action@v2.23.0 + uses: taiki-e/install-action@v2.23.7 with: tool: nextest diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 721fc037..81139fa2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -50,7 +50,7 @@ jobs: toolchain: ${{ matrix.version.version }} - name: Install cargo-hack - uses: taiki-e/install-action@v2.23.0 + uses: taiki-e/install-action@v2.23.7 with: tool: cargo-hack diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 927ac86b..810ea33d 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -23,7 +23,7 @@ jobs: components: llvm-tools-preview - name: Install cargo-llvm-cov - uses: taiki-e/install-action@v2.23.0 + uses: taiki-e/install-action@v2.23.7 with: tool: cargo-llvm-cov From febba786fa00a61c6be6c26db148a29261b056c9 Mon Sep 17 00:00:00 2001 From: Sven-Hendrik Haase Date: Sat, 6 Jan 2024 11:11:40 +0100 Subject: [PATCH 013/151] actix-files: Properly handle newlines in file names (#3235) --- actix-files/CHANGES.md | 1 + actix-files/src/lib.rs | 22 +++++++++++++++++++++- actix-files/src/named.rs | 7 ++++--- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/actix-files/CHANGES.md b/actix-files/CHANGES.md index 15c2958f..81e361a2 100644 --- a/actix-files/CHANGES.md +++ b/actix-files/CHANGES.md @@ -3,6 +3,7 @@ ## Unreleased - Minimum supported Rust version (MSRV) is now 1.68 due to transitive `time` dependency. +- Properly handle newlines in filenames. [#3235] ## 0.6.3 diff --git a/actix-files/src/lib.rs b/actix-files/src/lib.rs index 943130e1..87914c1c 100644 --- a/actix-files/src/lib.rs +++ b/actix-files/src/lib.rs @@ -568,6 +568,26 @@ mod tests { assert_eq!(bytes, data); } + #[actix_rt::test] + async fn test_static_files_with_newlines() { + // Create the file we want to test against ad-hoc. We can't check it in as otherwise + // Windows can't even checkout this repository. + let tmpdir = tempfile::tempdir().unwrap(); + let file_with_newlines = tmpdir.path().join("test\nnewline.text"); + fs::write(&file_with_newlines, "Look at my newlines").unwrap(); + let srv = test::init_service( + App::new().service(Files::new("", tmpdir.path()).index_file("Cargo.toml")), + ) + .await; + let request = TestRequest::get().uri("/test%0Anewline.text").to_request(); + let response = test::call_service(&srv, request).await; + assert_eq!(response.status(), StatusCode::OK); + + let bytes = test::read_body(response).await; + let data = web::Bytes::from(fs::read(file_with_newlines).unwrap()); + assert_eq!(bytes, data); + } + #[actix_rt::test] async fn test_files_not_allowed() { let srv = test::init_service(App::new().service(Files::new("/", "."))).await; @@ -842,7 +862,7 @@ mod tests { async fn test_percent_encoding_2() { let tmpdir = tempfile::tempdir().unwrap(); let filename = match cfg!(unix) { - true => "ض:?#[]{}<>()@!$&'`|*+,;= %20.test", + true => "ض:?#[]{}<>()@!$&'`|*+,;= %20\n.test", false => "ض#[]{}()@!$&'`+,;= %20.test", }; let filename_encoded = filename diff --git a/actix-files/src/named.rs b/actix-files/src/named.rs index d7795ba7..02dc701e 100644 --- a/actix-files/src/named.rs +++ b/actix-files/src/named.rs @@ -24,7 +24,6 @@ use bitflags::bitflags; use derive_more::{Deref, DerefMut}; use futures_core::future::LocalBoxFuture; use mime::Mime; -use mime_guess::from_path; use crate::{encoding::equiv_utf8_text, range::HttpRange}; @@ -128,7 +127,7 @@ impl NamedFile { } }; - let ct = from_path(&path).first_or_octet_stream(); + let ct = mime_guess::from_path(&path).first_or_octet_stream(); let disposition = match ct.type_() { mime::IMAGE | mime::TEXT | mime::AUDIO | mime::VIDEO => DispositionType::Inline, @@ -140,7 +139,9 @@ impl NamedFile { _ => DispositionType::Attachment, }; - let mut parameters = vec![DispositionParam::Filename(String::from(filename.as_ref()))]; + // Replace newlines in filenames which could occur on some filesystems. + let filename_s = filename.replace('\n', "%0A"); + let mut parameters = vec![DispositionParam::Filename(filename_s)]; if !filename.is_ascii() { parameters.push(DispositionParam::FilenameExt(ExtendedValue { From 46dde69d502d6800fadec2bf1401586b6090ee11 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Sat, 6 Jan 2024 10:19:15 +0000 Subject: [PATCH 014/151] chore(actix-files): prepare release 0.6.4 --- actix-files/CHANGES.md | 4 +++- actix-files/Cargo.toml | 2 +- actix-files/README.md | 4 ++-- actix-files/src/lib.rs | 13 +++++++------ 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/actix-files/CHANGES.md b/actix-files/CHANGES.md index 81e361a2..ac0fbfed 100644 --- a/actix-files/CHANGES.md +++ b/actix-files/CHANGES.md @@ -2,8 +2,10 @@ ## Unreleased +## 0.6.4 + +- Fix handling of newlines in filenames. - Minimum supported Rust version (MSRV) is now 1.68 due to transitive `time` dependency. -- Properly handle newlines in filenames. [#3235] ## 0.6.3 diff --git a/actix-files/Cargo.toml b/actix-files/Cargo.toml index efecb088..b7a27251 100644 --- a/actix-files/Cargo.toml +++ b/actix-files/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "actix-files" -version = "0.6.3" +version = "0.6.4" authors = [ "Nikolay Kim ", "Rob Ede ", diff --git a/actix-files/README.md b/actix-files/README.md index 3e656c43..d8d9e4f1 100644 --- a/actix-files/README.md +++ b/actix-files/README.md @@ -3,11 +3,11 @@ > Static file serving for Actix Web [![crates.io](https://img.shields.io/crates/v/actix-files?label=latest)](https://crates.io/crates/actix-files) -[![Documentation](https://docs.rs/actix-files/badge.svg?version=0.6.3)](https://docs.rs/actix-files/0.6.3) +[![Documentation](https://docs.rs/actix-files/badge.svg?version=0.6.4)](https://docs.rs/actix-files/0.6.4) ![Version](https://img.shields.io/badge/rustc-1.68+-ab6000.svg) ![License](https://img.shields.io/crates/l/actix-files.svg)
-[![dependency status](https://deps.rs/crate/actix-files/0.6.3/status.svg)](https://deps.rs/crate/actix-files/0.6.3) +[![dependency status](https://deps.rs/crate/actix-files/0.6.4/status.svg)](https://deps.rs/crate/actix-files/0.6.4) [![Download](https://img.shields.io/crates/d/actix-files.svg)](https://crates.io/crates/actix-files) [![Chat on Discord](https://img.shields.io/discord/771444961383153695?label=chat&logo=discord)](https://discord.gg/NWpN5mmg3x) diff --git a/actix-files/src/lib.rs b/actix-files/src/lib.rs index 87914c1c..8ceb59be 100644 --- a/actix-files/src/lib.rs +++ b/actix-files/src/lib.rs @@ -572,11 +572,12 @@ mod tests { async fn test_static_files_with_newlines() { // Create the file we want to test against ad-hoc. We can't check it in as otherwise // Windows can't even checkout this repository. - let tmpdir = tempfile::tempdir().unwrap(); - let file_with_newlines = tmpdir.path().join("test\nnewline.text"); + let temp_dir = tempfile::tempdir().unwrap(); + let file_with_newlines = temp_dir.path().join("test\nnewline.text"); fs::write(&file_with_newlines, "Look at my newlines").unwrap(); + let srv = test::init_service( - App::new().service(Files::new("", tmpdir.path()).index_file("Cargo.toml")), + App::new().service(Files::new("/", temp_dir.path()).index_file("Cargo.toml")), ) .await; let request = TestRequest::get().uri("/test%0Anewline.text").to_request(); @@ -860,7 +861,7 @@ mod tests { #[actix_rt::test] async fn test_percent_encoding_2() { - let tmpdir = tempfile::tempdir().unwrap(); + let temp_dir = tempfile::tempdir().unwrap(); let filename = match cfg!(unix) { true => "ض:?#[]{}<>()@!$&'`|*+,;= %20\n.test", false => "ض#[]{}()@!$&'`+,;= %20.test", @@ -872,9 +873,9 @@ mod tests { write!(&mut buf, "%{:02X}", c).unwrap(); buf }); - std::fs::File::create(tmpdir.path().join(filename)).unwrap(); + std::fs::File::create(temp_dir.path().join(filename)).unwrap(); - let srv = test::init_service(App::new().service(Files::new("", tmpdir.path()))).await; + let srv = test::init_service(App::new().service(Files::new("/", temp_dir.path()))).await; let req = TestRequest::get() .uri(&format!("/{}", filename_encoded)) From d2bd549eece6328aad7f2cef63881bd8ca1e1cd3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 8 Jan 2024 01:25:54 +0000 Subject: [PATCH 015/151] build(deps): bump taiki-e/install-action from 2.23.7 to 2.24.1 (#3239) Bumps [taiki-e/install-action](https://github.com/taiki-e/install-action) from 2.23.7 to 2.24.1. - [Release notes](https://github.com/taiki-e/install-action/releases) - [Changelog](https://github.com/taiki-e/install-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/taiki-e/install-action/compare/v2.23.7...v2.24.1) --- updated-dependencies: - dependency-name: taiki-e/install-action dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/ci-post-merge.yml | 6 +++--- .github/workflows/ci.yml | 2 +- .github/workflows/coverage.yml | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci-post-merge.yml b/.github/workflows/ci-post-merge.yml index df6f2168..394d447a 100644 --- a/.github/workflows/ci-post-merge.yml +++ b/.github/workflows/ci-post-merge.yml @@ -45,7 +45,7 @@ jobs: toolchain: ${{ matrix.version.version }} - name: Install cargo-hack - uses: taiki-e/install-action@v2.23.7 + uses: taiki-e/install-action@v2.24.1 with: tool: cargo-hack @@ -85,7 +85,7 @@ jobs: uses: actions-rust-lang/setup-rust-toolchain@v1.6.0 - name: Install cargo-hack - uses: taiki-e/install-action@v2.23.7 + uses: taiki-e/install-action@v2.24.1 with: tool: cargo-hack @@ -106,7 +106,7 @@ jobs: uses: actions-rust-lang/setup-rust-toolchain@v1.6.0 - name: Install nextest - uses: taiki-e/install-action@v2.23.7 + uses: taiki-e/install-action@v2.24.1 with: tool: nextest diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 81139fa2..bcab6219 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -50,7 +50,7 @@ jobs: toolchain: ${{ matrix.version.version }} - name: Install cargo-hack - uses: taiki-e/install-action@v2.23.7 + uses: taiki-e/install-action@v2.24.1 with: tool: cargo-hack diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 810ea33d..bdd15198 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -23,7 +23,7 @@ jobs: components: llvm-tools-preview - name: Install cargo-llvm-cov - uses: taiki-e/install-action@v2.23.7 + uses: taiki-e/install-action@v2.24.1 with: tool: cargo-llvm-cov From ac04d80d8e447f229ecef0d44d0b61edbcd4957e Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Mon, 8 Jan 2024 15:17:36 +0000 Subject: [PATCH 016/151] docs: better docs for peer_addr methods --- actix-http/src/requests/head.rs | 3 ++ actix-http/src/requests/request.rs | 2 +- actix-web/src/service.rs | 7 +-- actix-web/src/test/test_request.rs | 77 ++++++++++++++++-------------- scripts/bump | 16 +++++-- 5 files changed, 60 insertions(+), 45 deletions(-) diff --git a/actix-http/src/requests/head.rs b/actix-http/src/requests/head.rs index 4558801f..2e0c2dbd 100644 --- a/actix-http/src/requests/head.rs +++ b/actix-http/src/requests/head.rs @@ -16,7 +16,10 @@ pub struct RequestHead { pub uri: Uri, pub version: Version, pub headers: HeaderMap, + + /// Will only be None when called in unit tests unless [`TestRequest::peer_addr`] is used. pub peer_addr: Option, + flags: Flags, } diff --git a/actix-http/src/requests/request.rs b/actix-http/src/requests/request.rs index 1750fb2f..6a267a7a 100644 --- a/actix-http/src/requests/request.rs +++ b/actix-http/src/requests/request.rs @@ -173,7 +173,7 @@ impl

Request

{ /// Peer address is the directly connected peer's socket address. If a proxy is used in front of /// the Actix Web server, then it would be address of this proxy. /// - /// Will only return None when called in unit tests. + /// Will only return None when called in unit tests unless set manually. #[inline] pub fn peer_addr(&self) -> Option { self.head().peer_addr diff --git a/actix-web/src/service.rs b/actix-web/src/service.rs index 0e17c994..45122483 100644 --- a/actix-web/src/service.rs +++ b/actix-web/src/service.rs @@ -221,12 +221,9 @@ impl ServiceRequest { /// Returns peer's socket address. /// - /// Peer address is the directly connected peer's socket address. If a proxy is used in front of - /// the Actix Web server, then it would be address of this proxy. + /// See [`HttpRequest::peer_addr`] for more details. /// - /// To get client connection information `ConnectionInfo` should be used. - /// - /// Will only return None when called in unit tests. + /// [`HttpRequest::peer_addr`]: crate::HttpRequest::peer_addr #[inline] pub fn peer_addr(&self) -> Option { self.head().peer_addr diff --git a/actix-web/src/test/test_request.rs b/actix-web/src/test/test_request.rs index 5491af0a..a3945456 100644 --- a/actix-web/src/test/test_request.rs +++ b/actix-web/src/test/test_request.rs @@ -86,76 +86,77 @@ impl Default for TestRequest { #[allow(clippy::wrong_self_convention)] impl TestRequest { - /// Create TestRequest and set request uri - pub fn with_uri(path: &str) -> TestRequest { - TestRequest::default().uri(path) + /// Constructs test request and sets request URI. + pub fn with_uri(uri: &str) -> TestRequest { + TestRequest::default().uri(uri) } - /// Create TestRequest and set method to `Method::GET` + /// Constructs test request with GET method. pub fn get() -> TestRequest { TestRequest::default().method(Method::GET) } - /// Create TestRequest and set method to `Method::POST` + /// Constructs test request with POST method. pub fn post() -> TestRequest { TestRequest::default().method(Method::POST) } - /// Create TestRequest and set method to `Method::PUT` + /// Constructs test request with PUT method. pub fn put() -> TestRequest { TestRequest::default().method(Method::PUT) } - /// Create TestRequest and set method to `Method::PATCH` + /// Constructs test request with PATCH method. pub fn patch() -> TestRequest { TestRequest::default().method(Method::PATCH) } - /// Create TestRequest and set method to `Method::DELETE` + /// Constructs test request with DELETE method. pub fn delete() -> TestRequest { TestRequest::default().method(Method::DELETE) } - /// Set HTTP version of this request + /// Sets HTTP version of this request. pub fn version(mut self, ver: Version) -> Self { self.req.version(ver); self } - /// Set HTTP method of this request + /// Sets method of this request. pub fn method(mut self, meth: Method) -> Self { self.req.method(meth); self } - /// Set HTTP URI of this request + /// Sets URI of this request. pub fn uri(mut self, path: &str) -> Self { self.req.uri(path); self } - /// Insert a header, replacing any that were set with an equivalent field name. + /// Inserts a header, replacing any that were set with an equivalent field name. pub fn insert_header(mut self, header: impl TryIntoHeaderPair) -> Self { self.req.insert_header(header); self } - /// Append a header, keeping any that were set with an equivalent field name. + /// Appends a header, keeping any that were set with an equivalent field name. pub fn append_header(mut self, header: impl TryIntoHeaderPair) -> Self { self.req.append_header(header); self } - /// Set cookie for this request. + /// Sets cookie for this request. #[cfg(feature = "cookies")] pub fn cookie(mut self, cookie: Cookie<'_>) -> Self { self.cookies.add(cookie.into_owned()); self } - /// Set request path pattern parameter. + /// Sets request path pattern parameter. /// /// # Examples + /// /// ``` /// use actix_web::test::TestRequest; /// @@ -171,19 +172,19 @@ impl TestRequest { self } - /// Set peer addr. + /// Sets peer address. pub fn peer_addr(mut self, addr: SocketAddr) -> Self { self.peer_addr = Some(addr); self } - /// Set request payload. + /// Sets request payload. pub fn set_payload(mut self, data: impl Into) -> Self { self.req.set_payload(data); self } - /// Serialize `data` to a URL encoded form and set it as the request payload. + /// Serializes `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: impl Serialize) -> Self { @@ -194,7 +195,7 @@ impl TestRequest { self } - /// Serialize `data` to JSON and set it as the request payload. + /// Serializes `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: impl Serialize) -> Self { @@ -204,27 +205,33 @@ impl TestRequest { self } - /// Set application data. This is equivalent of `App::data()` method - /// for testing purpose. - pub fn data(mut self, data: T) -> Self { - self.app_data.insert(Data::new(data)); - self - } - - /// Set application data. This is equivalent of `App::app_data()` method - /// for testing purpose. + /// Inserts application data. + /// + /// This is equivalent of `App::app_data()` method for testing purpose. pub fn app_data(mut self, data: T) -> Self { self.app_data.insert(data); self } + /// Inserts application data. + /// + /// This is equivalent of `App::data()` method for testing purpose. + #[doc(hidden)] + pub fn data(mut self, data: T) -> Self { + self.app_data.insert(Data::new(data)); + self + } + + /// Sets resource map. #[cfg(test)] - /// Set request config pub(crate) fn rmap(mut self, rmap: ResourceMap) -> Self { self.rmap = rmap; self } + /// Finalizes test request. + /// + /// This request builder will be useless after calling `finish()`. fn finish(&mut self) -> Request { // mut used when cookie feature is enabled #[allow(unused_mut)] @@ -251,14 +258,14 @@ impl TestRequest { req } - /// Complete request creation and generate `Request` instance + /// Finalizes request creation and returns `Request` instance. pub fn to_request(mut self) -> Request { let mut req = self.finish(); req.head_mut().peer_addr = self.peer_addr; req } - /// Complete request creation and generate `ServiceRequest` instance + /// Finalizes request creation and returns `ServiceRequest` instance. pub fn to_srv_request(mut self) -> ServiceRequest { let (mut head, payload) = self.finish().into_parts(); head.peer_addr = self.peer_addr; @@ -279,12 +286,12 @@ impl TestRequest { ) } - /// Complete request creation and generate `ServiceResponse` instance + /// Finalizes request creation and returns `ServiceResponse` instance. pub fn to_srv_response(self, res: HttpResponse) -> ServiceResponse { self.to_srv_request().into_response(res) } - /// Complete request creation and generate `HttpRequest` instance + /// Finalizes request creation and returns `HttpRequest` instance. pub fn to_http_request(mut self) -> HttpRequest { let (mut head, _) = self.finish().into_parts(); head.peer_addr = self.peer_addr; @@ -302,7 +309,7 @@ impl TestRequest { ) } - /// Complete request creation and generate `HttpRequest` and `Payload` instances + /// Finalizes request creation and returns `HttpRequest` and `Payload` pair. pub fn to_http_parts(mut self) -> (HttpRequest, Payload) { let (mut head, payload) = self.finish().into_parts(); head.peer_addr = self.peer_addr; @@ -322,7 +329,7 @@ impl TestRequest { (req, payload) } - /// Complete request creation, calls service and waits for response future completion. + /// Finalizes request creation, calls service, and waits for response future completion. pub async fn send_request(self, app: &S) -> S::Response where S: Service, Error = E>, diff --git a/scripts/bump b/scripts/bump index 68f923e7..22aa2af9 100755 --- a/scripts/bump +++ b/scripts/bump @@ -112,17 +112,25 @@ echo read -p "Update all references: (y/N) " UPDATE_REFERENCES UPDATE_REFERENCES="${UPDATE_REFERENCES:-n}" + if [ "$UPDATE_REFERENCES" = 'y' ] || [ "$UPDATE_REFERENCES" = 'Y' ]; then + if [[ $NEW_VERSION == *".0.0" ]]; then + NEW_VERSION_SPEC="${NEW_VERSION%.0.0}" + elif [[ $NEW_VERSION == *".0" ]]; then + NEW_VERSION_SPEC="${NEW_VERSION%.0}" + else + NEW_VERSION_SPEC="$NEW_VERSION" + fi for f in $(fd Cargo.toml); do sed -i.bak -E \ - "s/^(${PACKAGE_NAME} ?= ?\")[^\"]+(\")$/\1${NEW_VERSION}\2/g" $f + "s/^(${PACKAGE_NAME} ?= ?\")[^\"]+(\")$/\1${NEW_VERSION_SPEC}\2/g" $f sed -i.bak -E \ - "s/^(${PACKAGE_NAME} ?=.*version ?= ?\")[^\"]+(\".*)$/\1${NEW_VERSION}\2/g" $f + "s/^(${PACKAGE_NAME} ?=.*version ?= ?\")[^\"]+(\".*)$/\1${NEW_VERSION_SPEC}\2/g" $f sed -i.bak -E \ - "s/^(.*package ?= ?\"${PACKAGE_NAME}\".*version ?= ?\")[^\"]+(\".*)$/\1${NEW_VERSION}\2/g" $f + "s/^(.*package ?= ?\"${PACKAGE_NAME}\".*version ?= ?\")[^\"]+(\".*)$/\1${NEW_VERSION_SPEC}\2/g" $f sed -i.bak -E \ - "s/^(.*version ?= ?\")[^\"]+(\".*package ?= ?\"${PACKAGE_NAME}\".*)$/\1${NEW_VERSION}\2/g" $f + "s/^(.*version ?= ?\")[^\"]+(\".*package ?= ?\"${PACKAGE_NAME}\".*)$/\1${NEW_VERSION_SPEC}\2/g" $f # remove backup file rm -f $f.bak From fcfc727295b67abe4568ab580316a62fa302a827 Mon Sep 17 00:00:00 2001 From: Dialga Date: Wed, 10 Jan 2024 16:56:15 +1300 Subject: [PATCH 017/151] actix-files: fix handling linebreaks in filenames (#3237) Co-authored-by: Rob Ede --- actix-files/CHANGES.md | 2 ++ actix-files/src/lib.rs | 8 +++++--- actix-files/src/named.rs | 8 ++++++-- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/actix-files/CHANGES.md b/actix-files/CHANGES.md index ac0fbfed..2958eae6 100644 --- a/actix-files/CHANGES.md +++ b/actix-files/CHANGES.md @@ -2,6 +2,8 @@ ## Unreleased +- Fix handling of special characters in filenames. + ## 0.6.4 - Fix handling of newlines in filenames. diff --git a/actix-files/src/lib.rs b/actix-files/src/lib.rs index 8ceb59be..5b1f14ee 100644 --- a/actix-files/src/lib.rs +++ b/actix-files/src/lib.rs @@ -569,18 +569,20 @@ mod tests { } #[actix_rt::test] - async fn test_static_files_with_newlines() { + async fn test_static_files_with_special_characters() { // Create the file we want to test against ad-hoc. We can't check it in as otherwise // Windows can't even checkout this repository. let temp_dir = tempfile::tempdir().unwrap(); - let file_with_newlines = temp_dir.path().join("test\nnewline.text"); + let file_with_newlines = temp_dir.path().join("test\n\x0B\x0C\rnewline.text"); fs::write(&file_with_newlines, "Look at my newlines").unwrap(); let srv = test::init_service( App::new().service(Files::new("/", temp_dir.path()).index_file("Cargo.toml")), ) .await; - let request = TestRequest::get().uri("/test%0Anewline.text").to_request(); + let request = TestRequest::get() + .uri("/test%0A%0B%0C%0Dnewline.text") + .to_request(); let response = test::call_service(&srv, request).await; assert_eq!(response.status(), StatusCode::OK); diff --git a/actix-files/src/named.rs b/actix-files/src/named.rs index 02dc701e..9e4a3773 100644 --- a/actix-files/src/named.rs +++ b/actix-files/src/named.rs @@ -139,8 +139,12 @@ impl NamedFile { _ => DispositionType::Attachment, }; - // Replace newlines in filenames which could occur on some filesystems. - let filename_s = filename.replace('\n', "%0A"); + // replace special characters in filenames which could occur on some filesystems + let filename_s = filename + .replace('\n', "%0A") // \n line break + .replace('\x0B', "%0B") // \v vertical tab + .replace('\x0C', "%0C") // \f form feed + .replace('\r', "%0D"); // \r carriage return let mut parameters = vec![DispositionParam::Filename(filename_s)]; if !filename.is_ascii() { From 33da4807092e39f11ac164d937a8e48b91c85862 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Wed, 10 Jan 2024 04:00:20 +0000 Subject: [PATCH 018/151] format project --- .prettierrc.yml | 2 +- actix-files/README.md | 6 +++++- actix-http-test/README.md | 6 +++++- actix-multipart-derive/README.md | 6 +++++- actix-multipart/README.md | 6 +++++- actix-router/README.md | 4 ++++ actix-web-actors/README.md | 6 +++++- actix-web-codegen/README.md | 6 +++++- awc/README.md | 6 +++++- justfile | 5 +++++ 10 files changed, 45 insertions(+), 8 deletions(-) diff --git a/.prettierrc.yml b/.prettierrc.yml index b61fd897..d7030347 100644 --- a/.prettierrc.yml +++ b/.prettierrc.yml @@ -1,5 +1,5 @@ overrides: - - files: '*.md' + - files: "*.md" options: printWidth: 9999 proseWrap: never diff --git a/actix-files/README.md b/actix-files/README.md index d8d9e4f1..c2dbc87f 100644 --- a/actix-files/README.md +++ b/actix-files/README.md @@ -1,7 +1,9 @@ -# actix-files +# `actix-files` > Static file serving for Actix Web + + [![crates.io](https://img.shields.io/crates/v/actix-files?label=latest)](https://crates.io/crates/actix-files) [![Documentation](https://docs.rs/actix-files/badge.svg?version=0.6.4)](https://docs.rs/actix-files/0.6.4) ![Version](https://img.shields.io/badge/rustc-1.68+-ab6000.svg) @@ -11,6 +13,8 @@ [![Download](https://img.shields.io/crates/d/actix-files.svg)](https://crates.io/crates/actix-files) [![Chat on Discord](https://img.shields.io/discord/771444961383153695?label=chat&logo=discord)](https://discord.gg/NWpN5mmg3x) + + ## Documentation & Resources - [API Documentation](https://docs.rs/actix-files) diff --git a/actix-http-test/README.md b/actix-http-test/README.md index 4b286e60..e544c361 100644 --- a/actix-http-test/README.md +++ b/actix-http-test/README.md @@ -1,7 +1,9 @@ -# actix-http-test +# `actix-http-test` > Various helpers for Actix applications to use during testing. + + [![crates.io](https://img.shields.io/crates/v/actix-http-test?label=latest)](https://crates.io/crates/actix-http-test) [![Documentation](https://docs.rs/actix-http-test/badge.svg?version=3.1.0)](https://docs.rs/actix-http-test/3.1.0) ![Version](https://img.shields.io/badge/rustc-1.68+-ab6000.svg) @@ -11,6 +13,8 @@ [![Download](https://img.shields.io/crates/d/actix-http-test.svg)](https://crates.io/crates/actix-http-test) [![Chat on Discord](https://img.shields.io/discord/771444961383153695?label=chat&logo=discord)](https://discord.gg/NWpN5mmg3x) + + ## Documentation & Resources - [API Documentation](https://docs.rs/actix-http-test) diff --git a/actix-multipart-derive/README.md b/actix-multipart-derive/README.md index cd5780c5..2beadefe 100644 --- a/actix-multipart-derive/README.md +++ b/actix-multipart-derive/README.md @@ -1,7 +1,9 @@ -# actix-multipart-derive +# `actix-multipart-derive` > The derive macro implementation for actix-multipart-derive. + + [![crates.io](https://img.shields.io/crates/v/actix-multipart-derive?label=latest)](https://crates.io/crates/actix-multipart-derive) [![Documentation](https://docs.rs/actix-multipart-derive/badge.svg?version=0.6.1)](https://docs.rs/actix-multipart-derive/0.6.1) ![Version](https://img.shields.io/badge/rustc-1.68+-ab6000.svg) @@ -11,6 +13,8 @@ [![Download](https://img.shields.io/crates/d/actix-multipart-derive.svg)](https://crates.io/crates/actix-multipart-derive) [![Chat on Discord](https://img.shields.io/discord/771444961383153695?label=chat&logo=discord)](https://discord.gg/NWpN5mmg3x) + + ## Documentation & Resources - [API Documentation](https://docs.rs/actix-multipart-derive) diff --git a/actix-multipart/README.md b/actix-multipart/README.md index 8fe0328a..16068510 100644 --- a/actix-multipart/README.md +++ b/actix-multipart/README.md @@ -1,7 +1,9 @@ -# actix-multipart +# `actix-multipart` > Multipart form support for Actix Web. + + [![crates.io](https://img.shields.io/crates/v/actix-multipart?label=latest)](https://crates.io/crates/actix-multipart) [![Documentation](https://docs.rs/actix-multipart/badge.svg?version=0.6.1)](https://docs.rs/actix-multipart/0.6.1) ![Version](https://img.shields.io/badge/rustc-1.68+-ab6000.svg) @@ -11,6 +13,8 @@ [![Download](https://img.shields.io/crates/d/actix-multipart.svg)](https://crates.io/crates/actix-multipart) [![Chat on Discord](https://img.shields.io/discord/771444961383153695?label=chat&logo=discord)](https://discord.gg/NWpN5mmg3x) + + ## Documentation & Resources - [API Documentation](https://docs.rs/actix-multipart) diff --git a/actix-router/README.md b/actix-router/README.md index 7dc0c901..7760b033 100644 --- a/actix-router/README.md +++ b/actix-router/README.md @@ -1,5 +1,7 @@ # `actix-router` + + [![crates.io](https://img.shields.io/crates/v/actix-router?label=latest)](https://crates.io/crates/actix-router) [![Documentation](https://docs.rs/actix-router/badge.svg?version=0.5.2)](https://docs.rs/actix-router/0.5.2) ![Version](https://img.shields.io/badge/rustc-1.68+-ab6000.svg) @@ -9,6 +11,8 @@ [![Download](https://img.shields.io/crates/d/actix-router.svg)](https://crates.io/crates/actix-router) [![Chat on Discord](https://img.shields.io/discord/771444961383153695?label=chat&logo=discord)](https://discord.gg/NWpN5mmg3x) + + Resource path matching and router. diff --git a/actix-web-actors/README.md b/actix-web-actors/README.md index b2c30b95..c81fe64c 100644 --- a/actix-web-actors/README.md +++ b/actix-web-actors/README.md @@ -1,7 +1,9 @@ -# actix-web-actors +# `actix-web-actors` > Actix actors support for Actix Web. + + [![crates.io](https://img.shields.io/crates/v/actix-web-actors?label=latest)](https://crates.io/crates/actix-web-actors) [![Documentation](https://docs.rs/actix-web-actors/badge.svg?version=4.2.0)](https://docs.rs/actix-web-actors/4.2.0) ![Version](https://img.shields.io/badge/rustc-1.68+-ab6000.svg) @@ -11,6 +13,8 @@ [![Download](https://img.shields.io/crates/d/actix-web-actors.svg)](https://crates.io/crates/actix-web-actors) [![Chat on Discord](https://img.shields.io/discord/771444961383153695?label=chat&logo=discord)](https://discord.gg/NWpN5mmg3x) + + ## Documentation & Resources - [API Documentation](https://docs.rs/actix-web-actors) diff --git a/actix-web-codegen/README.md b/actix-web-codegen/README.md index e9a1f9c7..088f3575 100644 --- a/actix-web-codegen/README.md +++ b/actix-web-codegen/README.md @@ -1,7 +1,9 @@ -# actix-web-codegen +# `actix-web-codegen` > Routing and runtime macros for Actix Web. + + [![crates.io](https://img.shields.io/crates/v/actix-web-codegen?label=latest)](https://crates.io/crates/actix-web-codegen) [![Documentation](https://docs.rs/actix-web-codegen/badge.svg?version=4.2.2)](https://docs.rs/actix-web-codegen/4.2.2) ![Version](https://img.shields.io/badge/rustc-1.68+-ab6000.svg) @@ -11,6 +13,8 @@ [![Download](https://img.shields.io/crates/d/actix-web-codegen.svg)](https://crates.io/crates/actix-web-codegen) [![Chat on Discord](https://img.shields.io/discord/771444961383153695?label=chat&logo=discord)](https://discord.gg/NWpN5mmg3x) + + ## Documentation & Resources - [API Documentation](https://docs.rs/actix-web-codegen) diff --git a/awc/README.md b/awc/README.md index 035348fb..424c86bb 100644 --- a/awc/README.md +++ b/awc/README.md @@ -1,13 +1,17 @@ -# awc (Actix Web Client) +# `awc` (Actix Web Client) > Async HTTP and WebSocket client library. + + [![crates.io](https://img.shields.io/crates/v/awc?label=latest)](https://crates.io/crates/awc) [![Documentation](https://docs.rs/awc/badge.svg?version=3.3.0)](https://docs.rs/awc/3.3.0) ![MIT or Apache 2.0 licensed](https://img.shields.io/crates/l/awc) [![Dependency Status](https://deps.rs/crate/awc/3.3.0/status.svg)](https://deps.rs/crate/awc/3.3.0) [![Chat on Discord](https://img.shields.io/discord/771444961383153695?label=chat&logo=discord)](https://discord.gg/NWpN5mmg3x) + + ## Documentation & Resources - [API Documentation](https://docs.rs/awc) diff --git a/justfile b/justfile index f2e449d8..2142e9bc 100644 --- a/justfile +++ b/justfile @@ -1,6 +1,11 @@ _list: @just --list +# Format workspace. +fmt: + cargo +nightly fmt + npx -y prettier --write $(fd --type=file --hidden --extension=md --extension=yml) + # Document crates in workspace. doc: RUSTDOCFLAGS="--cfg=docsrs" cargo +nightly doc --no-deps --workspace --features=rustls,openssl From 83be07d77de4d463558769cc571bb16fd082c8af Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Wed, 10 Jan 2024 04:01:14 +0000 Subject: [PATCH 019/151] chore(actix-files): prepare release 0.6.5 --- actix-files/CHANGES.md | 2 ++ actix-files/Cargo.toml | 2 +- actix-files/README.md | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/actix-files/CHANGES.md b/actix-files/CHANGES.md index 2958eae6..9aa62ff7 100644 --- a/actix-files/CHANGES.md +++ b/actix-files/CHANGES.md @@ -2,6 +2,8 @@ ## Unreleased +## 0.6.5 + - Fix handling of special characters in filenames. ## 0.6.4 diff --git a/actix-files/Cargo.toml b/actix-files/Cargo.toml index b7a27251..098d71bd 100644 --- a/actix-files/Cargo.toml +++ b/actix-files/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "actix-files" -version = "0.6.4" +version = "0.6.5" authors = [ "Nikolay Kim ", "Rob Ede ", diff --git a/actix-files/README.md b/actix-files/README.md index c2dbc87f..e805d041 100644 --- a/actix-files/README.md +++ b/actix-files/README.md @@ -5,11 +5,11 @@ [![crates.io](https://img.shields.io/crates/v/actix-files?label=latest)](https://crates.io/crates/actix-files) -[![Documentation](https://docs.rs/actix-files/badge.svg?version=0.6.4)](https://docs.rs/actix-files/0.6.4) +[![Documentation](https://docs.rs/actix-files/badge.svg?version=0.6.5)](https://docs.rs/actix-files/0.6.5) ![Version](https://img.shields.io/badge/rustc-1.68+-ab6000.svg) ![License](https://img.shields.io/crates/l/actix-files.svg)
-[![dependency status](https://deps.rs/crate/actix-files/0.6.4/status.svg)](https://deps.rs/crate/actix-files/0.6.4) +[![dependency status](https://deps.rs/crate/actix-files/0.6.5/status.svg)](https://deps.rs/crate/actix-files/0.6.5) [![Download](https://img.shields.io/crates/d/actix-files.svg)](https://crates.io/crates/actix-files) [![Chat on Discord](https://img.shields.io/discord/771444961383153695?label=chat&logo=discord)](https://discord.gg/NWpN5mmg3x) From 08a9c665680807d9129c4a6fc54fadd498c24e43 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Wed, 10 Jan 2024 04:03:29 +0000 Subject: [PATCH 020/151] docs(files: update readme from crate docs --- actix-files/README.md | 22 ++++++++++++++++------ justfile | 5 +++++ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/actix-files/README.md b/actix-files/README.md index e805d041..df80e404 100644 --- a/actix-files/README.md +++ b/actix-files/README.md @@ -1,7 +1,5 @@ # `actix-files` -> Static file serving for Actix Web - [![crates.io](https://img.shields.io/crates/v/actix-files?label=latest)](https://crates.io/crates/actix-files) @@ -15,8 +13,20 @@ -## Documentation & Resources + -- [API Documentation](https://docs.rs/actix-files) -- [Example Project](https://github.com/actix/examples/tree/master/basics/static-files) -- Minimum Supported Rust Version (MSRV): 1.68 +Static file serving for Actix Web. + +Provides a non-blocking service for serving static files from disk. + +## Examples + +```rust +use actix_web::App; +use actix_files::Files; + +let app = App::new() + .service(Files::new("/static", ".").prefer_utf8(true)); +``` + + diff --git a/justfile b/justfile index 2142e9bc..42979f18 100644 --- a/justfile +++ b/justfile @@ -14,3 +14,8 @@ doc: doc-watch: RUSTDOCFLAGS="--cfg=docsrs" cargo +nightly doc --no-deps --workspace --features=rustls,openssl --open cargo watch -- RUSTDOCFLAGS="--cfg=docsrs" cargo +nightly doc --no-deps --workspace --features=rustls,openssl + +# Update READMEs from crate root documentation. +update-readmes: && fmt + cd ./actix-files && cargo rdme --force + cd ./actix-router && cargo rdme --force From ba53c4f87512524b5e66fb4bc18becee4313b32a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 15 Jan 2024 01:24:21 +0000 Subject: [PATCH 021/151] build(deps): bump actions-rust-lang/setup-rust-toolchain from 1.6.0 to 1.8.0 (#3247) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/ci-post-merge.yml | 6 +++--- .github/workflows/ci.yml | 6 +++--- .github/workflows/coverage.yml | 2 +- .github/workflows/lint.yml | 8 ++++---- .github/workflows/upload-doc.yml | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci-post-merge.yml b/.github/workflows/ci-post-merge.yml index 394d447a..904edcdb 100644 --- a/.github/workflows/ci-post-merge.yml +++ b/.github/workflows/ci-post-merge.yml @@ -40,7 +40,7 @@ jobs: echo 'OPENSSL_DIR=C:\Program Files\OpenSSL' | Out-File -FilePath $env:GITHUB_ENV -Append - name: Install Rust (${{ matrix.version.name }}) - uses: actions-rust-lang/setup-rust-toolchain@v1.6.0 + uses: actions-rust-lang/setup-rust-toolchain@v1.8.0 with: toolchain: ${{ matrix.version.version }} @@ -82,7 +82,7 @@ jobs: - uses: actions/checkout@v4 - name: Install Rust - uses: actions-rust-lang/setup-rust-toolchain@v1.6.0 + uses: actions-rust-lang/setup-rust-toolchain@v1.8.0 - name: Install cargo-hack uses: taiki-e/install-action@v2.24.1 @@ -103,7 +103,7 @@ jobs: - uses: actions/checkout@v4 - name: Install Rust - uses: actions-rust-lang/setup-rust-toolchain@v1.6.0 + uses: actions-rust-lang/setup-rust-toolchain@v1.8.0 - name: Install nextest uses: taiki-e/install-action@v2.24.1 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bcab6219..562e4d33 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -45,7 +45,7 @@ jobs: echo 'OPENSSL_DIR=C:\Program Files\OpenSSL' | Out-File -FilePath $env:GITHUB_ENV -Append - name: Install Rust (${{ matrix.version.name }}) - uses: actions-rust-lang/setup-rust-toolchain@v1.6.0 + uses: actions-rust-lang/setup-rust-toolchain@v1.8.0 with: toolchain: ${{ matrix.version.version }} @@ -93,7 +93,7 @@ jobs: - uses: actions/checkout@v4 - name: Install Rust - uses: actions-rust-lang/setup-rust-toolchain@v1.6.0 + uses: actions-rust-lang/setup-rust-toolchain@v1.8.0 with: toolchain: nightly @@ -109,7 +109,7 @@ jobs: - uses: actions/checkout@v4 - name: Install Rust (nightly) - uses: actions-rust-lang/setup-rust-toolchain@v1.6.0 + uses: actions-rust-lang/setup-rust-toolchain@v1.8.0 with: toolchain: nightly diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index bdd15198..038c0360 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -18,7 +18,7 @@ jobs: - uses: actions/checkout@v4 - name: Install Rust - uses: actions-rust-lang/setup-rust-toolchain@v1.6.0 + uses: actions-rust-lang/setup-rust-toolchain@v1.8.0 with: components: llvm-tools-preview diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 13362dbb..5d427aa9 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -17,7 +17,7 @@ jobs: steps: - uses: actions/checkout@v4 - - uses: actions-rust-lang/setup-rust-toolchain@v1.6.0 + - uses: actions-rust-lang/setup-rust-toolchain@v1.8.0 with: toolchain: nightly components: rustfmt @@ -35,7 +35,7 @@ jobs: - uses: actions/checkout@v4 - name: Install Rust - uses: actions-rust-lang/setup-rust-toolchain@v1.6.0 + uses: actions-rust-lang/setup-rust-toolchain@v1.8.0 with: components: clippy @@ -53,7 +53,7 @@ jobs: steps: - uses: actions/checkout@v4 - - uses: actions-rust-lang/setup-rust-toolchain@v1.6.0 + - uses: actions-rust-lang/setup-rust-toolchain@v1.8.0 with: toolchain: nightly components: rust-docs @@ -72,7 +72,7 @@ jobs: - uses: actions/checkout@v4 - - uses: actions-rust-lang/setup-rust-toolchain@v1.6.0 + - uses: actions-rust-lang/setup-rust-toolchain@v1.8.0 with: toolchain: nightly-2023-08-25 diff --git a/.github/workflows/upload-doc.yml b/.github/workflows/upload-doc.yml index f4bd0cee..963b7f6b 100644 --- a/.github/workflows/upload-doc.yml +++ b/.github/workflows/upload-doc.yml @@ -22,7 +22,7 @@ jobs: - uses: actions/checkout@v4 - name: Install Rust - uses: actions-rust-lang/setup-rust-toolchain@v1.6.0 + uses: actions-rust-lang/setup-rust-toolchain@v1.8.0 with: toolchain: nightly From e442b00c8ce1c76ca70131c585d9578785381a03 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 15 Jan 2024 01:24:48 +0000 Subject: [PATCH 022/151] build(deps): bump taiki-e/install-action from 2.24.1 to 2.25.1 (#3246) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/ci-post-merge.yml | 6 +++--- .github/workflows/ci.yml | 2 +- .github/workflows/coverage.yml | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci-post-merge.yml b/.github/workflows/ci-post-merge.yml index 904edcdb..0385f46f 100644 --- a/.github/workflows/ci-post-merge.yml +++ b/.github/workflows/ci-post-merge.yml @@ -45,7 +45,7 @@ jobs: toolchain: ${{ matrix.version.version }} - name: Install cargo-hack - uses: taiki-e/install-action@v2.24.1 + uses: taiki-e/install-action@v2.25.1 with: tool: cargo-hack @@ -85,7 +85,7 @@ jobs: uses: actions-rust-lang/setup-rust-toolchain@v1.8.0 - name: Install cargo-hack - uses: taiki-e/install-action@v2.24.1 + uses: taiki-e/install-action@v2.25.1 with: tool: cargo-hack @@ -106,7 +106,7 @@ jobs: uses: actions-rust-lang/setup-rust-toolchain@v1.8.0 - name: Install nextest - uses: taiki-e/install-action@v2.24.1 + uses: taiki-e/install-action@v2.25.1 with: tool: nextest diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 562e4d33..687fc45b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -50,7 +50,7 @@ jobs: toolchain: ${{ matrix.version.version }} - name: Install cargo-hack - uses: taiki-e/install-action@v2.24.1 + uses: taiki-e/install-action@v2.25.1 with: tool: cargo-hack diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 038c0360..80d46161 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -23,7 +23,7 @@ jobs: components: llvm-tools-preview - name: Install cargo-llvm-cov - uses: taiki-e/install-action@v2.24.1 + uses: taiki-e/install-action@v2.25.1 with: tool: cargo-llvm-cov From 2915bb7d90e7c3dc2f511b9608e1330d250a4ea2 Mon Sep 17 00:00:00 2001 From: John Vandenberg Date: Tue, 16 Jan 2024 19:29:06 +0800 Subject: [PATCH 023/151] chore: fix typos (#3248) --- actix-web/MIGRATION-4.0.md | 4 ++-- actix-web/src/data.rs | 2 +- actix-web/src/guard/acceptable.rs | 2 +- actix-web/src/guard/host.rs | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/actix-web/MIGRATION-4.0.md b/actix-web/MIGRATION-4.0.md index 0f0bd3a5..08c89635 100644 --- a/actix-web/MIGRATION-4.0.md +++ b/actix-web/MIGRATION-4.0.md @@ -372,13 +372,13 @@ You may need to review the [guidance on shared mutable state](https://docs.rs/ac HttpServer::new(|| { - App::new() - .data(MyState::default()) -- .service(hander) +- .service(handler) + let my_state: Data = Data::new(MyState::default()); + + App::new() + .app_data(my_state) -+ .service(hander) ++ .service(handler) }) ``` diff --git a/actix-web/src/data.rs b/actix-web/src/data.rs index ebb98af3..acbb8e23 100644 --- a/actix-web/src/data.rs +++ b/actix-web/src/data.rs @@ -69,7 +69,7 @@ pub(crate) type FnDataFactory = /// HttpResponse::Ok() /// } /// -/// /// Alteratively, use the `HttpRequest::app_data` method to access data in a handler. +/// /// Alternatively, use the `HttpRequest::app_data` method to access data in a handler. /// async fn index_alt(req: HttpRequest) -> impl Responder { /// let data = req.app_data::>>().unwrap(); /// let mut my_data = data.lock().unwrap(); diff --git a/actix-web/src/guard/acceptable.rs b/actix-web/src/guard/acceptable.rs index a31494a1..8fa7165c 100644 --- a/actix-web/src/guard/acceptable.rs +++ b/actix-web/src/guard/acceptable.rs @@ -20,7 +20,7 @@ use crate::http::header::Accept; pub struct Acceptable { mime: mime::Mime, - /// Wether to match `*/*` mime type. + /// Whether to match `*/*` mime type. /// /// Defaults to false because it's not very useful otherwise. match_star_star: bool, diff --git a/actix-web/src/guard/host.rs b/actix-web/src/guard/host.rs index f05c8118..a971a3e3 100644 --- a/actix-web/src/guard/host.rs +++ b/actix-web/src/guard/host.rs @@ -2,7 +2,7 @@ use actix_http::{header, uri::Uri, RequestHead}; use super::{Guard, GuardContext}; -/// Creates a guard that matches requests targetting a specific host. +/// Creates a guard that matches requests targeting a specific host. /// /// # Matching Host /// This guard will: From d453b15dddfbb81ed67237e7e940413328ab7a88 Mon Sep 17 00:00:00 2001 From: Vojtech Kral Date: Thu, 18 Jan 2024 13:32:27 +0100 Subject: [PATCH 024/151] docs: mention result is wrapped in Data in data_factory() docs (#3251) --- actix-web/src/app.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/actix-web/src/app.rs b/actix-web/src/app.rs index 06b66f62..26b278bc 100644 --- a/actix-web/src/app.rs +++ b/actix-web/src/app.rs @@ -129,6 +129,8 @@ where /// /// Data items are constructed during application initialization, before the server starts /// accepting requests. + /// + /// The returned data value `D` is wrapped as [`Data`]. pub fn data_factory(mut self, data: F) -> Self where F: Fn() -> Out + 'static, From ea8cd6e9763436677bf5efaebdf0b51e864134bb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 22 Jan 2024 01:06:55 +0000 Subject: [PATCH 025/151] build(deps): bump taiki-e/install-action from 2.25.1 to 2.25.9 (#3252) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/ci-post-merge.yml | 6 +++--- .github/workflows/ci.yml | 2 +- .github/workflows/coverage.yml | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci-post-merge.yml b/.github/workflows/ci-post-merge.yml index 0385f46f..e6382189 100644 --- a/.github/workflows/ci-post-merge.yml +++ b/.github/workflows/ci-post-merge.yml @@ -45,7 +45,7 @@ jobs: toolchain: ${{ matrix.version.version }} - name: Install cargo-hack - uses: taiki-e/install-action@v2.25.1 + uses: taiki-e/install-action@v2.25.9 with: tool: cargo-hack @@ -85,7 +85,7 @@ jobs: uses: actions-rust-lang/setup-rust-toolchain@v1.8.0 - name: Install cargo-hack - uses: taiki-e/install-action@v2.25.1 + uses: taiki-e/install-action@v2.25.9 with: tool: cargo-hack @@ -106,7 +106,7 @@ jobs: uses: actions-rust-lang/setup-rust-toolchain@v1.8.0 - name: Install nextest - uses: taiki-e/install-action@v2.25.1 + uses: taiki-e/install-action@v2.25.9 with: tool: nextest diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 687fc45b..9dcd8fab 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -50,7 +50,7 @@ jobs: toolchain: ${{ matrix.version.version }} - name: Install cargo-hack - uses: taiki-e/install-action@v2.25.1 + uses: taiki-e/install-action@v2.25.9 with: tool: cargo-hack diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 80d46161..2722da08 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -23,7 +23,7 @@ jobs: components: llvm-tools-preview - name: Install cargo-llvm-cov - uses: taiki-e/install-action@v2.25.1 + uses: taiki-e/install-action@v2.25.9 with: tool: cargo-llvm-cov From a7375b687658790122c72e27e476affdd7bc1cb6 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Mon, 22 Jan 2024 02:19:19 +0000 Subject: [PATCH 026/151] ci: faster cargo-public-api install (#3255) --- .github/workflows/lint.yml | 22 ++++++++++++++-------- actix-http/src/requests/head.rs | 2 +- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 5d427aa9..adcb257b 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -17,12 +17,13 @@ jobs: steps: - uses: actions/checkout@v4 - - uses: actions-rust-lang/setup-rust-toolchain@v1.8.0 + - name: Install Rust (nightly) + uses: actions-rust-lang/setup-rust-toolchain@v1.8.0 with: toolchain: nightly components: rustfmt - - name: Check with rustfmt + - name: Check with Rustfmt run: cargo fmt --all -- --check clippy: @@ -53,7 +54,8 @@ jobs: steps: - uses: actions/checkout@v4 - - uses: actions-rust-lang/setup-rust-toolchain@v1.8.0 + - name: Install Rust (nightly) + uses: actions-rust-lang/setup-rust-toolchain@v1.8.0 with: toolchain: nightly components: rust-docs @@ -66,21 +68,25 @@ jobs: public-api-diff: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - name: Checkout main branch + uses: actions/checkout@v4 with: ref: ${{ github.base_ref }} - - uses: actions/checkout@v4 + - name: Checkout PR branch + uses: actions/checkout@v4 - - uses: actions-rust-lang/setup-rust-toolchain@v1.8.0 + - name: Install Rust + uses: actions-rust-lang/setup-rust-toolchain@v1.8.0 with: toolchain: nightly-2023-08-25 - - uses: taiki-e/cache-cargo-install-action@v1.3.0 + - name: Install cargo-public-api + uses: taiki-e/install-action@v2.24.1 with: tool: cargo-public-api - - name: generate API diff + - name: Generate API diff run: | for f in $(find -mindepth 2 -maxdepth 2 -name Cargo.toml); do cargo public-api --manifest-path "$f" diff ${{ github.event.pull_request.base.sha }}..${{ github.sha }} diff --git a/actix-http/src/requests/head.rs b/actix-http/src/requests/head.rs index 2e0c2dbd..9ceb2a20 100644 --- a/actix-http/src/requests/head.rs +++ b/actix-http/src/requests/head.rs @@ -17,7 +17,7 @@ pub struct RequestHead { pub version: Version, pub headers: HeaderMap, - /// Will only be None when called in unit tests unless [`TestRequest::peer_addr`] is used. + /// Will only be None when called in unit tests unless set manually. pub peer_addr: Option, flags: Flags, From 891ab083c6d497db2f6adde7767b41e367ca8907 Mon Sep 17 00:00:00 2001 From: Bruno Paulino Date: Wed, 24 Jan 2024 15:17:42 +0100 Subject: [PATCH 027/151] actix-http: Bump h2 to fix a resource exhaustion vulnerability (#3262) Co-authored-by: Rob Ede --- actix-http/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/actix-http/Cargo.toml b/actix-http/Cargo.toml index 6c53f35c..e7d50c31 100644 --- a/actix-http/Cargo.toml +++ b/actix-http/Cargo.toml @@ -89,7 +89,7 @@ tokio-util = { version = "0.7", features = ["io", "codec"] } tracing = { version = "0.1.30", default-features = false, features = ["log"] } # http2 -h2 = { version = "0.3.17", optional = true } +h2 = { version = "0.3.24", optional = true } # websockets local-channel = { version = "0.1", optional = true } From 643a80bff2dec42f3c9aa287de67c88a505d4638 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Thu, 1 Feb 2024 05:41:28 +0000 Subject: [PATCH 028/151] ci: workaround half crate msrv --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9dcd8fab..7d4d1a4b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -57,6 +57,8 @@ jobs: - name: workaround MSRV issues if: matrix.version.name == 'msrv' run: | + cargo update -p=ciborium --precise=0.2.1 + cargo update -p=ciborium-ll --precise=0.2.1 cargo update -p=clap --precise=4.3.24 cargo update -p=clap_lex --precise=0.5.0 cargo update -p=anstyle --precise=1.0.2 From 5246d24aba3db150ff9a6c75bb367abb70c9e3e6 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Thu, 1 Feb 2024 06:01:28 +0000 Subject: [PATCH 029/151] ci: force openssl version 3.2.1 --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7d4d1a4b..4caa9b1a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -37,7 +37,7 @@ jobs: - name: Install OpenSSL if: matrix.target.os == 'windows-latest' - run: choco install openssl -y --forcex64 --no-progress + run: choco install openssl -y --forcex64 --no-progress --version=3.2.1 - name: Set OpenSSL dir in env if: matrix.target.os == 'windows-latest' run: | From e89c881624b290c3c0802d02cc33360cb4c994da Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Thu, 1 Feb 2024 06:27:22 +0000 Subject: [PATCH 030/151] ci: use cargo-ci-cache-clean --- .github/workflows/ci-post-merge.yml | 12 ++++++++---- .github/workflows/ci.yml | 12 ++++++++---- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci-post-merge.yml b/.github/workflows/ci-post-merge.yml index e6382189..a08bc2ed 100644 --- a/.github/workflows/ci-post-merge.yml +++ b/.github/workflows/ci-post-merge.yml @@ -58,6 +58,7 @@ jobs: - name: tests timeout-minutes: 60 run: | + set -e cargo test --lib --tests -p=actix-router --all-features cargo test --lib --tests -p=actix-http --all-features cargo test --lib --tests -p=actix-web --features=rustls-0_20,rustls-0_21,openssl -- --skip=test_reading_deflate_encoding_large_random_rustls @@ -69,10 +70,13 @@ jobs: cargo test --lib --tests -p=actix-multipart --all-features cargo test --lib --tests -p=actix-web-actors --all-features - - name: Clear the cargo caches - run: | - cargo --locked install cargo-cache --version 0.8.3 --no-default-features --features ci-autoclean - cargo-cache + - name: Install cargo-ci-cache-clean + uses: taiki-e/install-action@v2.25.9 + with: + tool: cargo-ci-cache-clean + + - name: CI cache clean + run: cargo-ci-cache-clean ci_feature_powerset_check: name: Verify Feature Combinations diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4caa9b1a..90392892 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -72,6 +72,7 @@ jobs: - name: tests timeout-minutes: 60 run: | + set -e cargo test --lib --tests -p=actix-router --all-features cargo test --lib --tests -p=actix-http --all-features cargo test --lib --tests -p=actix-web --features=rustls-0_20,rustls-0_21,openssl -- --skip=test_reading_deflate_encoding_large_random_rustls @@ -83,10 +84,13 @@ jobs: cargo test --lib --tests -p=actix-multipart --all-features cargo test --lib --tests -p=actix-web-actors --all-features - - name: Clear the cargo caches - run: | - cargo --locked install cargo-cache --version 0.8.3 --no-default-features --features ci-autoclean - cargo-cache + - name: Install cargo-ci-cache-clean + uses: taiki-e/install-action@v2.25.9 + with: + tool: cargo-ci-cache-clean + + - name: CI cache clean + run: cargo-ci-cache-clean io-uring: name: io-uring tests From 8e458b34b7b5f63adddf39483755c1a358440040 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Thu, 1 Feb 2024 06:33:58 +0000 Subject: [PATCH 031/151] chore: remove set -e --- .github/workflows/ci-post-merge.yml | 1 - .github/workflows/ci.yml | 1 - 2 files changed, 2 deletions(-) diff --git a/.github/workflows/ci-post-merge.yml b/.github/workflows/ci-post-merge.yml index a08bc2ed..fd41819a 100644 --- a/.github/workflows/ci-post-merge.yml +++ b/.github/workflows/ci-post-merge.yml @@ -58,7 +58,6 @@ jobs: - name: tests timeout-minutes: 60 run: | - set -e cargo test --lib --tests -p=actix-router --all-features cargo test --lib --tests -p=actix-http --all-features cargo test --lib --tests -p=actix-web --features=rustls-0_20,rustls-0_21,openssl -- --skip=test_reading_deflate_encoding_large_random_rustls diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 90392892..b2128f3e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -72,7 +72,6 @@ jobs: - name: tests timeout-minutes: 60 run: | - set -e cargo test --lib --tests -p=actix-router --all-features cargo test --lib --tests -p=actix-http --all-features cargo test --lib --tests -p=actix-web --features=rustls-0_20,rustls-0_21,openssl -- --skip=test_reading_deflate_encoding_large_random_rustls From 7a76ba73406f9a72c3c76f7e9ccd01ae1640dd33 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 1 Feb 2024 07:34:11 +0000 Subject: [PATCH 032/151] build(deps): bump taiki-e/install-action from 2.24.1 to 2.26.8 (#3271) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/ci-post-merge.yml | 8 ++++---- .github/workflows/ci.yml | 4 ++-- .github/workflows/coverage.yml | 2 +- .github/workflows/lint.yml | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci-post-merge.yml b/.github/workflows/ci-post-merge.yml index fd41819a..d2f952ec 100644 --- a/.github/workflows/ci-post-merge.yml +++ b/.github/workflows/ci-post-merge.yml @@ -45,7 +45,7 @@ jobs: toolchain: ${{ matrix.version.version }} - name: Install cargo-hack - uses: taiki-e/install-action@v2.25.9 + uses: taiki-e/install-action@v2.26.8 with: tool: cargo-hack @@ -70,7 +70,7 @@ jobs: cargo test --lib --tests -p=actix-web-actors --all-features - name: Install cargo-ci-cache-clean - uses: taiki-e/install-action@v2.25.9 + uses: taiki-e/install-action@v2.26.8 with: tool: cargo-ci-cache-clean @@ -88,7 +88,7 @@ jobs: uses: actions-rust-lang/setup-rust-toolchain@v1.8.0 - name: Install cargo-hack - uses: taiki-e/install-action@v2.25.9 + uses: taiki-e/install-action@v2.26.8 with: tool: cargo-hack @@ -109,7 +109,7 @@ jobs: uses: actions-rust-lang/setup-rust-toolchain@v1.8.0 - name: Install nextest - uses: taiki-e/install-action@v2.25.9 + uses: taiki-e/install-action@v2.26.8 with: tool: nextest diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b2128f3e..5d2f5bb1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -50,7 +50,7 @@ jobs: toolchain: ${{ matrix.version.version }} - name: Install cargo-hack - uses: taiki-e/install-action@v2.25.9 + uses: taiki-e/install-action@v2.26.8 with: tool: cargo-hack @@ -84,7 +84,7 @@ jobs: cargo test --lib --tests -p=actix-web-actors --all-features - name: Install cargo-ci-cache-clean - uses: taiki-e/install-action@v2.25.9 + uses: taiki-e/install-action@v2.26.8 with: tool: cargo-ci-cache-clean diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 2722da08..2ad7bf8e 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -23,7 +23,7 @@ jobs: components: llvm-tools-preview - name: Install cargo-llvm-cov - uses: taiki-e/install-action@v2.25.9 + uses: taiki-e/install-action@v2.26.8 with: tool: cargo-llvm-cov diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index adcb257b..502bfeb6 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -82,7 +82,7 @@ jobs: toolchain: nightly-2023-08-25 - name: Install cargo-public-api - uses: taiki-e/install-action@v2.24.1 + uses: taiki-e/install-action@v2.26.8 with: tool: cargo-public-api From c1f88f718b866d6712d5b98e7dc6be4344944c77 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 1 Feb 2024 07:34:23 +0000 Subject: [PATCH 033/151] build(deps): bump codecov/codecov-action from 3.1.4 to 4.0.0 (#3272) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Rob Ede --- .github/workflows/coverage.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 2ad7bf8e..d871898f 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -31,7 +31,9 @@ jobs: run: cargo llvm-cov --workspace --all-features --codecov --output-path codecov.json - name: Upload coverage to Codecov - uses: codecov/codecov-action@v3.1.4 + uses: codecov/codecov-action@v4.0.0 with: files: codecov.json fail_ci_if_error: true + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} From ae7736f1341aef94d2ed7f52315c3bdea1d2ab3b Mon Sep 17 00:00:00 2001 From: SleeplessOne1917 <28871516+SleeplessOne1917@users.noreply.github.com> Date: Thu, 1 Feb 2024 12:52:35 +0000 Subject: [PATCH 034/151] Implement `From<&HeaderMap>` for `http::HeaderMap` (#3230) * Add From impl for header map references * Add From impl for header map references * Remove Into via http::HeaderMap * fix changelog --------- Co-authored-by: SleeplessOne1917 Co-authored-by: Rob Ede --- actix-http/CHANGES.md | 4 ++++ actix-http/src/header/map.rs | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/actix-http/CHANGES.md b/actix-http/CHANGES.md index 994c91a8..3ce06442 100644 --- a/actix-http/CHANGES.md +++ b/actix-http/CHANGES.md @@ -2,6 +2,10 @@ ## Unreleased +### Added + +- Implement `From<&HeaderMap>` for `http::HeaderMap`. + ## 3.5.1 ### Fixed diff --git a/actix-http/src/header/map.rs b/actix-http/src/header/map.rs index d8a63b57..b86798a4 100644 --- a/actix-http/src/header/map.rs +++ b/actix-http/src/header/map.rs @@ -650,6 +650,13 @@ impl From for http::HeaderMap { } } +/// Convert our `&HeaderMap` to a `http::HeaderMap`. +impl From<&HeaderMap> for http::HeaderMap { + fn from(map: &HeaderMap) -> Self { + map.to_owned().into() + } +} + /// Iterator over removed, owned values with the same associated name. /// /// Returned from methods that remove or replace items. See [`HeaderMap::insert`] From b1eb57ac4f4dce05dd043ab9fca871af8f84f164 Mon Sep 17 00:00:00 2001 From: Dylan DPC <99973273+Dylan-DPC@users.noreply.github.com> Date: Sat, 3 Feb 2024 16:20:07 +0000 Subject: [PATCH 035/151] Update Cargo.toml (#3276) --- awc/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/awc/Cargo.toml b/awc/Cargo.toml index 14009fb4..5c09400a 100644 --- a/awc/Cargo.toml +++ b/awc/Cargo.toml @@ -72,7 +72,7 @@ cfg-if = "1" derive_more = "0.99.5" futures-core = { version = "0.3.17", default-features = false, features = ["alloc"] } futures-util = { version = "0.3.17", default-features = false, features = ["alloc", "sink"] } -h2 = "0.3.17" +h2 = "0.3.24" http = "0.2.7" itoa = "1" log =" 0.4" From 2125aca2c5e0bba99172ce1a00f72531a58cee2a Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Sat, 3 Feb 2024 23:55:01 +0000 Subject: [PATCH 036/151] Rustls v0.22 support (#3275) --- .cargo/config.toml | 4 +- .github/workflows/ci-post-merge.yml | 23 ++-- .github/workflows/ci.yml | 23 ++-- actix-files/src/lib.rs | 1 + actix-http/CHANGES.md | 2 + actix-http/Cargo.toml | 31 +++-- actix-http/examples/tls_rustls.rs | 20 ++-- actix-http/examples/ws.rs | 21 ++-- actix-http/src/h1/service.rs | 65 +++++++++- actix-http/src/h2/service.rs | 55 ++++++++- actix-http/src/lib.rs | 7 +- actix-http/src/service.rs | 124 ++++++++++++++++++-- actix-http/tests/test_rustls.rs | 63 +++++----- actix-test/CHANGES.md | 2 + actix-test/Cargo.toml | 3 + actix-test/src/lib.rs | 83 +++++++++++-- actix-web/CHANGES.md | 3 + actix-web/Cargo.toml | 19 ++- actix-web/src/server.rs | 85 ++++++++++++++ actix-web/tests/test_server.rs | 2 +- awc/CHANGES.md | 3 + awc/Cargo.toml | 30 +++-- awc/src/client/connector.rs | 176 ++++++++++++++++++++-------- awc/tests/test_rustls_client.rs | 70 +++++++---- 24 files changed, 719 insertions(+), 196 deletions(-) diff --git a/.cargo/config.toml b/.cargo/config.toml index 931b20b2..350a924d 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -1,6 +1,6 @@ [alias] -lint = "clippy --workspace --tests --examples --bins -- -Dclippy::todo" -lint-all = "clippy --workspace --all-features --tests --examples --bins -- -Dclippy::todo" +lint = "clippy --workspace --all-targets -- -Dclippy::todo" +lint-all = "clippy --workspace --all-features --all-targets -- -Dclippy::todo" # lib checking ci-check-min = "hack --workspace check --no-default-features" diff --git a/.github/workflows/ci-post-merge.yml b/.github/workflows/ci-post-merge.yml index d2f952ec..de9b30a5 100644 --- a/.github/workflows/ci-post-merge.yml +++ b/.github/workflows/ci-post-merge.yml @@ -32,22 +32,22 @@ jobs: - name: Install OpenSSL if: matrix.target.os == 'windows-latest' - run: choco install openssl -y --forcex64 --no-progress - - name: Set OpenSSL dir in env - if: matrix.target.os == 'windows-latest' + shell: bash run: | - echo 'OPENSSL_DIR=C:\Program Files\OpenSSL-Win64' | Out-File -FilePath $env:GITHUB_ENV -Append - echo 'OPENSSL_DIR=C:\Program Files\OpenSSL' | Out-File -FilePath $env:GITHUB_ENV -Append + set -e + choco install openssl --version=1.1.1.2100 -y --no-progress + echo 'OPENSSL_DIR=C:\Program Files\OpenSSL' >> $GITHUB_ENV + echo "RUSTFLAGS=-C target-feature=+crt-static" >> $GITHUB_ENV - name: Install Rust (${{ matrix.version.name }}) uses: actions-rust-lang/setup-rust-toolchain@v1.8.0 with: toolchain: ${{ matrix.version.version }} - - name: Install cargo-hack + - name: Install cargo-hack and cargo-ci-cache-clean uses: taiki-e/install-action@v2.26.8 with: - tool: cargo-hack + tool: cargo-hack,cargo-ci-cache-clean - name: check minimal run: cargo ci-check-min @@ -57,10 +57,12 @@ jobs: - name: tests timeout-minutes: 60 + shell: bash run: | + set -e cargo test --lib --tests -p=actix-router --all-features cargo test --lib --tests -p=actix-http --all-features - cargo test --lib --tests -p=actix-web --features=rustls-0_20,rustls-0_21,openssl -- --skip=test_reading_deflate_encoding_large_random_rustls + cargo test --lib --tests -p=actix-web --features=rustls-0_20,rustls-0_21,rustls-0_22,openssl -- --skip=test_reading_deflate_encoding_large_random_rustls cargo test --lib --tests -p=actix-web-codegen --all-features cargo test --lib --tests -p=awc --all-features cargo test --lib --tests -p=actix-http-test --all-features @@ -69,11 +71,6 @@ jobs: cargo test --lib --tests -p=actix-multipart --all-features cargo test --lib --tests -p=actix-web-actors --all-features - - name: Install cargo-ci-cache-clean - uses: taiki-e/install-action@v2.26.8 - with: - tool: cargo-ci-cache-clean - - name: CI cache clean run: cargo-ci-cache-clean diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5d2f5bb1..79c581b8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -37,22 +37,22 @@ jobs: - name: Install OpenSSL if: matrix.target.os == 'windows-latest' - run: choco install openssl -y --forcex64 --no-progress --version=3.2.1 - - name: Set OpenSSL dir in env - if: matrix.target.os == 'windows-latest' + shell: bash run: | - echo 'OPENSSL_DIR=C:\Program Files\OpenSSL-Win64' | Out-File -FilePath $env:GITHUB_ENV -Append - echo 'OPENSSL_DIR=C:\Program Files\OpenSSL' | Out-File -FilePath $env:GITHUB_ENV -Append + set -e + choco install openssl --version=1.1.1.2100 -y --no-progress + echo 'OPENSSL_DIR=C:\Program Files\OpenSSL' >> $GITHUB_ENV + echo "RUSTFLAGS=-C target-feature=+crt-static" >> $GITHUB_ENV - name: Install Rust (${{ matrix.version.name }}) uses: actions-rust-lang/setup-rust-toolchain@v1.8.0 with: toolchain: ${{ matrix.version.version }} - - name: Install cargo-hack + - name: Install cargo-hack and cargo-ci-cache-clean uses: taiki-e/install-action@v2.26.8 with: - tool: cargo-hack + tool: cargo-hack,cargo-ci-cache-clean - name: workaround MSRV issues if: matrix.version.name == 'msrv' @@ -71,10 +71,12 @@ jobs: - name: tests timeout-minutes: 60 + shell: bash run: | + set -e cargo test --lib --tests -p=actix-router --all-features cargo test --lib --tests -p=actix-http --all-features - cargo test --lib --tests -p=actix-web --features=rustls-0_20,rustls-0_21,openssl -- --skip=test_reading_deflate_encoding_large_random_rustls + cargo test --lib --tests -p=actix-web --features=rustls-0_20,rustls-0_21,rustls-0_22,openssl -- --skip=test_reading_deflate_encoding_large_random_rustls cargo test --lib --tests -p=actix-web-codegen --all-features cargo test --lib --tests -p=awc --all-features cargo test --lib --tests -p=actix-http-test --all-features @@ -83,11 +85,6 @@ jobs: cargo test --lib --tests -p=actix-multipart --all-features cargo test --lib --tests -p=actix-web-actors --all-features - - name: Install cargo-ci-cache-clean - uses: taiki-e/install-action@v2.26.8 - with: - tool: cargo-ci-cache-clean - - name: CI cache clean run: cargo-ci-cache-clean diff --git a/actix-files/src/lib.rs b/actix-files/src/lib.rs index 5b1f14ee..8381519a 100644 --- a/actix-files/src/lib.rs +++ b/actix-files/src/lib.rs @@ -568,6 +568,7 @@ mod tests { assert_eq!(bytes, data); } + #[cfg(not(target_os = "windows"))] #[actix_rt::test] async fn test_static_files_with_special_characters() { // Create the file we want to test against ad-hoc. We can't check it in as otherwise diff --git a/actix-http/CHANGES.md b/actix-http/CHANGES.md index 3ce06442..aca2a257 100644 --- a/actix-http/CHANGES.md +++ b/actix-http/CHANGES.md @@ -4,6 +4,8 @@ ### Added +- Add `rustls-0_22` crate feature. +- Add `{h1::H1Service, h2::H2Service, HttpService}::rustls_0_22()` and `HttpService::rustls_0_22_with_config()` service constructors. - Implement `From<&HeaderMap>` for `http::HeaderMap`. ## 3.5.1 diff --git a/actix-http/Cargo.toml b/actix-http/Cargo.toml index e7d50c31..3a300016 100644 --- a/actix-http/Cargo.toml +++ b/actix-http/Cargo.toml @@ -20,8 +20,18 @@ edition.workspace = true rust-version.workspace = true [package.metadata.docs.rs] -# features that docs.rs will build with -features = ["http2", "ws", "openssl", "rustls-0_20", "rustls-0_21", "compress-brotli", "compress-gzip", "compress-zstd"] +rustdoc-args = ["--cfg", "docsrs"] +features = [ + "http2", + "ws", + "openssl", + "rustls-0_20", + "rustls-0_21", + "rustls-0_22", + "compress-brotli", + "compress-gzip", + "compress-zstd", +] [lib] name = "actix_http" @@ -53,6 +63,9 @@ rustls-0_20 = ["actix-tls/accept", "actix-tls/rustls-0_20"] # TLS via Rustls v0.21 rustls-0_21 = ["actix-tls/accept", "actix-tls/rustls-0_21"] +# TLS via Rustls v0.22 +rustls-0_22 = ["actix-tls/accept", "actix-tls/rustls-0_22"] + # Compression codecs compress-brotli = ["__compress", "brotli"] compress-gzip = ["__compress", "flate2"] @@ -98,7 +111,7 @@ rand = { version = "0.8", optional = true } sha1 = { version = "0.10", optional = true } # openssl/rustls -actix-tls = { version = "3.1", default-features = false, optional = true } +actix-tls = { version = "3.3", default-features = false, optional = true } # compress-* brotli = { version = "3.3.3", optional = true } @@ -108,7 +121,7 @@ zstd = { version = "0.13", optional = true } [dev-dependencies] actix-http-test = { version = "3", features = ["openssl"] } actix-server = "2" -actix-tls = { version = "3.1", features = ["openssl"] } +actix-tls = { version = "3.3", features = ["openssl", "rustls-0_22-webpki-roots"] } actix-web = "4" async-stream = "0.3" @@ -117,24 +130,24 @@ env_logger = "0.10" futures-util = { version = "0.3.17", default-features = false, features = ["alloc"] } memchr = "2.4" once_cell = "1.9" -rcgen = "0.11" +rcgen = "0.12" regex = "1.3" rustversion = "1" -rustls-pemfile = "1" +rustls-pemfile = "2" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" static_assertions = "1" tls-openssl = { package = "openssl", version = "0.10.55" } -tls-rustls_021 = { package = "rustls", version = "0.21" } +tls-rustls_022 = { package = "rustls", version = "0.22" } tokio = { version = "1.24.2", features = ["net", "rt", "macros"] } [[example]] name = "ws" -required-features = ["ws", "rustls-0_21"] +required-features = ["ws", "rustls-0_22"] [[example]] name = "tls_rustls" -required-features = ["http2", "rustls-0_21"] +required-features = ["http2", "rustls-0_22"] [[bench]] name = "response-body-compression" diff --git a/actix-http/examples/tls_rustls.rs b/actix-http/examples/tls_rustls.rs index fbb55c6a..47ff061c 100644 --- a/actix-http/examples/tls_rustls.rs +++ b/actix-http/examples/tls_rustls.rs @@ -12,7 +12,7 @@ //! Protocol: HTTP/1.1 //! ``` -extern crate tls_rustls_021 as rustls; +extern crate tls_rustls_022 as rustls; use std::io; @@ -36,7 +36,7 @@ async fn main() -> io::Result<()> { ); ok::<_, Error>(Response::ok().set_body(body)) }) - .rustls_021(rustls_config()) + .rustls_0_22(rustls_config()) })? .run() .await @@ -51,16 +51,18 @@ fn rustls_config() -> rustls::ServerConfig { let key_file = &mut io::BufReader::new(key_file.as_bytes()); let cert_chain = rustls_pemfile::certs(cert_file) - .unwrap() - .into_iter() - .map(rustls::Certificate) - .collect(); - let mut keys = rustls_pemfile::pkcs8_private_keys(key_file).unwrap(); + .collect::, _>>() + .unwrap(); + let mut keys = rustls_pemfile::pkcs8_private_keys(key_file) + .collect::, _>>() + .unwrap(); let mut config = rustls::ServerConfig::builder() - .with_safe_defaults() .with_no_client_auth() - .with_single_cert(cert_chain, rustls::PrivateKey(keys.remove(0))) + .with_single_cert( + cert_chain, + rustls::pki_types::PrivateKeyDer::Pkcs8(keys.remove(0)), + ) .unwrap(); const H1_ALPN: &[u8] = b"http/1.1"; diff --git a/actix-http/examples/ws.rs b/actix-http/examples/ws.rs index 241175ae..55085fd7 100644 --- a/actix-http/examples/ws.rs +++ b/actix-http/examples/ws.rs @@ -1,7 +1,7 @@ //! Sets up a WebSocket server over TCP and TLS. //! Sends a heartbeat message every 4 seconds but does not respond to any incoming frames. -extern crate tls_rustls_021 as rustls; +extern crate tls_rustls_022 as rustls; use std::{ io, @@ -30,7 +30,7 @@ async fn main() -> io::Result<()> { .bind("tls", ("127.0.0.1", 8443), || { HttpService::build() .finish(handler) - .rustls_021(tls_config()) + .rustls_0_22(tls_config()) })? .run() .await @@ -85,7 +85,6 @@ impl Stream for Heartbeat { fn tls_config() -> rustls::ServerConfig { use std::io::BufReader; - use rustls::{Certificate, PrivateKey}; use rustls_pemfile::{certs, pkcs8_private_keys}; let cert = rcgen::generate_simple_self_signed(vec!["localhost".to_owned()]).unwrap(); @@ -95,17 +94,17 @@ fn tls_config() -> rustls::ServerConfig { let cert_file = &mut BufReader::new(cert_file.as_bytes()); let key_file = &mut BufReader::new(key_file.as_bytes()); - let cert_chain = certs(cert_file) - .unwrap() - .into_iter() - .map(Certificate) - .collect(); - let mut keys = pkcs8_private_keys(key_file).unwrap(); + let cert_chain = certs(cert_file).collect::, _>>().unwrap(); + let mut keys = pkcs8_private_keys(key_file) + .collect::, _>>() + .unwrap(); let mut config = rustls::ServerConfig::builder() - .with_safe_defaults() .with_no_client_auth() - .with_single_cert(cert_chain, PrivateKey(keys.remove(0))) + .with_single_cert( + cert_chain, + rustls::pki_types::PrivateKeyDer::Pkcs8(keys.remove(0)), + ) .unwrap(); config.alpn_protocols.push(b"http/1.1".to_vec()); diff --git a/actix-http/src/h1/service.rs b/actix-http/src/h1/service.rs index 3b27e3db..64eb39c8 100644 --- a/actix-http/src/h1/service.rs +++ b/actix-http/src/h1/service.rs @@ -153,7 +153,7 @@ mod openssl { } #[cfg(feature = "rustls-0_20")] -mod rustls_020 { +mod rustls_0_20 { use std::io; use actix_service::ServiceFactoryExt as _; @@ -214,7 +214,7 @@ mod rustls_020 { } #[cfg(feature = "rustls-0_21")] -mod rustls_021 { +mod rustls_0_21 { use std::io; use actix_service::ServiceFactoryExt as _; @@ -274,6 +274,67 @@ mod rustls_021 { } } +#[cfg(feature = "rustls-0_22")] +mod rustls_0_22 { + use std::io; + + use actix_service::ServiceFactoryExt as _; + use actix_tls::accept::{ + rustls_0_22::{reexports::ServerConfig, Acceptor, TlsStream}, + TlsError, + }; + + use super::*; + + impl H1Service, S, B, X, U> + where + S: ServiceFactory, + S::Future: 'static, + S::Error: Into>, + S::InitError: fmt::Debug, + S::Response: Into>, + + B: MessageBody, + + X: ServiceFactory, + X::Future: 'static, + X::Error: Into>, + X::InitError: fmt::Debug, + + U: ServiceFactory< + (Request, Framed, Codec>), + Config = (), + Response = (), + >, + U::Future: 'static, + U::Error: fmt::Display + Into>, + U::InitError: fmt::Debug, + { + /// Create Rustls v0.22 based service. + pub fn rustls_0_22( + self, + config: ServerConfig, + ) -> impl ServiceFactory< + TcpStream, + Config = (), + Response = (), + Error = TlsError, + InitError = (), + > { + Acceptor::new(config) + .map_init_err(|_| { + unreachable!("TLS acceptor service factory does not error on init") + }) + .map_err(TlsError::into_service_error) + .map(|io: TlsStream| { + let peer_addr = io.get_ref().0.peer_addr().ok(); + (io, peer_addr) + }) + .and_then(self.map_err(TlsError::Service)) + } + } +} + impl H1Service where S: ServiceFactory, diff --git a/actix-http/src/h2/service.rs b/actix-http/src/h2/service.rs index 0ae7ea68..d50ffc4e 100644 --- a/actix-http/src/h2/service.rs +++ b/actix-http/src/h2/service.rs @@ -141,7 +141,7 @@ mod openssl { } #[cfg(feature = "rustls-0_20")] -mod rustls_020 { +mod rustls_0_20 { use std::io; use actix_service::ServiceFactoryExt as _; @@ -192,7 +192,7 @@ mod rustls_020 { } #[cfg(feature = "rustls-0_21")] -mod rustls_021 { +mod rustls_0_21 { use std::io; use actix_service::ServiceFactoryExt as _; @@ -242,6 +242,57 @@ mod rustls_021 { } } +#[cfg(feature = "rustls-0_22")] +mod rustls_0_22 { + use std::io; + + use actix_service::ServiceFactoryExt as _; + use actix_tls::accept::{ + rustls_0_22::{reexports::ServerConfig, Acceptor, TlsStream}, + TlsError, + }; + + use super::*; + + impl H2Service, S, B> + where + S: ServiceFactory, + S::Future: 'static, + S::Error: Into> + 'static, + S::Response: Into> + 'static, + >::Future: 'static, + + B: MessageBody + 'static, + { + /// Create Rustls v0.22 based service. + pub fn rustls_0_22( + self, + mut config: ServerConfig, + ) -> impl ServiceFactory< + TcpStream, + Config = (), + Response = (), + Error = TlsError, + InitError = S::InitError, + > { + let mut protos = vec![b"h2".to_vec()]; + protos.extend_from_slice(&config.alpn_protocols); + config.alpn_protocols = protos; + + Acceptor::new(config) + .map_init_err(|_| { + unreachable!("TLS acceptor service factory does not error on init") + }) + .map_err(TlsError::into_service_error) + .map(|io: TlsStream| { + let peer_addr = io.get_ref().0.peer_addr().ok(); + (io, peer_addr) + }) + .and_then(self.map_err(TlsError::Service)) + } + } +} + impl ServiceFactory<(T, Option)> for H2Service where T: AsyncRead + AsyncWrite + Unpin + 'static, diff --git a/actix-http/src/lib.rs b/actix-http/src/lib.rs index 888c3e06..cb82ced0 100644 --- a/actix-http/src/lib.rs +++ b/actix-http/src/lib.rs @@ -58,7 +58,12 @@ pub mod ws; #[allow(deprecated)] pub use self::payload::PayloadStream; -#[cfg(any(feature = "openssl", feature = "rustls-0_20", feature = "rustls-0_21"))] +#[cfg(any( + feature = "openssl", + feature = "rustls-0_20", + feature = "rustls-0_21", + feature = "rustls-0_22", +))] pub use self::service::TlsAcceptorConfig; pub use self::{ builder::HttpServiceBuilder, diff --git a/actix-http/src/service.rs b/actix-http/src/service.rs index fb38ba63..e2438718 100644 --- a/actix-http/src/service.rs +++ b/actix-http/src/service.rs @@ -241,13 +241,23 @@ where } /// Configuration options used when accepting TLS connection. -#[cfg(any(feature = "openssl", feature = "rustls-0_20", feature = "rustls-0_21"))] +#[cfg(any( + feature = "openssl", + feature = "rustls-0_20", + feature = "rustls-0_21", + feature = "rustls-0_22", +))] #[derive(Debug, Default)] pub struct TlsAcceptorConfig { pub(crate) handshake_timeout: Option, } -#[cfg(any(feature = "openssl", feature = "rustls-0_20", feature = "rustls-0_21"))] +#[cfg(any( + feature = "openssl", + feature = "rustls-0_20", + feature = "rustls-0_21", + feature = "rustls-0_22", +))] impl TlsAcceptorConfig { /// Set TLS handshake timeout duration. pub fn handshake_timeout(self, dur: std::time::Duration) -> Self { @@ -353,12 +363,12 @@ mod openssl { } #[cfg(feature = "rustls-0_20")] -mod rustls_020 { +mod rustls_0_20 { use std::io; use actix_service::ServiceFactoryExt as _; use actix_tls::accept::{ - rustls::{reexports::ServerConfig, Acceptor, TlsStream}, + rustls_0_20::{reexports::ServerConfig, Acceptor, TlsStream}, TlsError, }; @@ -389,7 +399,7 @@ mod rustls_020 { U::Error: fmt::Display + Into>, U::InitError: fmt::Debug, { - /// Create Rustls based service. + /// Create Rustls v0.20 based service. pub fn rustls( self, config: ServerConfig, @@ -403,7 +413,7 @@ mod rustls_020 { self.rustls_with_config(config, TlsAcceptorConfig::default()) } - /// Create Rustls based service with custom TLS acceptor configuration. + /// Create Rustls v0.20 based service with custom TLS acceptor configuration. pub fn rustls_with_config( self, mut config: ServerConfig, @@ -449,7 +459,7 @@ mod rustls_020 { } #[cfg(feature = "rustls-0_21")] -mod rustls_021 { +mod rustls_0_21 { use std::io; use actix_service::ServiceFactoryExt as _; @@ -485,7 +495,7 @@ mod rustls_021 { U::Error: fmt::Display + Into>, U::InitError: fmt::Debug, { - /// Create Rustls based service. + /// Create Rustls v0.21 based service. pub fn rustls_021( self, config: ServerConfig, @@ -499,7 +509,7 @@ mod rustls_021 { self.rustls_021_with_config(config, TlsAcceptorConfig::default()) } - /// Create Rustls based service with custom TLS acceptor configuration. + /// Create Rustls v0.21 based service with custom TLS acceptor configuration. pub fn rustls_021_with_config( self, mut config: ServerConfig, @@ -544,6 +554,102 @@ mod rustls_021 { } } +#[cfg(feature = "rustls-0_22")] +mod rustls_0_22 { + use std::io; + + use actix_service::ServiceFactoryExt as _; + use actix_tls::accept::{ + rustls_0_22::{reexports::ServerConfig, Acceptor, TlsStream}, + TlsError, + }; + + use super::*; + + impl HttpService, S, B, X, U> + where + S: ServiceFactory, + S::Future: 'static, + S::Error: Into> + 'static, + S::InitError: fmt::Debug, + S::Response: Into> + 'static, + >::Future: 'static, + + B: MessageBody + 'static, + + X: ServiceFactory, + X::Future: 'static, + X::Error: Into>, + X::InitError: fmt::Debug, + + U: ServiceFactory< + (Request, Framed, h1::Codec>), + Config = (), + Response = (), + >, + U::Future: 'static, + U::Error: fmt::Display + Into>, + U::InitError: fmt::Debug, + { + /// Create Rustls v0.22 based service. + pub fn rustls_0_22( + self, + config: ServerConfig, + ) -> impl ServiceFactory< + TcpStream, + Config = (), + Response = (), + Error = TlsError, + InitError = (), + > { + self.rustls_0_22_with_config(config, TlsAcceptorConfig::default()) + } + + /// Create Rustls v0.22 based service with custom TLS acceptor configuration. + pub fn rustls_0_22_with_config( + self, + mut config: ServerConfig, + tls_acceptor_config: TlsAcceptorConfig, + ) -> impl ServiceFactory< + TcpStream, + Config = (), + Response = (), + Error = TlsError, + InitError = (), + > { + let mut protos = vec![b"h2".to_vec(), b"http/1.1".to_vec()]; + protos.extend_from_slice(&config.alpn_protocols); + config.alpn_protocols = protos; + + let mut acceptor = Acceptor::new(config); + + if let Some(handshake_timeout) = tls_acceptor_config.handshake_timeout { + acceptor.set_handshake_timeout(handshake_timeout); + } + + acceptor + .map_init_err(|_| { + unreachable!("TLS acceptor service factory does not error on init") + }) + .map_err(TlsError::into_service_error) + .and_then(|io: TlsStream| async { + let proto = if let Some(protos) = io.get_ref().1.alpn_protocol() { + if protos.windows(2).any(|window| window == b"h2") { + Protocol::Http2 + } else { + Protocol::Http1 + } + } else { + Protocol::Http1 + }; + let peer_addr = io.get_ref().0.peer_addr().ok(); + Ok((io, proto, peer_addr)) + }) + .and_then(self.map_err(TlsError::Service)) + } + } +} + impl ServiceFactory<(T, Protocol, Option)> for HttpService where diff --git a/actix-http/tests/test_rustls.rs b/actix-http/tests/test_rustls.rs index c94e579e..08b3a249 100644 --- a/actix-http/tests/test_rustls.rs +++ b/actix-http/tests/test_rustls.rs @@ -1,6 +1,6 @@ -#![cfg(feature = "rustls-0_21")] +#![cfg(feature = "rustls-0_22")] -extern crate tls_rustls_021 as rustls; +extern crate tls_rustls_022 as rustls; use std::{ convert::Infallible, @@ -20,13 +20,13 @@ use actix_http::{ use actix_http_test::test_server; use actix_rt::pin; use actix_service::{fn_factory_with_config, fn_service}; -use actix_tls::connect::rustls_0_21::webpki_roots_cert_store; +use actix_tls::connect::rustls_0_22::webpki_roots_cert_store; use actix_utils::future::{err, ok, poll_fn}; use bytes::{Bytes, BytesMut}; use derive_more::{Display, Error}; use futures_core::{ready, Stream}; use futures_util::stream::once; -use rustls::{Certificate, PrivateKey, ServerConfig as RustlsServerConfig, ServerName}; +use rustls::{pki_types::ServerName, ServerConfig as RustlsServerConfig}; use rustls_pemfile::{certs, pkcs8_private_keys}; async fn load_body(stream: S) -> Result @@ -59,17 +59,17 @@ fn tls_config() -> RustlsServerConfig { let cert_file = &mut BufReader::new(cert_file.as_bytes()); let key_file = &mut BufReader::new(key_file.as_bytes()); - let cert_chain = certs(cert_file) - .unwrap() - .into_iter() - .map(Certificate) - .collect(); - let mut keys = pkcs8_private_keys(key_file).unwrap(); + let cert_chain = certs(cert_file).collect::, _>>().unwrap(); + let mut keys = pkcs8_private_keys(key_file) + .collect::, _>>() + .unwrap(); let mut config = RustlsServerConfig::builder() - .with_safe_defaults() .with_no_client_auth() - .with_single_cert(cert_chain, PrivateKey(keys.remove(0))) + .with_single_cert( + cert_chain, + rustls::pki_types::PrivateKeyDer::Pkcs8(keys.remove(0)), + ) .unwrap(); config.alpn_protocols.push(HTTP1_1_ALPN_PROTOCOL.to_vec()); @@ -83,7 +83,6 @@ pub fn get_negotiated_alpn_protocol( client_alpn_protocol: &[u8], ) -> Option> { let mut config = rustls::ClientConfig::builder() - .with_safe_defaults() .with_root_certificates(webpki_roots_cert_store()) .with_no_client_auth(); @@ -109,7 +108,7 @@ async fn h1() -> io::Result<()> { let srv = test_server(move || { HttpService::build() .h1(|_| ok::<_, Error>(Response::ok())) - .rustls_021(tls_config()) + .rustls_0_22(tls_config()) }) .await; @@ -123,7 +122,7 @@ async fn h2() -> io::Result<()> { let srv = test_server(move || { HttpService::build() .h2(|_| ok::<_, Error>(Response::ok())) - .rustls_021(tls_config()) + .rustls_0_22(tls_config()) }) .await; @@ -141,7 +140,7 @@ async fn h1_1() -> io::Result<()> { assert_eq!(req.version(), Version::HTTP_11); ok::<_, Error>(Response::ok()) }) - .rustls_021(tls_config()) + .rustls_0_22(tls_config()) }) .await; @@ -159,7 +158,7 @@ async fn h2_1() -> io::Result<()> { assert_eq!(req.version(), Version::HTTP_2); ok::<_, Error>(Response::ok()) }) - .rustls_021_with_config( + .rustls_0_22_with_config( tls_config(), TlsAcceptorConfig::default().handshake_timeout(Duration::from_secs(5)), ) @@ -180,7 +179,7 @@ async fn h2_body1() -> io::Result<()> { let body = load_body(req.take_payload()).await?; Ok::<_, Error>(Response::ok().set_body(body)) }) - .rustls_021(tls_config()) + .rustls_0_22(tls_config()) }) .await; @@ -206,7 +205,7 @@ async fn h2_content_length() { ]; ok::<_, Infallible>(Response::new(statuses[indx])) }) - .rustls_021(tls_config()) + .rustls_0_22(tls_config()) }) .await; @@ -278,7 +277,7 @@ async fn h2_headers() { } ok::<_, Infallible>(config.body(data.clone())) }) - .rustls_021(tls_config()) + .rustls_0_22(tls_config()) }) .await; @@ -317,7 +316,7 @@ async fn h2_body2() { let mut srv = test_server(move || { HttpService::build() .h2(|_| ok::<_, Infallible>(Response::ok().set_body(STR))) - .rustls_021(tls_config()) + .rustls_0_22(tls_config()) }) .await; @@ -334,7 +333,7 @@ async fn h2_head_empty() { let mut srv = test_server(move || { HttpService::build() .finish(|_| ok::<_, Infallible>(Response::ok().set_body(STR))) - .rustls_021(tls_config()) + .rustls_0_22(tls_config()) }) .await; @@ -360,7 +359,7 @@ async fn h2_head_binary() { let mut srv = test_server(move || { HttpService::build() .h2(|_| ok::<_, Infallible>(Response::ok().set_body(STR))) - .rustls_021(tls_config()) + .rustls_0_22(tls_config()) }) .await; @@ -385,7 +384,7 @@ async fn h2_head_binary2() { let srv = test_server(move || { HttpService::build() .h2(|_| ok::<_, Infallible>(Response::ok().set_body(STR))) - .rustls_021(tls_config()) + .rustls_0_22(tls_config()) }) .await; @@ -411,7 +410,7 @@ async fn h2_body_length() { Response::ok().set_body(SizedStream::new(STR.len() as u64, body)), ) }) - .rustls_021(tls_config()) + .rustls_0_22(tls_config()) }) .await; @@ -435,7 +434,7 @@ async fn h2_body_chunked_explicit() { .body(BodyStream::new(body)), ) }) - .rustls_021(tls_config()) + .rustls_0_22(tls_config()) }) .await; @@ -464,7 +463,7 @@ async fn h2_response_http_error_handling() { ) })) })) - .rustls_021(tls_config()) + .rustls_0_22(tls_config()) }) .await; @@ -494,7 +493,7 @@ async fn h2_service_error() { let mut srv = test_server(move || { HttpService::build() .h2(|_| err::, _>(BadRequest)) - .rustls_021(tls_config()) + .rustls_0_22(tls_config()) }) .await; @@ -511,7 +510,7 @@ async fn h1_service_error() { let mut srv = test_server(move || { HttpService::build() .h1(|_| err::, _>(BadRequest)) - .rustls_021(tls_config()) + .rustls_0_22(tls_config()) }) .await; @@ -534,7 +533,7 @@ async fn alpn_h1() -> io::Result<()> { config.alpn_protocols.push(CUSTOM_ALPN_PROTOCOL.to_vec()); HttpService::build() .h1(|_| ok::<_, Error>(Response::ok())) - .rustls_021(config) + .rustls_0_22(config) }) .await; @@ -556,7 +555,7 @@ async fn alpn_h2() -> io::Result<()> { config.alpn_protocols.push(CUSTOM_ALPN_PROTOCOL.to_vec()); HttpService::build() .h2(|_| ok::<_, Error>(Response::ok())) - .rustls_021(config) + .rustls_0_22(config) }) .await; @@ -582,7 +581,7 @@ async fn alpn_h2_1() -> io::Result<()> { config.alpn_protocols.push(CUSTOM_ALPN_PROTOCOL.to_vec()); HttpService::build() .finish(|_| ok::<_, Error>(Response::ok())) - .rustls_021(config) + .rustls_0_22(config) }) .await; diff --git a/actix-test/CHANGES.md b/actix-test/CHANGES.md index a3ca7fe1..bdacc8b2 100644 --- a/actix-test/CHANGES.md +++ b/actix-test/CHANGES.md @@ -2,6 +2,8 @@ ## Unreleased +- Add `TestServerConfig::rustls_0_22()` method for Rustls v0.22 support behind new `rustls-0_22` crate feature. + ## 0.1.2 - Add `TestServerConfig::rustls_021()` method for Rustls v0.21 support behind new `rustls-0_21` crate feature. diff --git a/actix-test/Cargo.toml b/actix-test/Cargo.toml index 46d65abd..d5be2538 100644 --- a/actix-test/Cargo.toml +++ b/actix-test/Cargo.toml @@ -27,6 +27,8 @@ rustls = ["rustls-0_20"] rustls-0_20 = ["tls-rustls-0_20", "actix-http/rustls-0_20", "awc/rustls-0_20"] # TLS via Rustls v0.21 rustls-0_21 = ["tls-rustls-0_21", "actix-http/rustls-0_21", "awc/rustls-0_21"] +# TLS via Rustls v0.22 +rustls-0_22 = ["tls-rustls-0_22", "actix-http/rustls-0_22", "awc/rustls-0_22-webpki-roots"] # TLS via OpenSSL openssl = ["tls-openssl", "actix-http/openssl", "awc/openssl"] @@ -50,4 +52,5 @@ serde_urlencoded = "0.7" tls-openssl = { package = "openssl", version = "0.10.55", optional = true } tls-rustls-0_20 = { package = "rustls", version = "0.20", optional = true } tls-rustls-0_21 = { package = "rustls", version = "0.21", optional = true } +tls-rustls-0_22 = { package = "rustls", version = "0.22", optional = true } tokio = { version = "1.24.2", features = ["sync"] } diff --git a/actix-test/src/lib.rs b/actix-test/src/lib.rs index e570bb26..b7aeddad 100644 --- a/actix-test/src/lib.rs +++ b/actix-test/src/lib.rs @@ -143,6 +143,8 @@ where StreamType::Rustls020(_) => true, #[cfg(feature = "rustls-0_21")] StreamType::Rustls021(_) => true, + #[cfg(feature = "rustls-0_22")] + StreamType::Rustls022(_) => true, }; // run server in separate orphaned thread @@ -327,6 +329,48 @@ where .rustls_021(config.clone()) }), }, + #[cfg(feature = "rustls-0_22")] + StreamType::Rustls022(config) => match cfg.tp { + HttpVer::Http1 => builder.listen("test", tcp, move || { + let app_cfg = + AppConfig::__priv_test_new(false, local_addr.to_string(), local_addr); + + let fac = factory() + .into_factory() + .map_err(|err| err.into().error_response()); + + HttpService::build() + .client_request_timeout(timeout) + .h1(map_config(fac, move |_| app_cfg.clone())) + .rustls_0_22(config.clone()) + }), + HttpVer::Http2 => builder.listen("test", tcp, move || { + let app_cfg = + AppConfig::__priv_test_new(false, local_addr.to_string(), local_addr); + + let fac = factory() + .into_factory() + .map_err(|err| err.into().error_response()); + + HttpService::build() + .client_request_timeout(timeout) + .h2(map_config(fac, move |_| app_cfg.clone())) + .rustls_0_22(config.clone()) + }), + HttpVer::Both => builder.listen("test", tcp, move || { + let app_cfg = + AppConfig::__priv_test_new(false, local_addr.to_string(), local_addr); + + let fac = factory() + .into_factory() + .map_err(|err| err.into().error_response()); + + HttpService::build() + .client_request_timeout(timeout) + .finish(map_config(fac, move |_| app_cfg.clone())) + .rustls_0_22(config.clone()) + }), + }, } .expect("test server could not be created"); @@ -401,6 +445,8 @@ enum StreamType { Rustls020(tls_rustls_0_20::ServerConfig), #[cfg(feature = "rustls-0_21")] Rustls021(tls_rustls_0_21::ServerConfig), + #[cfg(feature = "rustls-0_22")] + Rustls022(tls_rustls_0_22::ServerConfig), } /// Create default test server config. @@ -424,7 +470,7 @@ impl Default for TestServerConfig { } impl TestServerConfig { - /// Create default server configuration + /// Constructs default server configuration. pub(crate) fn new() -> TestServerConfig { TestServerConfig { tp: HttpVer::Both, @@ -435,40 +481,63 @@ impl TestServerConfig { } } - /// Accept HTTP/1.1 only. + /// Accepts HTTP/1.1 only. pub fn h1(mut self) -> Self { self.tp = HttpVer::Http1; self } - /// Accept HTTP/2 only. + /// Accepts HTTP/2 only. pub fn h2(mut self) -> Self { self.tp = HttpVer::Http2; self } - /// Accept secure connections via OpenSSL. + /// Accepts secure connections via OpenSSL. #[cfg(feature = "openssl")] pub fn openssl(mut self, acceptor: openssl::ssl::SslAcceptor) -> Self { self.stream = StreamType::Openssl(acceptor); self } - /// Accept secure connections via Rustls. + #[doc(hidden)] + #[deprecated(note = "Renamed to `rustls_0_20()`.")] #[cfg(feature = "rustls-0_20")] pub fn rustls(mut self, config: tls_rustls_0_20::ServerConfig) -> Self { self.stream = StreamType::Rustls020(config); self } - /// Accept secure connections via Rustls. + /// Accepts secure connections via Rustls v0.20. + #[cfg(feature = "rustls-0_20")] + pub fn rustls_0_20(mut self, config: tls_rustls_0_20::ServerConfig) -> Self { + self.stream = StreamType::Rustls020(config); + self + } + + #[doc(hidden)] + #[deprecated(note = "Renamed to `rustls_0_21()`.")] #[cfg(feature = "rustls-0_21")] pub fn rustls_021(mut self, config: tls_rustls_0_21::ServerConfig) -> Self { self.stream = StreamType::Rustls021(config); self } - /// Set client timeout for first request. + /// Accepts secure connections via Rustls v0.21. + #[cfg(feature = "rustls-0_21")] + pub fn rustls_0_21(mut self, config: tls_rustls_0_21::ServerConfig) -> Self { + self.stream = StreamType::Rustls021(config); + self + } + + /// Accepts secure connections via Rustls v0.22. + #[cfg(feature = "rustls-0_22")] + pub fn rustls_0_22(mut self, config: tls_rustls_0_22::ServerConfig) -> Self { + self.stream = StreamType::Rustls022(config); + self + } + + /// Sets client timeout for first request. pub fn client_request_timeout(mut self, dur: Duration) -> Self { self.client_request_timeout = dur; self diff --git a/actix-web/CHANGES.md b/actix-web/CHANGES.md index 674c834a..072cdc01 100644 --- a/actix-web/CHANGES.md +++ b/actix-web/CHANGES.md @@ -2,6 +2,9 @@ ## Unreleased +- Add `rustls-0_22` crate feature. +- Add `HttpServer::{bind_rustls_0_22, listen_rustls_0_22}()` builder methods. + ## 4.4.1 ### Changed diff --git a/actix-web/Cargo.toml b/actix-web/Cargo.toml index d1fc9c91..37299721 100644 --- a/actix-web/Cargo.toml +++ b/actix-web/Cargo.toml @@ -20,9 +20,20 @@ edition.workspace = true rust-version.workspace = true [package.metadata.docs.rs] -# features that docs.rs will build with -features = ["macros", "openssl", "rustls-0_20", "rustls-0_21", "compress-brotli", "compress-gzip", "compress-zstd", "cookies", "secure-cookies"] rustdoc-args = ["--cfg", "docsrs"] +features = [ + "macros", + "openssl", + "rustls-0_20", + "rustls-0_21", + "rustls-0_22", + "compress-brotli", + "compress-gzip", + "compress-zstd", + "cookies", + "secure-cookies", +] + [lib] name = "actix_web" @@ -58,6 +69,8 @@ rustls = ["rustls-0_20"] rustls-0_20 = ["http2", "actix-http/rustls-0_20", "actix-tls/accept", "actix-tls/rustls-0_20"] # TLS via Rustls v0.21 rustls-0_21 = ["http2", "actix-http/rustls-0_21", "actix-tls/accept", "actix-tls/rustls-0_21"] +# TLS via Rustls v0.22 +rustls-0_22 = ["http2", "actix-http/rustls-0_22", "actix-tls/accept", "actix-tls/rustls-0_22"] # Internal (PRIVATE!) features used to aid testing and checking feature status. # Don't rely on these whatsoever. They may disappear at anytime. @@ -73,7 +86,7 @@ actix-rt = { version = "2.6", default-features = false } actix-server = "2" actix-service = "2" actix-utils = "3" -actix-tls = { version = "3.1", default-features = false, optional = true } +actix-tls = { version = "3.3", default-features = false, optional = true } actix-http = { version = "3.5", features = ["ws"] } actix-router = "0.5" diff --git a/actix-web/src/server.rs b/actix-web/src/server.rs index 2cc00cb9..193a7cce 100644 --- a/actix-web/src/server.rs +++ b/actix-web/src/server.rs @@ -442,6 +442,25 @@ where Ok(self) } + /// Resolves socket address(es) and binds server to created listener(s) for TLS connections + /// using Rustls v0.22. + /// + /// See [`bind()`](Self::bind()) for more details on `addrs` argument. + /// + /// ALPN protocols "h2" and "http/1.1" are added to any configured ones. + #[cfg(feature = "rustls-0_22")] + pub fn bind_rustls_0_22( + mut self, + addrs: A, + config: actix_tls::accept::rustls_0_22::reexports::ServerConfig, + ) -> io::Result { + let sockets = bind_addrs(addrs, self.backlog)?; + for lst in sockets { + self = self.listen_rustls_0_22_inner(lst, config.clone())?; + } + Ok(self) + } + /// Resolves socket address(es) and binds server to created listener(s) for TLS connections /// using OpenSSL. /// @@ -685,6 +704,72 @@ where Ok(self) } + /// Binds to existing listener for accepting incoming TLS connection requests using Rustls + /// v0.22. + /// + /// See [`listen()`](Self::listen) for more details on the `lst` argument. + /// + /// ALPN protocols "h2" and "http/1.1" are added to any configured ones. + #[cfg(feature = "rustls-0_22")] + pub fn listen_rustls_0_22( + self, + lst: net::TcpListener, + config: actix_tls::accept::rustls_0_22::reexports::ServerConfig, + ) -> io::Result { + self.listen_rustls_0_22_inner(lst, config) + } + + #[cfg(feature = "rustls-0_22")] + fn listen_rustls_0_22_inner( + mut self, + lst: net::TcpListener, + config: actix_tls::accept::rustls_0_22::reexports::ServerConfig, + ) -> io::Result { + let factory = self.factory.clone(); + let cfg = self.config.clone(); + let addr = lst.local_addr().unwrap(); + self.sockets.push(Socket { + addr, + scheme: "https", + }); + + let on_connect_fn = self.on_connect_fn.clone(); + + self.builder = + self.builder + .listen(format!("actix-web-service-{}", addr), lst, move || { + let c = cfg.lock().unwrap(); + let host = c.host.clone().unwrap_or_else(|| format!("{}", addr)); + + let svc = HttpService::build() + .keep_alive(c.keep_alive) + .client_request_timeout(c.client_request_timeout) + .client_disconnect_timeout(c.client_disconnect_timeout); + + let svc = if let Some(handler) = on_connect_fn.clone() { + svc.on_connect_ext(move |io: &_, ext: _| (handler)(io as &dyn Any, ext)) + } else { + svc + }; + + let fac = factory() + .into_factory() + .map_err(|err| err.into().error_response()); + + let acceptor_config = match c.tls_handshake_timeout { + Some(dur) => TlsAcceptorConfig::default().handshake_timeout(dur), + None => TlsAcceptorConfig::default(), + }; + + svc.finish(map_config(fac, move |_| { + AppConfig::new(true, host.clone(), addr) + })) + .rustls_0_22_with_config(config.clone(), acceptor_config) + })?; + + Ok(self) + } + /// Binds to existing listener for accepting incoming TLS connection requests using OpenSSL. /// /// See [`listen()`](Self::listen) for more details on the `lst` argument. diff --git a/actix-web/tests/test_server.rs b/actix-web/tests/test_server.rs index a268cb6e..0df6e212 100644 --- a/actix-web/tests/test_server.rs +++ b/actix-web/tests/test_server.rs @@ -743,7 +743,7 @@ mod plus_rustls { .map(char::from) .collect::(); - let srv = actix_test::start_with(actix_test::config().rustls_021(tls_config()), || { + let srv = actix_test::start_with(actix_test::config().rustls_0_21(tls_config()), || { App::new().service(web::resource("/").route(web::to(|bytes: Bytes| async { // echo decompressed request body back in response HttpResponse::Ok() diff --git a/awc/CHANGES.md b/awc/CHANGES.md index 6f4212f9..3cef0e13 100644 --- a/awc/CHANGES.md +++ b/awc/CHANGES.md @@ -2,6 +2,9 @@ ## Unreleased +- Add `rustls-0_22-webpki-roots` and `rustls-0_22-native-roots` crate feature. +- Add `awc::Connector::rustls_0_22()` method. + ## 3.3.0 - Update `trust-dns-resolver` dependency to `0.23`. diff --git a/awc/Cargo.toml b/awc/Cargo.toml index 5c09400a..369119c2 100644 --- a/awc/Cargo.toml +++ b/awc/Cargo.toml @@ -20,8 +20,17 @@ name = "awc" path = "src/lib.rs" [package.metadata.docs.rs] -# features that docs.rs will build with -features = ["openssl", "rustls-0_20", "rustls-0_21", "compress-brotli", "compress-gzip", "compress-zstd", "cookies"] +rustdoc-args = ["--cfg", "docsrs"] +features = [ + "cookies", + "openssl", + "rustls-0_20", + "rustls-0_21", + "rustls-0_22-webpki-roots", + "compress-brotli", + "compress-gzip", + "compress-zstd", +] [features] default = ["compress-brotli", "compress-gzip", "compress-zstd", "cookies"] @@ -35,6 +44,10 @@ rustls = ["rustls-0_20"] rustls-0_20 = ["tls-rustls-0_20", "actix-tls/rustls-0_20"] # TLS via Rustls v0.21 rustls-0_21 = ["tls-rustls-0_21", "actix-tls/rustls-0_21"] +# TLS via Rustls v0.22 (WebPKI roots) +rustls-0_22-webpki-roots = ["tls-rustls-0_22", "actix-tls/rustls-0_22-webpki-roots"] +# TLS via Rustls v0.22 (Native roots) +rustls-0_22-native-roots = ["tls-rustls-0_22", "actix-tls/rustls-0_22-native-roots"] # Brotli algorithm content-encoding support compress-brotli = ["actix-http/compress-brotli", "__compress"] @@ -63,7 +76,7 @@ actix-codec = "0.5" actix-service = "2" actix-http = { version = "3.5", features = ["http2", "ws"] } actix-rt = { version = "2.1", default-features = false } -actix-tls = { version = "3.1", features = ["connect", "uri"] } +actix-tls = { version = "3.3", features = ["connect", "uri"] } actix-utils = "3" base64 = "0.21" @@ -90,6 +103,7 @@ cookie = { version = "0.16", features = ["percent-encode"], optional = true } tls-openssl = { package = "openssl", version = "0.10.55", optional = true } tls-rustls-0_20 = { package = "rustls", version = "0.20", optional = true, features = ["dangerous_configuration"] } tls-rustls-0_21 = { package = "rustls", version = "0.21", optional = true, features = ["dangerous_configuration"] } +tls-rustls-0_22 = { package = "rustls", version = "0.22", optional = true } trust-dns-resolver = { version = "0.23", optional = true } @@ -97,8 +111,8 @@ trust-dns-resolver = { version = "0.23", optional = true } actix-http = { version = "3.5", features = ["openssl"] } actix-http-test = { version = "3", features = ["openssl"] } actix-server = "2" -actix-test = { version = "0.1", features = ["openssl", "rustls-0_21"] } -actix-tls = { version = "3", features = ["openssl", "rustls-0_21"] } +actix-test = { version = "0.1", features = ["openssl", "rustls-0_22"] } +actix-tls = { version = "3.3", features = ["openssl", "rustls-0_22"] } actix-utils = "3" actix-web = { version = "4", features = ["openssl"] } @@ -108,11 +122,11 @@ env_logger = "0.10" flate2 = "1.0.13" futures-util = { version = "0.3.17", default-features = false } static_assertions = "1.1" -rcgen = "0.11" -rustls-pemfile = "1" +rcgen = "0.12" +rustls-pemfile = "2" tokio = { version = "1.24.2", features = ["rt-multi-thread", "macros"] } zstd = "0.13" [[example]] name = "client" -required-features = ["rustls-0_21"] +required-features = ["rustls-0_22-webpki-roots"] diff --git a/awc/src/client/connector.rs b/awc/src/client/connector.rs index 879d1895..df6e422f 100644 --- a/awc/src/client/connector.rs +++ b/awc/src/client/connector.rs @@ -40,14 +40,23 @@ enum OurTlsConnector { /// Provided because building the OpenSSL context on newer versions can be very slow. /// This prevents unnecessary calls to `.build()` while constructing the client connector. #[cfg(feature = "openssl")] - #[allow(dead_code)] // false positive; used in build_ssl + #[allow(dead_code)] // false positive; used in build_tls OpensslBuilder(actix_tls::connect::openssl::reexports::SslConnectorBuilder), #[cfg(feature = "rustls-0_20")] + #[allow(dead_code)] // false positive; used in build_tls Rustls020(std::sync::Arc), #[cfg(feature = "rustls-0_21")] + #[allow(dead_code)] // false positive; used in build_tls Rustls021(std::sync::Arc), + + #[cfg(any( + feature = "rustls-0_22-webpki-roots", + feature = "rustls-0_22-native-roots", + ))] + #[allow(dead_code)] // false positive; used in build_tls + Rustls022(std::sync::Arc), } /// Manages HTTP client network connectivity. @@ -86,67 +95,83 @@ impl Connector<()> { } } - /// Provides an empty TLS connector when no TLS feature is enabled. - #[cfg(not(any(feature = "openssl", feature = "rustls-0_20", feature = "rustls-0_21")))] - fn build_tls(_: Vec>) -> OurTlsConnector { - OurTlsConnector::None - } + cfg_if::cfg_if! { + if #[cfg(any(feature = "rustls-0_22-webpki-roots", feature = "rustls-0_22-webpki-roots"))] { + /// Build TLS connector with Rustls v0.22, based on supplied ALPN protocols. + /// + /// Note that if other TLS crate features are enabled, Rustls v0.22 will be used. + fn build_tls(protocols: Vec>) -> OurTlsConnector { + use actix_tls::connect::rustls_0_22::{self, reexports::ClientConfig}; - /// Build TLS connector with Rustls v0.21, based on supplied ALPN protocols - /// - /// Note that if other TLS crate features are enabled, Rustls v0.21 will be used. - #[cfg(feature = "rustls-0_21")] - fn build_tls(protocols: Vec>) -> OurTlsConnector { - use actix_tls::connect::rustls_0_21::{reexports::ClientConfig, webpki_roots_cert_store}; + cfg_if::cfg_if! { + if #[cfg(feature = "rustls-0_22-webpki-roots")] { + let certs = rustls_0_22::webpki_roots_cert_store(); + } else if #[cfg(feature = "rustls-0_22-native-roots")] { + let certs = rustls_0_22::native_roots_cert_store(); + } + } - let mut config = ClientConfig::builder() - .with_safe_defaults() - .with_root_certificates(webpki_roots_cert_store()) - .with_no_client_auth(); + let mut config = ClientConfig::builder() + .with_root_certificates(certs) + .with_no_client_auth(); - config.alpn_protocols = protocols; + config.alpn_protocols = protocols; - OurTlsConnector::Rustls021(std::sync::Arc::new(config)) - } + OurTlsConnector::Rustls022(std::sync::Arc::new(config)) + } + } else if #[cfg(feature = "rustls-0_21")] { + /// Build TLS connector with Rustls v0.21, based on supplied ALPN protocols. + fn build_tls(protocols: Vec>) -> OurTlsConnector { + use actix_tls::connect::rustls_0_21::{reexports::ClientConfig, webpki_roots_cert_store}; - /// Build TLS connector with Rustls v0.20, based on supplied ALPN protocols - /// - /// Note that if other TLS crate features are enabled, Rustls v0.21 will be used. - #[cfg(all(feature = "rustls-0_20", not(feature = "rustls-0_21")))] - fn build_tls(protocols: Vec>) -> OurTlsConnector { - use actix_tls::connect::rustls_0_20::{reexports::ClientConfig, webpki_roots_cert_store}; + let mut config = ClientConfig::builder() + .with_safe_defaults() + .with_root_certificates(webpki_roots_cert_store()) + .with_no_client_auth(); - let mut config = ClientConfig::builder() - .with_safe_defaults() - .with_root_certificates(webpki_roots_cert_store()) - .with_no_client_auth(); + config.alpn_protocols = protocols; - config.alpn_protocols = protocols; + OurTlsConnector::Rustls021(std::sync::Arc::new(config)) + } + } else if #[cfg(feature = "rustls-0_20")] { + /// Build TLS connector with Rustls v0.20, based on supplied ALPN protocols. + fn build_tls(protocols: Vec>) -> OurTlsConnector { + use actix_tls::connect::rustls_0_20::{reexports::ClientConfig, webpki_roots_cert_store}; - OurTlsConnector::Rustls020(std::sync::Arc::new(config)) - } + let mut config = ClientConfig::builder() + .with_safe_defaults() + .with_root_certificates(webpki_roots_cert_store()) + .with_no_client_auth(); - /// Build TLS connector with OpenSSL, based on supplied ALPN protocols - #[cfg(all( - feature = "openssl", - not(any(feature = "rustls-0_20", feature = "rustls-0_21")), - ))] - fn build_tls(protocols: Vec>) -> OurTlsConnector { - use actix_tls::connect::openssl::reexports::{SslConnector, SslMethod}; - use bytes::{BufMut, BytesMut}; + config.alpn_protocols = protocols; - let mut alpn = BytesMut::with_capacity(20); - for proto in &protocols { - alpn.put_u8(proto.len() as u8); - alpn.put(proto.as_slice()); + OurTlsConnector::Rustls020(std::sync::Arc::new(config)) + } + } else if #[cfg(feature = "openssl")] { + /// Build TLS connector with OpenSSL, based on supplied ALPN protocols. + fn build_tls(protocols: Vec>) -> OurTlsConnector { + use actix_tls::connect::openssl::reexports::{SslConnector, SslMethod}; + use bytes::{BufMut, BytesMut}; + + let mut alpn = BytesMut::with_capacity(20); + for proto in &protocols { + alpn.put_u8(proto.len() as u8); + alpn.put(proto.as_slice()); + } + + let mut ssl = SslConnector::builder(SslMethod::tls()).unwrap(); + if let Err(err) = ssl.set_alpn_protos(&alpn) { + log::error!("Can not set ALPN protocol: {err:?}"); + } + + OurTlsConnector::OpensslBuilder(ssl) + } + } else { + /// Provides an empty TLS connector when no TLS feature is enabled. + fn build_tls(_: Vec>) -> OurTlsConnector { + OurTlsConnector::None + } } - - let mut ssl = SslConnector::builder(SslMethod::tls()).unwrap(); - if let Err(err) = ssl.set_alpn_protos(&alpn) { - log::error!("Can not set ALPN protocol: {:?}", err); - } - - OurTlsConnector::OpensslBuilder(ssl) } } @@ -240,6 +265,19 @@ where self } + /// Sets custom Rustls v0.22 `ClientConfig` instance. + #[cfg(any( + feature = "rustls-0_22-webpki-roots", + feature = "rustls-0_22-native-roots", + ))] + pub fn rustls_0_22( + mut self, + connector: std::sync::Arc, + ) -> Self { + self.tls = OurTlsConnector::Rustls022(connector); + self + } + /// Sets maximum supported HTTP major version. /// /// Supported versions are HTTP/1.1 and HTTP/2. @@ -509,6 +547,42 @@ where Some(actix_service::boxed::rc_service(tls_service)) } + + #[cfg(any( + feature = "rustls-0_22-webpki-roots", + feature = "rustls-0_22-native-roots", + ))] + OurTlsConnector::Rustls022(tls) => { + const H2: &[u8] = b"h2"; + + use actix_tls::connect::rustls_0_22::{reexports::AsyncTlsStream, TlsConnector}; + + impl IntoConnectionIo for TcpConnection> { + fn into_connection_io(self) -> (Box, Protocol) { + let sock = self.into_parts().0; + let h2 = sock + .get_ref() + .1 + .alpn_protocol() + .map_or(false, |protos| protos.windows(2).any(|w| w == H2)); + if h2 { + (Box::new(sock), Protocol::Http2) + } else { + (Box::new(sock), Protocol::Http1) + } + } + } + + let handshake_timeout = self.config.handshake_timeout; + + let tls_service = TlsConnectorService { + tcp_service: tcp_service_inner, + tls_service: TlsConnector::service(tls), + timeout: handshake_timeout, + }; + + Some(actix_service::boxed::rc_service(tls_service)) + } }; let tcp_config = self.config.no_disconnect_timeout(); diff --git a/awc/tests/test_rustls_client.rs b/awc/tests/test_rustls_client.rs index d758f93d..1cc3e8c4 100644 --- a/awc/tests/test_rustls_client.rs +++ b/awc/tests/test_rustls_client.rs @@ -1,6 +1,6 @@ -#![cfg(feature = "rustls-0_21")] +#![cfg(feature = "rustls-0_22-webpki-roots")] -extern crate tls_rustls_0_21 as rustls; +extern crate tls_rustls_0_22 as rustls; use std::{ io::BufReader, @@ -8,18 +8,17 @@ use std::{ atomic::{AtomicUsize, Ordering}, Arc, }, - time::SystemTime, }; use actix_http::HttpService; use actix_http_test::test_server; use actix_service::{fn_service, map_config, ServiceFactoryExt}; -use actix_tls::connect::rustls_0_21::webpki_roots_cert_store; +use actix_tls::connect::rustls_0_22::webpki_roots_cert_store; use actix_utils::future::ok; use actix_web::{dev::AppConfig, http::Version, web, App, HttpResponse}; use rustls::{ - client::{ServerCertVerified, ServerCertVerifier}, - Certificate, ClientConfig, PrivateKey, ServerConfig, ServerName, + pki_types::{CertificateDer, PrivateKeyDer, ServerName}, + ClientConfig, ServerConfig, }; use rustls_pemfile::{certs, pkcs8_private_keys}; @@ -31,36 +30,62 @@ fn tls_config() -> ServerConfig { let cert_file = &mut BufReader::new(cert_file.as_bytes()); let key_file = &mut BufReader::new(key_file.as_bytes()); - let cert_chain = certs(cert_file) - .unwrap() - .into_iter() - .map(Certificate) - .collect(); - let mut keys = pkcs8_private_keys(key_file).unwrap(); + let cert_chain = certs(cert_file).collect::, _>>().unwrap(); + let mut keys = pkcs8_private_keys(key_file) + .collect::, _>>() + .unwrap(); ServerConfig::builder() - .with_safe_defaults() .with_no_client_auth() - .with_single_cert(cert_chain, PrivateKey(keys.remove(0))) + .with_single_cert(cert_chain, PrivateKeyDer::Pkcs8(keys.remove(0))) .unwrap() } mod danger { + use rustls::{ + client::danger::{ServerCertVerified, ServerCertVerifier}, + pki_types::UnixTime, + }; + use super::*; + #[derive(Debug)] pub struct NoCertificateVerification; impl ServerCertVerifier for NoCertificateVerification { fn verify_server_cert( &self, - _end_entity: &Certificate, - _intermediates: &[Certificate], - _server_name: &ServerName, - _scts: &mut dyn Iterator, + _end_entity: &CertificateDer<'_>, + _intermediates: &[CertificateDer<'_>], + _server_name: &ServerName<'_>, _ocsp_response: &[u8], - _now: SystemTime, + _now: UnixTime, ) -> Result { - Ok(ServerCertVerified::assertion()) + Ok(rustls::client::danger::ServerCertVerified::assertion()) + } + + fn verify_tls12_signature( + &self, + _message: &[u8], + _cert: &CertificateDer<'_>, + _dss: &rustls::DigitallySignedStruct, + ) -> Result { + Ok(rustls::client::danger::HandshakeSignatureValid::assertion()) + } + + fn verify_tls13_signature( + &self, + _message: &[u8], + _cert: &CertificateDer<'_>, + _dss: &rustls::DigitallySignedStruct, + ) -> Result { + Ok(rustls::client::danger::HandshakeSignatureValid::assertion()) + } + + fn supported_verify_schemes(&self) -> Vec { + rustls::crypto::ring::default_provider() + .signature_verification_algorithms + .supported_schemes() } } } @@ -82,14 +107,13 @@ async fn test_connection_reuse_h2() { App::new().service(web::resource("/").route(web::to(HttpResponse::Ok))), |_| AppConfig::default(), )) - .rustls_021(tls_config()) + .rustls_0_22(tls_config()) .map_err(|_| ()), ) }) .await; let mut config = ClientConfig::builder() - .with_safe_defaults() .with_root_certificates(webpki_roots_cert_store()) .with_no_client_auth(); @@ -102,7 +126,7 @@ async fn test_connection_reuse_h2() { .set_certificate_verifier(Arc::new(danger::NoCertificateVerification)); let client = awc::Client::builder() - .connector(awc::Connector::new().rustls_021(Arc::new(config))) + .connector(awc::Connector::new().rustls_0_22(Arc::new(config))) .finish(); // req 1 From 8db3de6edee25090edb377d4ae858747191e38c6 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Sun, 4 Feb 2024 00:31:14 +0000 Subject: [PATCH 037/151] chore(actix-http): prepare release 3.6.0 --- actix-http/CHANGES.md | 2 ++ actix-http/Cargo.toml | 2 +- actix-http/README.md | 4 ++-- actix-test/Cargo.toml | 2 +- actix-web/Cargo.toml | 2 +- awc/Cargo.toml | 4 ++-- scripts/bump | 1 - 7 files changed, 9 insertions(+), 8 deletions(-) diff --git a/actix-http/CHANGES.md b/actix-http/CHANGES.md index aca2a257..e3805ff7 100644 --- a/actix-http/CHANGES.md +++ b/actix-http/CHANGES.md @@ -2,6 +2,8 @@ ## Unreleased +## 3.6.0 + ### Added - Add `rustls-0_22` crate feature. diff --git a/actix-http/Cargo.toml b/actix-http/Cargo.toml index 3a300016..14b9bdac 100644 --- a/actix-http/Cargo.toml +++ b/actix-http/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "actix-http" -version = "3.5.1" +version = "3.6.0" authors = [ "Nikolay Kim ", "Rob Ede ", diff --git a/actix-http/README.md b/actix-http/README.md index 9d80c10c..c9bd1b34 100644 --- a/actix-http/README.md +++ b/actix-http/README.md @@ -5,11 +5,11 @@ [![crates.io](https://img.shields.io/crates/v/actix-http?label=latest)](https://crates.io/crates/actix-http) -[![Documentation](https://docs.rs/actix-http/badge.svg?version=3.5.1)](https://docs.rs/actix-http/3.5.1) +[![Documentation](https://docs.rs/actix-http/badge.svg?version=3.6.0)](https://docs.rs/actix-http/3.6.0) ![Version](https://img.shields.io/badge/rustc-1.68+-ab6000.svg) ![MIT or Apache 2.0 licensed](https://img.shields.io/crates/l/actix-http.svg)
-[![dependency status](https://deps.rs/crate/actix-http/3.5.1/status.svg)](https://deps.rs/crate/actix-http/3.5.1) +[![dependency status](https://deps.rs/crate/actix-http/3.6.0/status.svg)](https://deps.rs/crate/actix-http/3.6.0) [![Download](https://img.shields.io/crates/d/actix-http.svg)](https://crates.io/crates/actix-http) [![Chat on Discord](https://img.shields.io/discord/771444961383153695?label=chat&logo=discord)](https://discord.gg/NWpN5mmg3x) diff --git a/actix-test/Cargo.toml b/actix-test/Cargo.toml index d5be2538..c24e1363 100644 --- a/actix-test/Cargo.toml +++ b/actix-test/Cargo.toml @@ -35,7 +35,7 @@ openssl = ["tls-openssl", "actix-http/openssl", "awc/openssl"] [dependencies] actix-codec = "0.5" -actix-http = "3" +actix-http = "3.6" actix-http-test = "3" actix-rt = "2.1" actix-service = "2" diff --git a/actix-web/Cargo.toml b/actix-web/Cargo.toml index 37299721..16792726 100644 --- a/actix-web/Cargo.toml +++ b/actix-web/Cargo.toml @@ -88,7 +88,7 @@ actix-service = "2" actix-utils = "3" actix-tls = { version = "3.3", default-features = false, optional = true } -actix-http = { version = "3.5", features = ["ws"] } +actix-http = { version = "3.6", features = ["ws"] } actix-router = "0.5" actix-web-codegen = { version = "4.2", optional = true } diff --git a/awc/Cargo.toml b/awc/Cargo.toml index 369119c2..46603fed 100644 --- a/awc/Cargo.toml +++ b/awc/Cargo.toml @@ -74,7 +74,7 @@ dangerous-h2c = [] [dependencies] actix-codec = "0.5" actix-service = "2" -actix-http = { version = "3.5", features = ["http2", "ws"] } +actix-http = { version = "3.6", features = ["http2", "ws"] } actix-rt = { version = "2.1", default-features = false } actix-tls = { version = "3.3", features = ["connect", "uri"] } actix-utils = "3" @@ -108,7 +108,7 @@ tls-rustls-0_22 = { package = "rustls", version = "0.22", optional = true } trust-dns-resolver = { version = "0.23", optional = true } [dev-dependencies] -actix-http = { version = "3.5", features = ["openssl"] } +actix-http = { version = "3.6", features = ["openssl"] } actix-http-test = { version = "3", features = ["openssl"] } actix-server = "2" actix-test = { version = "0.1", features = ["openssl", "rustls-0_22"] } diff --git a/scripts/bump b/scripts/bump index 22aa2af9..6fd879ea 100755 --- a/scripts/bump +++ b/scripts/bump @@ -112,7 +112,6 @@ echo read -p "Update all references: (y/N) " UPDATE_REFERENCES UPDATE_REFERENCES="${UPDATE_REFERENCES:-n}" - if [ "$UPDATE_REFERENCES" = 'y' ] || [ "$UPDATE_REFERENCES" = 'Y' ]; then if [[ $NEW_VERSION == *".0.0" ]]; then NEW_VERSION_SPEC="${NEW_VERSION%.0.0}" From 8e9e9fbcdd727d54361ea165ce64af74375c9f81 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Sun, 4 Feb 2024 00:32:28 +0000 Subject: [PATCH 038/151] chore(actix-web): prepare release 4.5.0 --- actix-test/Cargo.toml | 2 +- actix-web/CHANGES.md | 2 ++ actix-web/Cargo.toml | 2 +- actix-web/README.md | 4 ++-- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/actix-test/Cargo.toml b/actix-test/Cargo.toml index c24e1363..4e6ea086 100644 --- a/actix-test/Cargo.toml +++ b/actix-test/Cargo.toml @@ -40,7 +40,7 @@ actix-http-test = "3" actix-rt = "2.1" actix-service = "2" actix-utils = "3" -actix-web = { version = "4", default-features = false, features = ["cookies"] } +actix-web = { version = "4.5", default-features = false, features = ["cookies"] } awc = { version = "3", default-features = false, features = ["cookies"] } futures-core = { version = "0.3.17", default-features = false, features = ["std"] } diff --git a/actix-web/CHANGES.md b/actix-web/CHANGES.md index 072cdc01..174a70e6 100644 --- a/actix-web/CHANGES.md +++ b/actix-web/CHANGES.md @@ -2,6 +2,8 @@ ## Unreleased +## 4.5.0 + - Add `rustls-0_22` crate feature. - Add `HttpServer::{bind_rustls_0_22, listen_rustls_0_22}()` builder methods. diff --git a/actix-web/Cargo.toml b/actix-web/Cargo.toml index 16792726..985a103f 100644 --- a/actix-web/Cargo.toml +++ b/actix-web/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "actix-web" -version = "4.4.1" +version = "4.5.0" description = "Actix Web is a powerful, pragmatic, and extremely fast web framework for Rust" authors = [ "Nikolay Kim ", diff --git a/actix-web/README.md b/actix-web/README.md index 80ae2123..492f06fa 100644 --- a/actix-web/README.md +++ b/actix-web/README.md @@ -8,10 +8,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=4.4.1)](https://docs.rs/actix-web/4.4.1) +[![Documentation](https://docs.rs/actix-web/badge.svg?version=4.5.0)](https://docs.rs/actix-web/4.5.0) ![MSRV](https://img.shields.io/badge/rustc-1.68+-ab6000.svg) ![MIT or Apache 2.0 licensed](https://img.shields.io/crates/l/actix-web.svg) -[![Dependency Status](https://deps.rs/crate/actix-web/4.4.1/status.svg)](https://deps.rs/crate/actix-web/4.4.1) +[![Dependency Status](https://deps.rs/crate/actix-web/4.5.0/status.svg)](https://deps.rs/crate/actix-web/4.5.0)
[![CI](https://github.com/actix/actix-web/actions/workflows/ci.yml/badge.svg)](https://github.com/actix/actix-web/actions/workflows/ci.yml) [![codecov](https://codecov.io/gh/actix/actix-web/branch/master/graph/badge.svg)](https://codecov.io/gh/actix/actix-web) From 73fa1184f18bd36668dfb2fbf30ced578b928833 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Sun, 4 Feb 2024 00:32:57 +0000 Subject: [PATCH 039/151] chore(awc): prepare release 3.4.0 --- actix-test/Cargo.toml | 2 +- awc/CHANGES.md | 2 ++ awc/Cargo.toml | 2 +- awc/README.md | 4 ++-- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/actix-test/Cargo.toml b/actix-test/Cargo.toml index 4e6ea086..49ba22d5 100644 --- a/actix-test/Cargo.toml +++ b/actix-test/Cargo.toml @@ -41,7 +41,7 @@ actix-rt = "2.1" actix-service = "2" actix-utils = "3" actix-web = { version = "4.5", default-features = false, features = ["cookies"] } -awc = { version = "3", default-features = false, features = ["cookies"] } +awc = { version = "3.4", default-features = false, features = ["cookies"] } futures-core = { version = "0.3.17", default-features = false, features = ["std"] } futures-util = { version = "0.3.17", default-features = false, features = [] } diff --git a/awc/CHANGES.md b/awc/CHANGES.md index 3cef0e13..4ed02ada 100644 --- a/awc/CHANGES.md +++ b/awc/CHANGES.md @@ -2,6 +2,8 @@ ## Unreleased +## 3.4.0 + - Add `rustls-0_22-webpki-roots` and `rustls-0_22-native-roots` crate feature. - Add `awc::Connector::rustls_0_22()` method. diff --git a/awc/Cargo.toml b/awc/Cargo.toml index 46603fed..14d93ac3 100644 --- a/awc/Cargo.toml +++ b/awc/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "awc" -version = "3.3.0" +version = "3.4.0" authors = ["Nikolay Kim "] description = "Async HTTP and WebSocket client library" keywords = ["actix", "http", "framework", "async", "web"] diff --git a/awc/README.md b/awc/README.md index 424c86bb..d8665756 100644 --- a/awc/README.md +++ b/awc/README.md @@ -5,9 +5,9 @@ [![crates.io](https://img.shields.io/crates/v/awc?label=latest)](https://crates.io/crates/awc) -[![Documentation](https://docs.rs/awc/badge.svg?version=3.3.0)](https://docs.rs/awc/3.3.0) +[![Documentation](https://docs.rs/awc/badge.svg?version=3.4.0)](https://docs.rs/awc/3.4.0) ![MIT or Apache 2.0 licensed](https://img.shields.io/crates/l/awc) -[![Dependency Status](https://deps.rs/crate/awc/3.3.0/status.svg)](https://deps.rs/crate/awc/3.3.0) +[![Dependency Status](https://deps.rs/crate/awc/3.4.0/status.svg)](https://deps.rs/crate/awc/3.4.0) [![Chat on Discord](https://img.shields.io/discord/771444961383153695?label=chat&logo=discord)](https://discord.gg/NWpN5mmg3x) From 17ed73b33e0fb7d3257da4c98039496044154c35 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Sun, 4 Feb 2024 00:33:38 +0000 Subject: [PATCH 040/151] chore(actix-web-actors): prepare release 4.3.0 --- actix-web-actors/CHANGES.md | 2 ++ actix-web-actors/Cargo.toml | 2 +- actix-web-actors/README.md | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/actix-web-actors/CHANGES.md b/actix-web-actors/CHANGES.md index 5c516db5..85d6b624 100644 --- a/actix-web-actors/CHANGES.md +++ b/actix-web-actors/CHANGES.md @@ -2,6 +2,8 @@ ## Unreleased +## 4.3.0 + - Minimum supported Rust version (MSRV) is now 1.68 due to transitive `time` dependency. ## 4.2.0 diff --git a/actix-web-actors/Cargo.toml b/actix-web-actors/Cargo.toml index c6f14554..0263e9b2 100644 --- a/actix-web-actors/Cargo.toml +++ b/actix-web-actors/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "actix-web-actors" -version = "4.2.0" +version = "4.3.0" authors = ["Nikolay Kim "] description = "Actix actors support for Actix Web" keywords = ["actix", "http", "web", "framework", "async"] diff --git a/actix-web-actors/README.md b/actix-web-actors/README.md index c81fe64c..17b94722 100644 --- a/actix-web-actors/README.md +++ b/actix-web-actors/README.md @@ -5,11 +5,11 @@ [![crates.io](https://img.shields.io/crates/v/actix-web-actors?label=latest)](https://crates.io/crates/actix-web-actors) -[![Documentation](https://docs.rs/actix-web-actors/badge.svg?version=4.2.0)](https://docs.rs/actix-web-actors/4.2.0) +[![Documentation](https://docs.rs/actix-web-actors/badge.svg?version=4.3.0)](https://docs.rs/actix-web-actors/4.3.0) ![Version](https://img.shields.io/badge/rustc-1.68+-ab6000.svg) ![License](https://img.shields.io/crates/l/actix-web-actors.svg)
-[![dependency status](https://deps.rs/crate/actix-web-actors/4.2.0/status.svg)](https://deps.rs/crate/actix-web-actors/4.2.0) +[![dependency status](https://deps.rs/crate/actix-web-actors/4.3.0/status.svg)](https://deps.rs/crate/actix-web-actors/4.3.0) [![Download](https://img.shields.io/crates/d/actix-web-actors.svg)](https://crates.io/crates/actix-web-actors) [![Chat on Discord](https://img.shields.io/discord/771444961383153695?label=chat&logo=discord)](https://discord.gg/NWpN5mmg3x) From 3f2fd2d59f64c172a944ddf82787e7d31e6a1b95 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Sun, 4 Feb 2024 00:33:42 +0000 Subject: [PATCH 041/151] chore(actix-test): prepare release 0.1.3 --- actix-test/CHANGES.md | 2 ++ actix-test/Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/actix-test/CHANGES.md b/actix-test/CHANGES.md index bdacc8b2..8604a126 100644 --- a/actix-test/CHANGES.md +++ b/actix-test/CHANGES.md @@ -2,6 +2,8 @@ ## Unreleased +## 0.1.3 + - Add `TestServerConfig::rustls_0_22()` method for Rustls v0.22 support behind new `rustls-0_22` crate feature. ## 0.1.2 diff --git a/actix-test/Cargo.toml b/actix-test/Cargo.toml index 49ba22d5..7f48fc2c 100644 --- a/actix-test/Cargo.toml +++ b/actix-test/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "actix-test" -version = "0.1.2" +version = "0.1.3" authors = [ "Nikolay Kim ", "Rob Ede ", From 59bc85fe0e5961b9e3499a3272737b780904955d Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Sun, 4 Feb 2024 00:34:00 +0000 Subject: [PATCH 042/151] chore(actix-http-test): prepare release 3.2.0 --- actix-http-test/CHANGES.md | 2 ++ actix-http-test/Cargo.toml | 2 +- actix-http-test/README.md | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/actix-http-test/CHANGES.md b/actix-http-test/CHANGES.md index 065141b2..ec30b9c4 100644 --- a/actix-http-test/CHANGES.md +++ b/actix-http-test/CHANGES.md @@ -2,6 +2,8 @@ ## Unreleased +## 3.2.0 + - Minimum supported Rust version (MSRV) is now 1.68 due to transitive `time` dependency. ## 3.1.0 diff --git a/actix-http-test/Cargo.toml b/actix-http-test/Cargo.toml index 0881e0bc..bfb0a353 100644 --- a/actix-http-test/Cargo.toml +++ b/actix-http-test/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "actix-http-test" -version = "3.1.0" +version = "3.2.0" authors = ["Nikolay Kim "] description = "Various helpers for Actix applications to use during testing" keywords = ["http", "web", "framework", "async", "futures"] diff --git a/actix-http-test/README.md b/actix-http-test/README.md index e544c361..9a87f9ef 100644 --- a/actix-http-test/README.md +++ b/actix-http-test/README.md @@ -5,11 +5,11 @@ [![crates.io](https://img.shields.io/crates/v/actix-http-test?label=latest)](https://crates.io/crates/actix-http-test) -[![Documentation](https://docs.rs/actix-http-test/badge.svg?version=3.1.0)](https://docs.rs/actix-http-test/3.1.0) +[![Documentation](https://docs.rs/actix-http-test/badge.svg?version=3.2.0)](https://docs.rs/actix-http-test/3.2.0) ![Version](https://img.shields.io/badge/rustc-1.68+-ab6000.svg) ![MIT or Apache 2.0 licensed](https://img.shields.io/crates/l/actix-http-test)
-[![Dependency Status](https://deps.rs/crate/actix-http-test/3.1.0/status.svg)](https://deps.rs/crate/actix-http-test/3.1.0) +[![Dependency Status](https://deps.rs/crate/actix-http-test/3.2.0/status.svg)](https://deps.rs/crate/actix-http-test/3.2.0) [![Download](https://img.shields.io/crates/d/actix-http-test.svg)](https://crates.io/crates/actix-http-test) [![Chat on Discord](https://img.shields.io/discord/771444961383153695?label=chat&logo=discord)](https://discord.gg/NWpN5mmg3x) From 2b8c528e543a7d663d2e0bcc89dfaffa0d8a77f7 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Sun, 4 Feb 2024 01:22:36 +0000 Subject: [PATCH 043/151] chore(actix-web): prepare release 4.5.1 --- actix-web/CHANGES.md | 8 ++++++++ actix-web/Cargo.toml | 2 +- actix-web/README.md | 4 ++-- actix-web/src/server.rs | 7 ++++++- 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/actix-web/CHANGES.md b/actix-web/CHANGES.md index 174a70e6..6e2894e4 100644 --- a/actix-web/CHANGES.md +++ b/actix-web/CHANGES.md @@ -2,8 +2,16 @@ ## Unreleased +## 4.5.1 + +### Fixed + +- Fix missing import when using enabling Rustls v0.22 support. + ## 4.5.0 +### Added + - Add `rustls-0_22` crate feature. - Add `HttpServer::{bind_rustls_0_22, listen_rustls_0_22}()` builder methods. diff --git a/actix-web/Cargo.toml b/actix-web/Cargo.toml index 985a103f..8c1cc9bf 100644 --- a/actix-web/Cargo.toml +++ b/actix-web/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "actix-web" -version = "4.5.0" +version = "4.5.1" description = "Actix Web is a powerful, pragmatic, and extremely fast web framework for Rust" authors = [ "Nikolay Kim ", diff --git a/actix-web/README.md b/actix-web/README.md index 492f06fa..b564c879 100644 --- a/actix-web/README.md +++ b/actix-web/README.md @@ -8,10 +8,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=4.5.0)](https://docs.rs/actix-web/4.5.0) +[![Documentation](https://docs.rs/actix-web/badge.svg?version=4.5.1)](https://docs.rs/actix-web/4.5.1) ![MSRV](https://img.shields.io/badge/rustc-1.68+-ab6000.svg) ![MIT or Apache 2.0 licensed](https://img.shields.io/crates/l/actix-web.svg) -[![Dependency Status](https://deps.rs/crate/actix-web/4.5.0/status.svg)](https://deps.rs/crate/actix-web/4.5.0) +[![Dependency Status](https://deps.rs/crate/actix-web/4.5.1/status.svg)](https://deps.rs/crate/actix-web/4.5.1)
[![CI](https://github.com/actix/actix-web/actions/workflows/ci.yml/badge.svg)](https://github.com/actix/actix-web/actions/workflows/ci.yml) [![codecov](https://codecov.io/gh/actix/actix-web/branch/master/graph/badge.svg)](https://codecov.io/gh/actix/actix-web) diff --git a/actix-web/src/server.rs b/actix-web/src/server.rs index 193a7cce..6592079b 100644 --- a/actix-web/src/server.rs +++ b/actix-web/src/server.rs @@ -7,7 +7,12 @@ use std::{ time::Duration, }; -#[cfg(any(feature = "openssl", feature = "rustls-0_20", feature = "rustls-0_21"))] +#[cfg(any( + feature = "openssl", + feature = "rustls-0_20", + feature = "rustls-0_21", + feature = "rustls-0_22", +))] use actix_http::TlsAcceptorConfig; use actix_http::{body::MessageBody, Extensions, HttpService, KeepAlive, Request, Response}; use actix_server::{Server, ServerBuilder}; From d9b31b80ac4c3e58444248b5e5b531fae557af14 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Sun, 4 Feb 2024 03:11:48 +0000 Subject: [PATCH 044/151] fix: standardize body stream error reporting --- actix-http/examples/h2c-detect.rs | 9 +++++++-- actix-http/src/h1/dispatcher.rs | 5 ++++- actix-http/src/h2/dispatcher.rs | 15 ++++++++------- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/actix-http/examples/h2c-detect.rs b/actix-http/examples/h2c-detect.rs index aa3dd5d3..b0bde3fe 100644 --- a/actix-http/examples/h2c-detect.rs +++ b/actix-http/examples/h2c-detect.rs @@ -8,7 +8,7 @@ use std::{convert::Infallible, io}; -use actix_http::{HttpService, Request, Response, StatusCode}; +use actix_http::{body::BodyStream, HttpService, Request, Response, StatusCode}; use actix_server::Server; #[tokio::main(flavor = "current_thread")] @@ -19,7 +19,12 @@ async fn main() -> io::Result<()> { .bind("h2c-detect", ("127.0.0.1", 8080), || { HttpService::build() .finish(|_req: Request| async move { - Ok::<_, Infallible>(Response::build(StatusCode::OK).body("Hello!")) + Ok::<_, Infallible>(Response::build(StatusCode::OK).body(BodyStream::new( + futures_util::stream::iter([ + Ok::<_, String>("123".into()), + Err("wertyuikmnbvcxdfty6t".to_owned()), + ]), + ))) }) .tcp_auto_h2c() })? diff --git a/actix-http/src/h1/dispatcher.rs b/actix-http/src/h1/dispatcher.rs index 27070780..bfbcaf24 100644 --- a/actix-http/src/h1/dispatcher.rs +++ b/actix-http/src/h1/dispatcher.rs @@ -512,8 +512,10 @@ where } Poll::Ready(Some(Err(err))) => { + let err = err.into(); + tracing::error!("Response payload stream error: {err:?}"); this.flags.insert(Flags::FINISHED); - return Err(DispatchError::Body(err.into())); + return Err(DispatchError::Body(err)); } Poll::Pending => return Ok(PollResponse::DoNothing), @@ -549,6 +551,7 @@ where } Poll::Ready(Some(Err(err))) => { + tracing::error!("Response payload stream error: {err:?}"); this.flags.insert(Flags::FINISHED); return Err(DispatchError::Body( Error::new_body().with_cause(err).into(), diff --git a/actix-http/src/h2/dispatcher.rs b/actix-http/src/h2/dispatcher.rs index 3e618820..022239c2 100644 --- a/actix-http/src/h2/dispatcher.rs +++ b/actix-http/src/h2/dispatcher.rs @@ -4,7 +4,7 @@ use std::{ future::Future, marker::PhantomData, net, - pin::Pin, + pin::{pin, Pin}, rc::Rc, task::{Context, Poll}, }; @@ -20,7 +20,6 @@ use h2::{ Ping, PingPong, }; use pin_project_lite::pin_project; -use tracing::{error, trace, warn}; use crate::{ body::{BodySize, BoxBody, MessageBody}, @@ -147,11 +146,13 @@ where if let Err(err) = res { match err { DispatchError::SendResponse(err) => { - trace!("Error sending HTTP/2 response: {:?}", err) + tracing::trace!("Error sending response: {err:?}"); + } + DispatchError::SendData(err) => { + tracing::warn!("Send data error: {err:?}"); } - DispatchError::SendData(err) => warn!("{:?}", err), DispatchError::ResponseBody(err) => { - error!("Response payload stream error: {:?}", err) + tracing::error!("Response payload stream error: {err:?}"); } } } @@ -228,9 +229,9 @@ where return Ok(()); } - // poll response body and send chunks to client - actix_rt::pin!(body); + let mut body = pin!(body); + // poll response body and send chunks to client while let Some(res) = poll_fn(|cx| body.as_mut().poll_next(cx)).await { let mut chunk = res.map_err(|err| DispatchError::ResponseBody(err.into()))?; From f5f6132f948ec8d30251cfc13523db1827f25e2e Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Sun, 4 Feb 2024 03:30:16 +0000 Subject: [PATCH 045/151] test: update rustls for test_server --- actix-web/Cargo.toml | 6 +++--- actix-web/tests/test_server.rs | 19 ++++++++----------- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/actix-web/Cargo.toml b/actix-web/Cargo.toml index 8c1cc9bf..aedcb3ef 100644 --- a/actix-web/Cargo.toml +++ b/actix-web/Cargo.toml @@ -128,12 +128,12 @@ env_logger = "0.10" flate2 = "1.0.13" futures-util = { version = "0.3.17", default-features = false, features = ["std"] } rand = "0.8" -rcgen = "0.11" -rustls-pemfile = "1" +rcgen = "0.12" +rustls-pemfile = "2" serde = { version = "1.0", features = ["derive"] } static_assertions = "1" tls-openssl = { package = "openssl", version = "0.10.55" } -tls-rustls = { package = "rustls", version = "0.21" } +tls-rustls = { package = "rustls", version = "0.22" } tokio = { version = "1.24.2", features = ["rt-multi-thread", "macros"] } zstd = "0.13" diff --git a/actix-web/tests/test_server.rs b/actix-web/tests/test_server.rs index 0df6e212..36f45c14 100644 --- a/actix-web/tests/test_server.rs +++ b/actix-web/tests/test_server.rs @@ -1,6 +1,6 @@ #[cfg(feature = "openssl")] extern crate tls_openssl as openssl; -#[cfg(feature = "rustls-0_21")] +#[cfg(feature = "rustls-0_22")] extern crate tls_rustls as rustls; use std::{ @@ -708,7 +708,7 @@ async fn test_brotli_encoding_large_openssl() { mod plus_rustls { use std::io::BufReader; - use rustls::{Certificate, PrivateKey, ServerConfig as RustlsServerConfig}; + use rustls::{pki_types::PrivateKeyDer, ServerConfig as RustlsServerConfig}; use rustls_pemfile::{certs, pkcs8_private_keys}; use super::*; @@ -721,17 +721,14 @@ mod plus_rustls { let cert_file = &mut BufReader::new(cert_file.as_bytes()); let key_file = &mut BufReader::new(key_file.as_bytes()); - let cert_chain = certs(cert_file) - .unwrap() - .into_iter() - .map(Certificate) - .collect(); - let mut keys = pkcs8_private_keys(key_file).unwrap(); + let cert_chain = certs(cert_file).collect::, _>>().unwrap(); + let mut keys = pkcs8_private_keys(key_file) + .collect::, _>>() + .unwrap(); RustlsServerConfig::builder() - .with_safe_defaults() .with_no_client_auth() - .with_single_cert(cert_chain, PrivateKey(keys.remove(0))) + .with_single_cert(cert_chain, PrivateKeyDer::Pkcs8(keys.remove(0))) .unwrap() } @@ -743,7 +740,7 @@ mod plus_rustls { .map(char::from) .collect::(); - let srv = actix_test::start_with(actix_test::config().rustls_0_21(tls_config()), || { + let srv = actix_test::start_with(actix_test::config().rustls_0_22(tls_config()), || { App::new().service(web::resource("/").route(web::to(|bytes: Bytes| async { // echo decompressed request body back in response HttpResponse::Ok() From e518170a30e6bd32c6a42b1ff20f46126ca1f8a8 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Sun, 4 Feb 2024 03:40:58 +0000 Subject: [PATCH 046/151] test: fix test_server --- actix-web/Cargo.toml | 2 +- actix-web/tests/test_server.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/actix-web/Cargo.toml b/actix-web/Cargo.toml index aedcb3ef..b045589b 100644 --- a/actix-web/Cargo.toml +++ b/actix-web/Cargo.toml @@ -118,7 +118,7 @@ url = "2.1" [dev-dependencies] actix-files = "0.6" -actix-test = { version = "0.1", features = ["openssl", "rustls-0_21"] } +actix-test = { version = "0.1", features = ["openssl", "rustls-0_22"] } awc = { version = "3", features = ["openssl"] } brotli = "3.3.3" diff --git a/actix-web/tests/test_server.rs b/actix-web/tests/test_server.rs index 36f45c14..8fb80216 100644 --- a/actix-web/tests/test_server.rs +++ b/actix-web/tests/test_server.rs @@ -704,7 +704,7 @@ async fn test_brotli_encoding_large_openssl() { srv.stop().await; } -#[cfg(feature = "rustls-0_21")] +#[cfg(feature = "rustls-0_22")] mod plus_rustls { use std::io::BufReader; From 373d4ca970bce4ab68d2c55a82d8e493cc550890 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 5 Feb 2024 01:27:57 +0000 Subject: [PATCH 047/151] build(deps): bump codecov/codecov-action from 4.0.0 to 4.0.1 (#3279) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/coverage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index d871898f..9fef98dc 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -31,7 +31,7 @@ jobs: run: cargo llvm-cov --workspace --all-features --codecov --output-path codecov.json - name: Upload coverage to Codecov - uses: codecov/codecov-action@v4.0.0 + uses: codecov/codecov-action@v4.0.1 with: files: codecov.json fail_ci_if_error: true From 7e4e12b0aa674c96e8abe9c79b8bd1fe4fcb5cb3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 5 Feb 2024 14:38:02 +0000 Subject: [PATCH 048/151] build(deps): bump taiki-e/install-action from 2.26.8 to 2.26.12 (#3280) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/ci-post-merge.yml | 6 +++--- .github/workflows/ci.yml | 2 +- .github/workflows/coverage.yml | 2 +- .github/workflows/lint.yml | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci-post-merge.yml b/.github/workflows/ci-post-merge.yml index de9b30a5..1a0437cb 100644 --- a/.github/workflows/ci-post-merge.yml +++ b/.github/workflows/ci-post-merge.yml @@ -45,7 +45,7 @@ jobs: toolchain: ${{ matrix.version.version }} - name: Install cargo-hack and cargo-ci-cache-clean - uses: taiki-e/install-action@v2.26.8 + uses: taiki-e/install-action@v2.26.12 with: tool: cargo-hack,cargo-ci-cache-clean @@ -85,7 +85,7 @@ jobs: uses: actions-rust-lang/setup-rust-toolchain@v1.8.0 - name: Install cargo-hack - uses: taiki-e/install-action@v2.26.8 + uses: taiki-e/install-action@v2.26.12 with: tool: cargo-hack @@ -106,7 +106,7 @@ jobs: uses: actions-rust-lang/setup-rust-toolchain@v1.8.0 - name: Install nextest - uses: taiki-e/install-action@v2.26.8 + uses: taiki-e/install-action@v2.26.12 with: tool: nextest diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 79c581b8..9af6d75f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -50,7 +50,7 @@ jobs: toolchain: ${{ matrix.version.version }} - name: Install cargo-hack and cargo-ci-cache-clean - uses: taiki-e/install-action@v2.26.8 + uses: taiki-e/install-action@v2.26.12 with: tool: cargo-hack,cargo-ci-cache-clean diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 9fef98dc..180a9a0e 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -23,7 +23,7 @@ jobs: components: llvm-tools-preview - name: Install cargo-llvm-cov - uses: taiki-e/install-action@v2.26.8 + uses: taiki-e/install-action@v2.26.12 with: tool: cargo-llvm-cov diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 502bfeb6..bb03acce 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -82,7 +82,7 @@ jobs: toolchain: nightly-2023-08-25 - name: Install cargo-public-api - uses: taiki-e/install-action@v2.26.8 + uses: taiki-e/install-action@v2.26.12 with: tool: cargo-public-api From 1e2ef6f92fe8e6a2eca69233644dc3ff1e375150 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Wed, 7 Feb 2024 03:47:30 +0000 Subject: [PATCH 049/151] perf: remove unnecessary allocation when writing http dates (#3261) --- .github/workflows/ci.yml | 14 +++++--------- Cargo.toml | 2 +- actix-files/CHANGES.md | 2 ++ actix-files/README.md | 2 +- actix-http-test/CHANGES.md | 2 ++ actix-http-test/README.md | 7 +------ actix-http/CHANGES.md | 4 ++++ actix-http/Cargo.toml | 5 +++++ actix-http/README.md | 7 +------ actix-http/benches/date-formatting.rs | 20 ++++++++++++++++++++ actix-http/src/date.rs | 2 +- actix-http/src/header/shared/http_date.rs | 5 ++--- actix-multipart-derive/CHANGES.md | 2 ++ actix-multipart-derive/README.md | 7 +------ actix-multipart-derive/tests/trybuild.rs | 2 +- actix-multipart/CHANGES.md | 2 ++ actix-multipart/README.md | 7 +------ actix-router/CHANGES.md | 2 ++ actix-router/README.md | 2 +- actix-test/CHANGES.md | 2 ++ actix-web-actors/CHANGES.md | 2 ++ actix-web-actors/README.md | 7 +------ actix-web-codegen/CHANGES.md | 2 ++ actix-web-codegen/README.md | 7 +------ actix-web-codegen/tests/trybuild.rs | 2 +- actix-web/CHANGES.md | 4 ++++ actix-web/README.md | 4 ++-- awc/CHANGES.md | 2 ++ awc/README.md | 8 +++----- 29 files changed, 75 insertions(+), 61 deletions(-) create mode 100644 actix-http/benches/date-formatting.rs diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9af6d75f..ee12ebab 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,7 +26,7 @@ jobs: - { name: macOS, os: macos-latest, triple: x86_64-apple-darwin } - { name: Windows, os: windows-latest, triple: x86_64-pc-windows-msvc } version: - - { name: msrv, version: 1.68.0 } + - { name: msrv, version: 1.70.0 } - { name: stable, version: stable } name: ${{ matrix.target.name }} / ${{ matrix.version.name }} @@ -54,14 +54,10 @@ jobs: with: tool: cargo-hack,cargo-ci-cache-clean - - name: workaround MSRV issues - if: matrix.version.name == 'msrv' - run: | - cargo update -p=ciborium --precise=0.2.1 - cargo update -p=ciborium-ll --precise=0.2.1 - cargo update -p=clap --precise=4.3.24 - cargo update -p=clap_lex --precise=0.5.0 - cargo update -p=anstyle --precise=1.0.2 + # - name: workaround MSRV issues + # if: matrix.version.name == 'msrv' + # run: | + # cargo update -p=anstyle --precise=1.0.2 - name: check minimal run: cargo ci-check-min diff --git a/Cargo.toml b/Cargo.toml index 58fd9693..f90cdbea 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,7 +17,7 @@ members = [ [workspace.package] license = "MIT OR Apache-2.0" edition = "2021" -rust-version = "1.68" +rust-version = "1.70" [profile.dev] # Disabling debug info speeds up builds a bunch and we don't rely on it for debugging that much. diff --git a/actix-files/CHANGES.md b/actix-files/CHANGES.md index 9aa62ff7..0099dcf3 100644 --- a/actix-files/CHANGES.md +++ b/actix-files/CHANGES.md @@ -2,6 +2,8 @@ ## Unreleased +- Minimum supported Rust version (MSRV) is now 1.70. + ## 0.6.5 - Fix handling of special characters in filenames. diff --git a/actix-files/README.md b/actix-files/README.md index df80e404..1f05be18 100644 --- a/actix-files/README.md +++ b/actix-files/README.md @@ -4,7 +4,7 @@ [![crates.io](https://img.shields.io/crates/v/actix-files?label=latest)](https://crates.io/crates/actix-files) [![Documentation](https://docs.rs/actix-files/badge.svg?version=0.6.5)](https://docs.rs/actix-files/0.6.5) -![Version](https://img.shields.io/badge/rustc-1.68+-ab6000.svg) +![Version](https://img.shields.io/badge/rustc-1.70+-ab6000.svg) ![License](https://img.shields.io/crates/l/actix-files.svg)
[![dependency status](https://deps.rs/crate/actix-files/0.6.5/status.svg)](https://deps.rs/crate/actix-files/0.6.5) diff --git a/actix-http-test/CHANGES.md b/actix-http-test/CHANGES.md index ec30b9c4..b9b2d9d1 100644 --- a/actix-http-test/CHANGES.md +++ b/actix-http-test/CHANGES.md @@ -2,6 +2,8 @@ ## Unreleased +- Minimum supported Rust version (MSRV) is now 1.70. + ## 3.2.0 - Minimum supported Rust version (MSRV) is now 1.68 due to transitive `time` dependency. diff --git a/actix-http-test/README.md b/actix-http-test/README.md index 9a87f9ef..6639874d 100644 --- a/actix-http-test/README.md +++ b/actix-http-test/README.md @@ -6,7 +6,7 @@ [![crates.io](https://img.shields.io/crates/v/actix-http-test?label=latest)](https://crates.io/crates/actix-http-test) [![Documentation](https://docs.rs/actix-http-test/badge.svg?version=3.2.0)](https://docs.rs/actix-http-test/3.2.0) -![Version](https://img.shields.io/badge/rustc-1.68+-ab6000.svg) +![Version](https://img.shields.io/badge/rustc-1.70+-ab6000.svg) ![MIT or Apache 2.0 licensed](https://img.shields.io/crates/l/actix-http-test)
[![Dependency Status](https://deps.rs/crate/actix-http-test/3.2.0/status.svg)](https://deps.rs/crate/actix-http-test/3.2.0) @@ -14,8 +14,3 @@ [![Chat on Discord](https://img.shields.io/discord/771444961383153695?label=chat&logo=discord)](https://discord.gg/NWpN5mmg3x) - -## Documentation & Resources - -- [API Documentation](https://docs.rs/actix-http-test) -- Minimum Supported Rust Version (MSRV): 1.68 diff --git a/actix-http/CHANGES.md b/actix-http/CHANGES.md index e3805ff7..a50bb906 100644 --- a/actix-http/CHANGES.md +++ b/actix-http/CHANGES.md @@ -2,6 +2,10 @@ ## Unreleased +### Changed + +- Minimum supported Rust version (MSRV) is now 1.70. + ## 3.6.0 ### Added diff --git a/actix-http/Cargo.toml b/actix-http/Cargo.toml index 14b9bdac..e8f315cb 100644 --- a/actix-http/Cargo.toml +++ b/actix-http/Cargo.toml @@ -126,6 +126,7 @@ actix-web = "4" async-stream = "0.3" criterion = { version = "0.5", features = ["html_reports"] } +divan = "0.1.8" env_logger = "0.10" futures-util = { version = "0.3.17", default-features = false, features = ["alloc"] } memchr = "2.4" @@ -153,3 +154,7 @@ required-features = ["http2", "rustls-0_22"] name = "response-body-compression" harness = false required-features = ["compress-brotli", "compress-gzip", "compress-zstd"] + +[[bench]] +name = "date-formatting" +harness = false diff --git a/actix-http/README.md b/actix-http/README.md index c9bd1b34..4f10ba24 100644 --- a/actix-http/README.md +++ b/actix-http/README.md @@ -6,7 +6,7 @@ [![crates.io](https://img.shields.io/crates/v/actix-http?label=latest)](https://crates.io/crates/actix-http) [![Documentation](https://docs.rs/actix-http/badge.svg?version=3.6.0)](https://docs.rs/actix-http/3.6.0) -![Version](https://img.shields.io/badge/rustc-1.68+-ab6000.svg) +![Version](https://img.shields.io/badge/rustc-1.70+-ab6000.svg) ![MIT or Apache 2.0 licensed](https://img.shields.io/crates/l/actix-http.svg)
[![dependency status](https://deps.rs/crate/actix-http/3.6.0/status.svg)](https://deps.rs/crate/actix-http/3.6.0) @@ -15,11 +15,6 @@ -## Documentation & Resources - -- [API Documentation](https://docs.rs/actix-http) -- Minimum Supported Rust Version (MSRV): 1.68 - ## Examples ```rust diff --git a/actix-http/benches/date-formatting.rs b/actix-http/benches/date-formatting.rs new file mode 100644 index 00000000..26d0f3da --- /dev/null +++ b/actix-http/benches/date-formatting.rs @@ -0,0 +1,20 @@ +use std::time::SystemTime; + +use actix_http::header::HttpDate; +use divan::{black_box, AllocProfiler, Bencher}; + +#[global_allocator] +static ALLOC: AllocProfiler = AllocProfiler::system(); + +#[divan::bench] +fn date_formatting(b: Bencher<'_, '_>) { + let now = SystemTime::now(); + + b.bench(|| { + black_box(HttpDate::from(black_box(now)).to_string()); + }) +} + +fn main() { + divan::main(); +} diff --git a/actix-http/src/date.rs b/actix-http/src/date.rs index 1358bbd8..735dd910 100644 --- a/actix-http/src/date.rs +++ b/actix-http/src/date.rs @@ -28,7 +28,7 @@ impl Date { fn update(&mut self) { self.pos = 0; - write!(self, "{}", httpdate::fmt_http_date(SystemTime::now())).unwrap(); + write!(self, "{}", httpdate::HttpDate::from(SystemTime::now())).unwrap(); } } diff --git a/actix-http/src/header/shared/http_date.rs b/actix-http/src/header/shared/http_date.rs index 21ed49f0..bdfbc705 100644 --- a/actix-http/src/header/shared/http_date.rs +++ b/actix-http/src/header/shared/http_date.rs @@ -24,8 +24,7 @@ impl FromStr for HttpDate { impl fmt::Display for HttpDate { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let date_str = httpdate::fmt_http_date(self.0); - f.write_str(&date_str) + httpdate::HttpDate::from(self.0).fmt(f) } } @@ -37,7 +36,7 @@ impl TryIntoHeaderValue for HttpDate { let mut wrt = MutWriter(&mut buf); // unwrap: date output is known to be well formed and of known length - write!(wrt, "{}", httpdate::fmt_http_date(self.0)).unwrap(); + write!(wrt, "{}", self).unwrap(); HeaderValue::from_maybe_shared(buf.split().freeze()) } diff --git a/actix-multipart-derive/CHANGES.md b/actix-multipart-derive/CHANGES.md index e36a13d0..23dd4f2d 100644 --- a/actix-multipart-derive/CHANGES.md +++ b/actix-multipart-derive/CHANGES.md @@ -2,6 +2,8 @@ ## Unreleased +- Minimum supported Rust version (MSRV) is now 1.70. + ## 0.6.1 - Update `syn` dependency to `2`. diff --git a/actix-multipart-derive/README.md b/actix-multipart-derive/README.md index 2beadefe..6845e9df 100644 --- a/actix-multipart-derive/README.md +++ b/actix-multipart-derive/README.md @@ -6,7 +6,7 @@ [![crates.io](https://img.shields.io/crates/v/actix-multipart-derive?label=latest)](https://crates.io/crates/actix-multipart-derive) [![Documentation](https://docs.rs/actix-multipart-derive/badge.svg?version=0.6.1)](https://docs.rs/actix-multipart-derive/0.6.1) -![Version](https://img.shields.io/badge/rustc-1.68+-ab6000.svg) +![Version](https://img.shields.io/badge/rustc-1.70+-ab6000.svg) ![MIT or Apache 2.0 licensed](https://img.shields.io/crates/l/actix-multipart-derive.svg)
[![dependency status](https://deps.rs/crate/actix-multipart-derive/0.6.1/status.svg)](https://deps.rs/crate/actix-multipart-derive/0.6.1) @@ -14,8 +14,3 @@ [![Chat on Discord](https://img.shields.io/discord/771444961383153695?label=chat&logo=discord)](https://discord.gg/NWpN5mmg3x) - -## Documentation & Resources - -- [API Documentation](https://docs.rs/actix-multipart-derive) -- Minimum Supported Rust Version (MSRV): 1.68 diff --git a/actix-multipart-derive/tests/trybuild.rs b/actix-multipart-derive/tests/trybuild.rs index 88aa619c..b196868a 100644 --- a/actix-multipart-derive/tests/trybuild.rs +++ b/actix-multipart-derive/tests/trybuild.rs @@ -1,4 +1,4 @@ -#[rustversion::stable(1.68)] // MSRV +#[rustversion::stable(1.70)] // MSRV #[test] fn compile_macros() { let t = trybuild::TestCases::new(); diff --git a/actix-multipart/CHANGES.md b/actix-multipart/CHANGES.md index 50faf7cf..214f899e 100644 --- a/actix-multipart/CHANGES.md +++ b/actix-multipart/CHANGES.md @@ -2,6 +2,8 @@ ## Unreleased +- Minimum supported Rust version (MSRV) is now 1.70. + ## 0.6.1 - Minimum supported Rust version (MSRV) is now 1.68 due to transitive `time` dependency. diff --git a/actix-multipart/README.md b/actix-multipart/README.md index 16068510..15a70175 100644 --- a/actix-multipart/README.md +++ b/actix-multipart/README.md @@ -6,7 +6,7 @@ [![crates.io](https://img.shields.io/crates/v/actix-multipart?label=latest)](https://crates.io/crates/actix-multipart) [![Documentation](https://docs.rs/actix-multipart/badge.svg?version=0.6.1)](https://docs.rs/actix-multipart/0.6.1) -![Version](https://img.shields.io/badge/rustc-1.68+-ab6000.svg) +![Version](https://img.shields.io/badge/rustc-1.70+-ab6000.svg) ![MIT or Apache 2.0 licensed](https://img.shields.io/crates/l/actix-multipart.svg)
[![dependency status](https://deps.rs/crate/actix-multipart/0.6.1/status.svg)](https://deps.rs/crate/actix-multipart/0.6.1) @@ -14,8 +14,3 @@ [![Chat on Discord](https://img.shields.io/discord/771444961383153695?label=chat&logo=discord)](https://discord.gg/NWpN5mmg3x) - -## Documentation & Resources - -- [API Documentation](https://docs.rs/actix-multipart) -- Minimum Supported Rust Version (MSRV): 1.68 diff --git a/actix-router/CHANGES.md b/actix-router/CHANGES.md index a855c007..4d77988d 100644 --- a/actix-router/CHANGES.md +++ b/actix-router/CHANGES.md @@ -2,6 +2,8 @@ ## Unreleased +- Minimum supported Rust version (MSRV) is now 1.70. + ## 0.5.2 - Minimum supported Rust version (MSRV) is now 1.68 due to transitive `time` dependency. diff --git a/actix-router/README.md b/actix-router/README.md index 7760b033..506b6501 100644 --- a/actix-router/README.md +++ b/actix-router/README.md @@ -4,7 +4,7 @@ [![crates.io](https://img.shields.io/crates/v/actix-router?label=latest)](https://crates.io/crates/actix-router) [![Documentation](https://docs.rs/actix-router/badge.svg?version=0.5.2)](https://docs.rs/actix-router/0.5.2) -![Version](https://img.shields.io/badge/rustc-1.68+-ab6000.svg) +![Version](https://img.shields.io/badge/rustc-1.70+-ab6000.svg) ![MIT or Apache 2.0 licensed](https://img.shields.io/crates/l/actix-router.svg)
[![dependency status](https://deps.rs/crate/actix-router/0.5.2/status.svg)](https://deps.rs/crate/actix-router/0.5.2) diff --git a/actix-test/CHANGES.md b/actix-test/CHANGES.md index 8604a126..99bb21ed 100644 --- a/actix-test/CHANGES.md +++ b/actix-test/CHANGES.md @@ -2,6 +2,8 @@ ## Unreleased +- Minimum supported Rust version (MSRV) is now 1.70. + ## 0.1.3 - Add `TestServerConfig::rustls_0_22()` method for Rustls v0.22 support behind new `rustls-0_22` crate feature. diff --git a/actix-web-actors/CHANGES.md b/actix-web-actors/CHANGES.md index 85d6b624..c146841f 100644 --- a/actix-web-actors/CHANGES.md +++ b/actix-web-actors/CHANGES.md @@ -2,6 +2,8 @@ ## Unreleased +- Minimum supported Rust version (MSRV) is now 1.70. + ## 4.3.0 - Minimum supported Rust version (MSRV) is now 1.68 due to transitive `time` dependency. diff --git a/actix-web-actors/README.md b/actix-web-actors/README.md index 17b94722..202d7d4c 100644 --- a/actix-web-actors/README.md +++ b/actix-web-actors/README.md @@ -6,7 +6,7 @@ [![crates.io](https://img.shields.io/crates/v/actix-web-actors?label=latest)](https://crates.io/crates/actix-web-actors) [![Documentation](https://docs.rs/actix-web-actors/badge.svg?version=4.3.0)](https://docs.rs/actix-web-actors/4.3.0) -![Version](https://img.shields.io/badge/rustc-1.68+-ab6000.svg) +![Version](https://img.shields.io/badge/rustc-1.70+-ab6000.svg) ![License](https://img.shields.io/crates/l/actix-web-actors.svg)
[![dependency status](https://deps.rs/crate/actix-web-actors/4.3.0/status.svg)](https://deps.rs/crate/actix-web-actors/4.3.0) @@ -14,8 +14,3 @@ [![Chat on Discord](https://img.shields.io/discord/771444961383153695?label=chat&logo=discord)](https://discord.gg/NWpN5mmg3x) - -## Documentation & Resources - -- [API Documentation](https://docs.rs/actix-web-actors) -- Minimum Supported Rust Version (MSRV): 1.68 diff --git a/actix-web-codegen/CHANGES.md b/actix-web-codegen/CHANGES.md index 00e36b03..ecab6e09 100644 --- a/actix-web-codegen/CHANGES.md +++ b/actix-web-codegen/CHANGES.md @@ -2,6 +2,8 @@ ## Unreleased +- Minimum supported Rust version (MSRV) is now 1.70. + ## 4.2.2 - Fix regression when declaring `wrap` attribute using an expression. diff --git a/actix-web-codegen/README.md b/actix-web-codegen/README.md index 088f3575..bd79f9af 100644 --- a/actix-web-codegen/README.md +++ b/actix-web-codegen/README.md @@ -6,7 +6,7 @@ [![crates.io](https://img.shields.io/crates/v/actix-web-codegen?label=latest)](https://crates.io/crates/actix-web-codegen) [![Documentation](https://docs.rs/actix-web-codegen/badge.svg?version=4.2.2)](https://docs.rs/actix-web-codegen/4.2.2) -![Version](https://img.shields.io/badge/rustc-1.68+-ab6000.svg) +![Version](https://img.shields.io/badge/rustc-1.70+-ab6000.svg) ![License](https://img.shields.io/crates/l/actix-web-codegen.svg)
[![dependency status](https://deps.rs/crate/actix-web-codegen/4.2.2/status.svg)](https://deps.rs/crate/actix-web-codegen/4.2.2) @@ -15,11 +15,6 @@ -## Documentation & Resources - -- [API Documentation](https://docs.rs/actix-web-codegen) -- Minimum Supported Rust Version (MSRV): 1.68 - ## Compile Testing Uses the [`trybuild`] crate. All compile fail tests should include a stderr file generated by `trybuild`. See the [workflow section](https://github.com/dtolnay/trybuild#workflow) of the trybuild docs for info on how to do this. diff --git a/actix-web-codegen/tests/trybuild.rs b/actix-web-codegen/tests/trybuild.rs index 8e1f58a4..13b0359f 100644 --- a/actix-web-codegen/tests/trybuild.rs +++ b/actix-web-codegen/tests/trybuild.rs @@ -1,4 +1,4 @@ -#[rustversion::stable(1.68)] // MSRV +#[rustversion::stable(1.70)] // MSRV #[test] fn compile_macros() { let t = trybuild::TestCases::new(); diff --git a/actix-web/CHANGES.md b/actix-web/CHANGES.md index 6e2894e4..d296e334 100644 --- a/actix-web/CHANGES.md +++ b/actix-web/CHANGES.md @@ -2,6 +2,10 @@ ## Unreleased +### Changed + +- Minimum supported Rust version (MSRV) is now 1.70. + ## 4.5.1 ### Fixed diff --git a/actix-web/README.md b/actix-web/README.md index b564c879..613f7e04 100644 --- a/actix-web/README.md +++ b/actix-web/README.md @@ -9,7 +9,7 @@ [![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=4.5.1)](https://docs.rs/actix-web/4.5.1) -![MSRV](https://img.shields.io/badge/rustc-1.68+-ab6000.svg) +![MSRV](https://img.shields.io/badge/rustc-1.70+-ab6000.svg) ![MIT or Apache 2.0 licensed](https://img.shields.io/crates/l/actix-web.svg) [![Dependency Status](https://deps.rs/crate/actix-web/4.5.1/status.svg)](https://deps.rs/crate/actix-web/4.5.1)
@@ -37,7 +37,7 @@ - SSL support using OpenSSL or Rustls - Middlewares ([Logger, Session, CORS, etc](https://actix.rs/docs/middleware/)) - Integrates with the [`awc` HTTP client](https://docs.rs/awc/) -- Runs on stable Rust 1.68+ +- Runs on stable Rust 1.70+ ## Documentation diff --git a/awc/CHANGES.md b/awc/CHANGES.md index 4ed02ada..769f896a 100644 --- a/awc/CHANGES.md +++ b/awc/CHANGES.md @@ -2,6 +2,8 @@ ## Unreleased +- Minimum supported Rust version (MSRV) is now 1.70. + ## 3.4.0 - Add `rustls-0_22-webpki-roots` and `rustls-0_22-native-roots` crate feature. diff --git a/awc/README.md b/awc/README.md index d8665756..19236b85 100644 --- a/awc/README.md +++ b/awc/README.md @@ -12,13 +12,11 @@ -## Documentation & Resources +## Examples -- [API Documentation](https://docs.rs/awc) -- [Example Project](https://github.com/actix/examples/tree/master/https-tls/awc-https) -- Minimum Supported Rust Version (MSRV): 1.68 +[Example project using TLS-enabled client →](https://github.com/actix/examples/tree/master/https-tls/awc-https) -## Example +Basic usage: ```rust use actix_rt::System; From 022b052bd97823c56be5cc5f38340ecb9d3cf591 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Mon, 12 Feb 2024 23:02:45 +0000 Subject: [PATCH 050/151] chore: clippy --- actix-http/src/h1/dispatcher.rs | 2 +- actix-http/src/h2/dispatcher.rs | 2 +- actix-http/src/header/utils.rs | 6 +++--- actix-http/src/notify_on_drop.rs | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/actix-http/src/h1/dispatcher.rs b/actix-http/src/h1/dispatcher.rs index bfbcaf24..a24a6bb0 100644 --- a/actix-http/src/h1/dispatcher.rs +++ b/actix-http/src/h1/dispatcher.rs @@ -706,7 +706,7 @@ where req.head_mut().peer_addr = *this.peer_addr; - req.conn_data = this.conn_data.as_ref().map(Rc::clone); + req.conn_data = this.conn_data.clone(); match this.codec.message_type() { // request has no payload diff --git a/actix-http/src/h2/dispatcher.rs b/actix-http/src/h2/dispatcher.rs index 022239c2..97ceb51e 100644 --- a/actix-http/src/h2/dispatcher.rs +++ b/actix-http/src/h2/dispatcher.rs @@ -126,7 +126,7 @@ where head.headers = parts.headers.into(); head.peer_addr = this.peer_addr; - req.conn_data = this.conn_data.as_ref().map(Rc::clone); + req.conn_data = this.conn_data.clone(); let fut = this.flow.service.call(req); let config = this.config.clone(); diff --git a/actix-http/src/header/utils.rs b/actix-http/src/header/utils.rs index f4f34d34..caaab3b1 100644 --- a/actix-http/src/header/utils.rs +++ b/actix-http/src/header/utils.rs @@ -80,18 +80,18 @@ mod tests { #[test] fn comma_delimited_parsing() { - let headers = vec![]; + let headers = []; let res: Vec = from_comma_delimited(headers.iter()).unwrap(); assert_eq!(res, vec![0; 0]); - let headers = vec![ + let headers = [ HeaderValue::from_static("1, 2"), HeaderValue::from_static("3,4"), ]; let res: Vec = from_comma_delimited(headers.iter()).unwrap(); assert_eq!(res, vec![1, 2, 3, 4]); - let headers = vec![ + let headers = [ HeaderValue::from_static(""), HeaderValue::from_static(","), HeaderValue::from_static(" "), diff --git a/actix-http/src/notify_on_drop.rs b/actix-http/src/notify_on_drop.rs index 98544bb5..95904b28 100644 --- a/actix-http/src/notify_on_drop.rs +++ b/actix-http/src/notify_on_drop.rs @@ -5,7 +5,7 @@ use std::cell::RefCell; thread_local! { - static NOTIFY_DROPPED: RefCell> = RefCell::new(None); + static NOTIFY_DROPPED: RefCell> = const { RefCell::new(None) }; } /// Check if the spawned task is dropped. From 1e08ebabf9410ad125947d1bf9a8e8d1fde5ef40 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Tue, 13 Feb 2024 01:24:34 +0000 Subject: [PATCH 051/151] build: bump MSRV to 1.72 --- .github/workflows/ci.yml | 2 +- Cargo.toml | 2 +- actix-files/CHANGES.md | 2 +- actix-files/README.md | 2 +- actix-http-test/CHANGES.md | 2 +- actix-http-test/README.md | 2 +- actix-http/CHANGES.md | 2 +- actix-http/README.md | 2 +- actix-multipart-derive/CHANGES.md | 2 +- actix-multipart-derive/README.md | 2 +- actix-multipart-derive/tests/trybuild.rs | 2 +- actix-multipart/CHANGES.md | 2 +- actix-multipart/README.md | 2 +- actix-router/CHANGES.md | 2 +- actix-router/README.md | 2 +- actix-test/CHANGES.md | 2 +- actix-web-actors/CHANGES.md | 2 +- actix-web-actors/README.md | 2 +- actix-web-codegen/CHANGES.md | 2 +- actix-web-codegen/README.md | 2 +- actix-web-codegen/tests/trybuild.rs | 2 +- actix-web/CHANGES.md | 2 +- actix-web/README.md | 4 ++-- awc/CHANGES.md | 2 +- 24 files changed, 25 insertions(+), 25 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ee12ebab..a328c74d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,7 +26,7 @@ jobs: - { name: macOS, os: macos-latest, triple: x86_64-apple-darwin } - { name: Windows, os: windows-latest, triple: x86_64-pc-windows-msvc } version: - - { name: msrv, version: 1.70.0 } + - { name: msrv, version: 1.72.0 } - { name: stable, version: stable } name: ${{ matrix.target.name }} / ${{ matrix.version.name }} diff --git a/Cargo.toml b/Cargo.toml index f90cdbea..9efeda4d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,7 +17,7 @@ members = [ [workspace.package] license = "MIT OR Apache-2.0" edition = "2021" -rust-version = "1.70" +rust-version = "1.72" [profile.dev] # Disabling debug info speeds up builds a bunch and we don't rely on it for debugging that much. diff --git a/actix-files/CHANGES.md b/actix-files/CHANGES.md index 0099dcf3..393e7b61 100644 --- a/actix-files/CHANGES.md +++ b/actix-files/CHANGES.md @@ -2,7 +2,7 @@ ## Unreleased -- Minimum supported Rust version (MSRV) is now 1.70. +- Minimum supported Rust version (MSRV) is now 1.72. ## 0.6.5 diff --git a/actix-files/README.md b/actix-files/README.md index 1f05be18..a6b3f63c 100644 --- a/actix-files/README.md +++ b/actix-files/README.md @@ -4,7 +4,7 @@ [![crates.io](https://img.shields.io/crates/v/actix-files?label=latest)](https://crates.io/crates/actix-files) [![Documentation](https://docs.rs/actix-files/badge.svg?version=0.6.5)](https://docs.rs/actix-files/0.6.5) -![Version](https://img.shields.io/badge/rustc-1.70+-ab6000.svg) +![Version](https://img.shields.io/badge/rustc-1.72+-ab6000.svg) ![License](https://img.shields.io/crates/l/actix-files.svg)
[![dependency status](https://deps.rs/crate/actix-files/0.6.5/status.svg)](https://deps.rs/crate/actix-files/0.6.5) diff --git a/actix-http-test/CHANGES.md b/actix-http-test/CHANGES.md index b9b2d9d1..4d133e3e 100644 --- a/actix-http-test/CHANGES.md +++ b/actix-http-test/CHANGES.md @@ -2,7 +2,7 @@ ## Unreleased -- Minimum supported Rust version (MSRV) is now 1.70. +- Minimum supported Rust version (MSRV) is now 1.72. ## 3.2.0 diff --git a/actix-http-test/README.md b/actix-http-test/README.md index 6639874d..ee242d1d 100644 --- a/actix-http-test/README.md +++ b/actix-http-test/README.md @@ -6,7 +6,7 @@ [![crates.io](https://img.shields.io/crates/v/actix-http-test?label=latest)](https://crates.io/crates/actix-http-test) [![Documentation](https://docs.rs/actix-http-test/badge.svg?version=3.2.0)](https://docs.rs/actix-http-test/3.2.0) -![Version](https://img.shields.io/badge/rustc-1.70+-ab6000.svg) +![Version](https://img.shields.io/badge/rustc-1.72+-ab6000.svg) ![MIT or Apache 2.0 licensed](https://img.shields.io/crates/l/actix-http-test)
[![Dependency Status](https://deps.rs/crate/actix-http-test/3.2.0/status.svg)](https://deps.rs/crate/actix-http-test/3.2.0) diff --git a/actix-http/CHANGES.md b/actix-http/CHANGES.md index a50bb906..fddd1c2c 100644 --- a/actix-http/CHANGES.md +++ b/actix-http/CHANGES.md @@ -4,7 +4,7 @@ ### Changed -- Minimum supported Rust version (MSRV) is now 1.70. +- Minimum supported Rust version (MSRV) is now 1.72. ## 3.6.0 diff --git a/actix-http/README.md b/actix-http/README.md index 4f10ba24..3881b805 100644 --- a/actix-http/README.md +++ b/actix-http/README.md @@ -6,7 +6,7 @@ [![crates.io](https://img.shields.io/crates/v/actix-http?label=latest)](https://crates.io/crates/actix-http) [![Documentation](https://docs.rs/actix-http/badge.svg?version=3.6.0)](https://docs.rs/actix-http/3.6.0) -![Version](https://img.shields.io/badge/rustc-1.70+-ab6000.svg) +![Version](https://img.shields.io/badge/rustc-1.72+-ab6000.svg) ![MIT or Apache 2.0 licensed](https://img.shields.io/crates/l/actix-http.svg)
[![dependency status](https://deps.rs/crate/actix-http/3.6.0/status.svg)](https://deps.rs/crate/actix-http/3.6.0) diff --git a/actix-multipart-derive/CHANGES.md b/actix-multipart-derive/CHANGES.md index 23dd4f2d..1b44ba4b 100644 --- a/actix-multipart-derive/CHANGES.md +++ b/actix-multipart-derive/CHANGES.md @@ -2,7 +2,7 @@ ## Unreleased -- Minimum supported Rust version (MSRV) is now 1.70. +- Minimum supported Rust version (MSRV) is now 1.72. ## 0.6.1 diff --git a/actix-multipart-derive/README.md b/actix-multipart-derive/README.md index 6845e9df..ec0afffd 100644 --- a/actix-multipart-derive/README.md +++ b/actix-multipart-derive/README.md @@ -6,7 +6,7 @@ [![crates.io](https://img.shields.io/crates/v/actix-multipart-derive?label=latest)](https://crates.io/crates/actix-multipart-derive) [![Documentation](https://docs.rs/actix-multipart-derive/badge.svg?version=0.6.1)](https://docs.rs/actix-multipart-derive/0.6.1) -![Version](https://img.shields.io/badge/rustc-1.70+-ab6000.svg) +![Version](https://img.shields.io/badge/rustc-1.72+-ab6000.svg) ![MIT or Apache 2.0 licensed](https://img.shields.io/crates/l/actix-multipart-derive.svg)
[![dependency status](https://deps.rs/crate/actix-multipart-derive/0.6.1/status.svg)](https://deps.rs/crate/actix-multipart-derive/0.6.1) diff --git a/actix-multipart-derive/tests/trybuild.rs b/actix-multipart-derive/tests/trybuild.rs index b196868a..6b25d78d 100644 --- a/actix-multipart-derive/tests/trybuild.rs +++ b/actix-multipart-derive/tests/trybuild.rs @@ -1,4 +1,4 @@ -#[rustversion::stable(1.70)] // MSRV +#[rustversion::stable(1.72)] // MSRV #[test] fn compile_macros() { let t = trybuild::TestCases::new(); diff --git a/actix-multipart/CHANGES.md b/actix-multipart/CHANGES.md index 214f899e..adf37044 100644 --- a/actix-multipart/CHANGES.md +++ b/actix-multipart/CHANGES.md @@ -2,7 +2,7 @@ ## Unreleased -- Minimum supported Rust version (MSRV) is now 1.70. +- Minimum supported Rust version (MSRV) is now 1.72. ## 0.6.1 diff --git a/actix-multipart/README.md b/actix-multipart/README.md index 15a70175..56723bd6 100644 --- a/actix-multipart/README.md +++ b/actix-multipart/README.md @@ -6,7 +6,7 @@ [![crates.io](https://img.shields.io/crates/v/actix-multipart?label=latest)](https://crates.io/crates/actix-multipart) [![Documentation](https://docs.rs/actix-multipart/badge.svg?version=0.6.1)](https://docs.rs/actix-multipart/0.6.1) -![Version](https://img.shields.io/badge/rustc-1.70+-ab6000.svg) +![Version](https://img.shields.io/badge/rustc-1.72+-ab6000.svg) ![MIT or Apache 2.0 licensed](https://img.shields.io/crates/l/actix-multipart.svg)
[![dependency status](https://deps.rs/crate/actix-multipart/0.6.1/status.svg)](https://deps.rs/crate/actix-multipart/0.6.1) diff --git a/actix-router/CHANGES.md b/actix-router/CHANGES.md index 4d77988d..a80b15e6 100644 --- a/actix-router/CHANGES.md +++ b/actix-router/CHANGES.md @@ -2,7 +2,7 @@ ## Unreleased -- Minimum supported Rust version (MSRV) is now 1.70. +- Minimum supported Rust version (MSRV) is now 1.72. ## 0.5.2 diff --git a/actix-router/README.md b/actix-router/README.md index 506b6501..751c307b 100644 --- a/actix-router/README.md +++ b/actix-router/README.md @@ -4,7 +4,7 @@ [![crates.io](https://img.shields.io/crates/v/actix-router?label=latest)](https://crates.io/crates/actix-router) [![Documentation](https://docs.rs/actix-router/badge.svg?version=0.5.2)](https://docs.rs/actix-router/0.5.2) -![Version](https://img.shields.io/badge/rustc-1.70+-ab6000.svg) +![Version](https://img.shields.io/badge/rustc-1.72+-ab6000.svg) ![MIT or Apache 2.0 licensed](https://img.shields.io/crates/l/actix-router.svg)
[![dependency status](https://deps.rs/crate/actix-router/0.5.2/status.svg)](https://deps.rs/crate/actix-router/0.5.2) diff --git a/actix-test/CHANGES.md b/actix-test/CHANGES.md index 99bb21ed..08252044 100644 --- a/actix-test/CHANGES.md +++ b/actix-test/CHANGES.md @@ -2,7 +2,7 @@ ## Unreleased -- Minimum supported Rust version (MSRV) is now 1.70. +- Minimum supported Rust version (MSRV) is now 1.72. ## 0.1.3 diff --git a/actix-web-actors/CHANGES.md b/actix-web-actors/CHANGES.md index c146841f..9a622d8d 100644 --- a/actix-web-actors/CHANGES.md +++ b/actix-web-actors/CHANGES.md @@ -2,7 +2,7 @@ ## Unreleased -- Minimum supported Rust version (MSRV) is now 1.70. +- Minimum supported Rust version (MSRV) is now 1.72. ## 4.3.0 diff --git a/actix-web-actors/README.md b/actix-web-actors/README.md index 202d7d4c..feb3d1b3 100644 --- a/actix-web-actors/README.md +++ b/actix-web-actors/README.md @@ -6,7 +6,7 @@ [![crates.io](https://img.shields.io/crates/v/actix-web-actors?label=latest)](https://crates.io/crates/actix-web-actors) [![Documentation](https://docs.rs/actix-web-actors/badge.svg?version=4.3.0)](https://docs.rs/actix-web-actors/4.3.0) -![Version](https://img.shields.io/badge/rustc-1.70+-ab6000.svg) +![Version](https://img.shields.io/badge/rustc-1.72+-ab6000.svg) ![License](https://img.shields.io/crates/l/actix-web-actors.svg)
[![dependency status](https://deps.rs/crate/actix-web-actors/4.3.0/status.svg)](https://deps.rs/crate/actix-web-actors/4.3.0) diff --git a/actix-web-codegen/CHANGES.md b/actix-web-codegen/CHANGES.md index ecab6e09..a5acdd21 100644 --- a/actix-web-codegen/CHANGES.md +++ b/actix-web-codegen/CHANGES.md @@ -2,7 +2,7 @@ ## Unreleased -- Minimum supported Rust version (MSRV) is now 1.70. +- Minimum supported Rust version (MSRV) is now 1.72. ## 4.2.2 diff --git a/actix-web-codegen/README.md b/actix-web-codegen/README.md index bd79f9af..9229f8f1 100644 --- a/actix-web-codegen/README.md +++ b/actix-web-codegen/README.md @@ -6,7 +6,7 @@ [![crates.io](https://img.shields.io/crates/v/actix-web-codegen?label=latest)](https://crates.io/crates/actix-web-codegen) [![Documentation](https://docs.rs/actix-web-codegen/badge.svg?version=4.2.2)](https://docs.rs/actix-web-codegen/4.2.2) -![Version](https://img.shields.io/badge/rustc-1.70+-ab6000.svg) +![Version](https://img.shields.io/badge/rustc-1.72+-ab6000.svg) ![License](https://img.shields.io/crates/l/actix-web-codegen.svg)
[![dependency status](https://deps.rs/crate/actix-web-codegen/4.2.2/status.svg)](https://deps.rs/crate/actix-web-codegen/4.2.2) diff --git a/actix-web-codegen/tests/trybuild.rs b/actix-web-codegen/tests/trybuild.rs index 13b0359f..88f77548 100644 --- a/actix-web-codegen/tests/trybuild.rs +++ b/actix-web-codegen/tests/trybuild.rs @@ -1,4 +1,4 @@ -#[rustversion::stable(1.70)] // MSRV +#[rustversion::stable(1.72)] // MSRV #[test] fn compile_macros() { let t = trybuild::TestCases::new(); diff --git a/actix-web/CHANGES.md b/actix-web/CHANGES.md index d296e334..88215293 100644 --- a/actix-web/CHANGES.md +++ b/actix-web/CHANGES.md @@ -4,7 +4,7 @@ ### Changed -- Minimum supported Rust version (MSRV) is now 1.70. +- Minimum supported Rust version (MSRV) is now 1.72. ## 4.5.1 diff --git a/actix-web/README.md b/actix-web/README.md index 613f7e04..35e07fc0 100644 --- a/actix-web/README.md +++ b/actix-web/README.md @@ -9,7 +9,7 @@ [![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=4.5.1)](https://docs.rs/actix-web/4.5.1) -![MSRV](https://img.shields.io/badge/rustc-1.70+-ab6000.svg) +![MSRV](https://img.shields.io/badge/rustc-1.72+-ab6000.svg) ![MIT or Apache 2.0 licensed](https://img.shields.io/crates/l/actix-web.svg) [![Dependency Status](https://deps.rs/crate/actix-web/4.5.1/status.svg)](https://deps.rs/crate/actix-web/4.5.1)
@@ -37,7 +37,7 @@ - SSL support using OpenSSL or Rustls - Middlewares ([Logger, Session, CORS, etc](https://actix.rs/docs/middleware/)) - Integrates with the [`awc` HTTP client](https://docs.rs/awc/) -- Runs on stable Rust 1.70+ +- Runs on stable Rust 1.72+ ## Documentation diff --git a/awc/CHANGES.md b/awc/CHANGES.md index 769f896a..507c8a08 100644 --- a/awc/CHANGES.md +++ b/awc/CHANGES.md @@ -2,7 +2,7 @@ ## Unreleased -- Minimum supported Rust version (MSRV) is now 1.70. +- Minimum supported Rust version (MSRV) is now 1.72. ## 3.4.0 From 9ce5e33b72e238355683cfbb1815be6ea9fdc78e Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Tue, 13 Feb 2024 01:42:54 +0000 Subject: [PATCH 052/151] ci: workaround clap MSRV in dev deps --- .github/workflows/ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a328c74d..915eb7ea 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -54,10 +54,10 @@ jobs: with: tool: cargo-hack,cargo-ci-cache-clean - # - name: workaround MSRV issues - # if: matrix.version.name == 'msrv' - # run: | - # cargo update -p=anstyle --precise=1.0.2 + - name: workaround MSRV issues + if: matrix.version.name == 'msrv' + run: | + cargo update -p=clap --precise=4.4.18 - name: check minimal run: cargo ci-check-min From 3819767fa02850abe654a9e76b53682c39fe9b9c Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Tue, 13 Feb 2024 02:14:03 +0000 Subject: [PATCH 053/151] test: fix trybuild tests --- .../tests/trybuild/route-custom-lowercase.stderr | 13 ++++++++----- .../trybuild/route-duplicate-method-fail.stderr | 13 ++++++++----- .../tests/trybuild/route-missing-method-fail.stderr | 13 ++++++++----- .../tests/trybuild/routes-missing-args-fail.stderr | 13 ++++++++----- .../trybuild/routes-missing-method-fail.stderr | 13 ++++++++----- 5 files changed, 40 insertions(+), 25 deletions(-) diff --git a/actix-web-codegen/tests/trybuild/route-custom-lowercase.stderr b/actix-web-codegen/tests/trybuild/route-custom-lowercase.stderr index 88198a55..c2a51d00 100644 --- a/actix-web-codegen/tests/trybuild/route-custom-lowercase.stderr +++ b/actix-web-codegen/tests/trybuild/route-custom-lowercase.stderr @@ -13,17 +13,20 @@ error[E0277]: the trait bound `fn() -> impl std::future::Future | required by a bound introduced by this call | = help: the following other types implement trait `HttpServiceFactory`: + Resource + actix_web::Scope + Vec + Redirect + (A,) (A, B) (A, B, C) (A, B, C, D) - (A, B, C, D, E) - (A, B, C, D, E, F) - (A, B, C, D, E, F, G) - (A, B, C, D, E, F, G, H) - (A, B, C, D, E, F, G, H, I) and $N others note: required by a bound in `App::::service` --> $WORKSPACE/actix-web/src/app.rs | + | pub fn service(mut self, factory: F) -> Self + | ------- required by a bound in this associated function + | where | F: HttpServiceFactory + 'static, | ^^^^^^^^^^^^^^^^^^ required by this bound in `App::::service` diff --git a/actix-web-codegen/tests/trybuild/route-duplicate-method-fail.stderr b/actix-web-codegen/tests/trybuild/route-duplicate-method-fail.stderr index bda73634..ae18f347 100644 --- a/actix-web-codegen/tests/trybuild/route-duplicate-method-fail.stderr +++ b/actix-web-codegen/tests/trybuild/route-duplicate-method-fail.stderr @@ -13,17 +13,20 @@ error[E0277]: the trait bound `fn() -> impl std::future::Future | required by a bound introduced by this call | = help: the following other types implement trait `HttpServiceFactory`: + Resource + actix_web::Scope + Vec + Redirect + (A,) (A, B) (A, B, C) (A, B, C, D) - (A, B, C, D, E) - (A, B, C, D, E, F) - (A, B, C, D, E, F, G) - (A, B, C, D, E, F, G, H) - (A, B, C, D, E, F, G, H, I) and $N others note: required by a bound in `App::::service` --> $WORKSPACE/actix-web/src/app.rs | + | pub fn service(mut self, factory: F) -> Self + | ------- required by a bound in this associated function + | where | F: HttpServiceFactory + 'static, | ^^^^^^^^^^^^^^^^^^ required by this bound in `App::::service` diff --git a/actix-web-codegen/tests/trybuild/route-missing-method-fail.stderr b/actix-web-codegen/tests/trybuild/route-missing-method-fail.stderr index 9f2f788f..37d8354c 100644 --- a/actix-web-codegen/tests/trybuild/route-missing-method-fail.stderr +++ b/actix-web-codegen/tests/trybuild/route-missing-method-fail.stderr @@ -15,17 +15,20 @@ error[E0277]: the trait bound `fn() -> impl std::future::Future | required by a bound introduced by this call | = help: the following other types implement trait `HttpServiceFactory`: + Resource + actix_web::Scope + Vec + Redirect + (A,) (A, B) (A, B, C) (A, B, C, D) - (A, B, C, D, E) - (A, B, C, D, E, F) - (A, B, C, D, E, F, G) - (A, B, C, D, E, F, G, H) - (A, B, C, D, E, F, G, H, I) and $N others note: required by a bound in `App::::service` --> $WORKSPACE/actix-web/src/app.rs | + | pub fn service(mut self, factory: F) -> Self + | ------- required by a bound in this associated function + | where | F: HttpServiceFactory + 'static, | ^^^^^^^^^^^^^^^^^^ required by this bound in `App::::service` diff --git a/actix-web-codegen/tests/trybuild/routes-missing-args-fail.stderr b/actix-web-codegen/tests/trybuild/routes-missing-args-fail.stderr index 2e84c296..40b19fc7 100644 --- a/actix-web-codegen/tests/trybuild/routes-missing-args-fail.stderr +++ b/actix-web-codegen/tests/trybuild/routes-missing-args-fail.stderr @@ -29,17 +29,20 @@ error[E0277]: the trait bound `fn() -> impl std::future::Future | required by a bound introduced by this call | = help: the following other types implement trait `HttpServiceFactory`: + Resource + actix_web::Scope + Vec + Redirect + (A,) (A, B) (A, B, C) (A, B, C, D) - (A, B, C, D, E) - (A, B, C, D, E, F) - (A, B, C, D, E, F, G) - (A, B, C, D, E, F, G, H) - (A, B, C, D, E, F, G, H, I) and $N others note: required by a bound in `App::::service` --> $WORKSPACE/actix-web/src/app.rs | + | pub fn service(mut self, factory: F) -> Self + | ------- required by a bound in this associated function + | where | F: HttpServiceFactory + 'static, | ^^^^^^^^^^^^^^^^^^ required by this bound in `App::::service` diff --git a/actix-web-codegen/tests/trybuild/routes-missing-method-fail.stderr b/actix-web-codegen/tests/trybuild/routes-missing-method-fail.stderr index 228dced9..ff7f00b3 100644 --- a/actix-web-codegen/tests/trybuild/routes-missing-method-fail.stderr +++ b/actix-web-codegen/tests/trybuild/routes-missing-method-fail.stderr @@ -15,17 +15,20 @@ error[E0277]: the trait bound `fn() -> impl std::future::Future | required by a bound introduced by this call | = help: the following other types implement trait `HttpServiceFactory`: + Resource + actix_web::Scope + Vec + Redirect + (A,) (A, B) (A, B, C) (A, B, C, D) - (A, B, C, D, E) - (A, B, C, D, E, F) - (A, B, C, D, E, F, G) - (A, B, C, D, E, F, G, H) - (A, B, C, D, E, F, G, H, I) and $N others note: required by a bound in `App::::service` --> $WORKSPACE/actix-web/src/app.rs | + | pub fn service(mut self, factory: F) -> Self + | ------- required by a bound in this associated function + | where | F: HttpServiceFactory + 'static, | ^^^^^^^^^^^^^^^^^^ required by this bound in `App::::service` From 82f8ddc38f279e1b7bea2c1103b784f5fdc1fb8e Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Wed, 14 Feb 2024 22:22:07 +0000 Subject: [PATCH 054/151] feat: multipart testing utilities (#3288) --- actix-multipart/CHANGES.md | 1 + actix-multipart/Cargo.toml | 3 + actix-multipart/src/form/json.rs | 51 +++++--- actix-multipart/src/lib.rs | 7 +- actix-multipart/src/server.rs | 32 ++++- actix-multipart/src/test.rs | 217 +++++++++++++++++++++++++++++++ 6 files changed, 287 insertions(+), 24 deletions(-) create mode 100644 actix-multipart/src/test.rs diff --git a/actix-multipart/CHANGES.md b/actix-multipart/CHANGES.md index adf37044..196d2ca9 100644 --- a/actix-multipart/CHANGES.md +++ b/actix-multipart/CHANGES.md @@ -2,6 +2,7 @@ ## Unreleased +- Add testing utilities under new module `test`. - Minimum supported Rust version (MSRV) is now 1.72. ## 0.6.1 diff --git a/actix-multipart/Cargo.toml b/actix-multipart/Cargo.toml index 257d5613..6e36c339 100644 --- a/actix-multipart/Cargo.toml +++ b/actix-multipart/Cargo.toml @@ -35,6 +35,7 @@ local-waker = "0.1" log = "0.4" memchr = "2.5" mime = "0.3" +rand = "0.8" serde = "1" serde_json = "1" serde_plain = "1" @@ -46,7 +47,9 @@ actix-http = "3" actix-multipart-rfc7578 = "0.10" actix-rt = "2.2" actix-test = "0.1" +actix-web = "4" awc = "3" futures-util = { version = "0.3.17", default-features = false, features = ["alloc"] } +multer = "3" tokio = { version = "1.24.2", features = ["sync"] } tokio-stream = "0.1" diff --git a/actix-multipart/src/form/json.rs b/actix-multipart/src/form/json.rs index fb90a82b..bb4e03bf 100644 --- a/actix-multipart/src/form/json.rs +++ b/actix-multipart/src/form/json.rs @@ -131,14 +131,13 @@ impl Default for JsonConfig { #[cfg(test)] mod tests { - use std::{collections::HashMap, io::Cursor}; + use std::collections::HashMap; - use actix_multipart_rfc7578::client::multipart; use actix_web::{http::StatusCode, web, App, HttpResponse, Responder}; + use bytes::Bytes; use crate::form::{ json::{Json, JsonConfig}, - tests::send_form, MultipartForm, }; @@ -155,6 +154,8 @@ mod tests { HttpResponse::Ok().finish() } + const TEST_JSON: &str = r#"{"key1": "value1", "key2": "value2"}"#; + #[actix_rt::test] async fn test_json_without_content_type() { let srv = actix_test::start(|| { @@ -163,10 +164,16 @@ mod tests { .app_data(JsonConfig::default().validate_content_type(false)) }); - let mut form = multipart::Form::default(); - form.add_text("json", "{\"key1\": \"value1\", \"key2\": \"value2\"}"); - let response = send_form(&srv, form, "/").await; - assert_eq!(response.status(), StatusCode::OK); + let (body, headers) = crate::test::create_form_data_payload_and_headers( + "json", + None, + None, + Bytes::from_static(TEST_JSON.as_bytes()), + ); + let mut req = srv.post("/"); + *req.headers_mut() = headers; + let res = req.send_body(body).await.unwrap(); + assert_eq!(res.status(), StatusCode::OK); } #[actix_rt::test] @@ -178,17 +185,27 @@ mod tests { }); // Deny because wrong content type - let bytes = Cursor::new("{\"key1\": \"value1\", \"key2\": \"value2\"}"); - let mut form = multipart::Form::default(); - form.add_reader_file_with_mime("json", bytes, "", mime::APPLICATION_OCTET_STREAM); - let response = send_form(&srv, form, "/").await; - assert_eq!(response.status(), StatusCode::BAD_REQUEST); + let (body, headers) = crate::test::create_form_data_payload_and_headers( + "json", + None, + Some(mime::APPLICATION_OCTET_STREAM), + Bytes::from_static(TEST_JSON.as_bytes()), + ); + let mut req = srv.post("/"); + *req.headers_mut() = headers; + let res = req.send_body(body).await.unwrap(); + assert_eq!(res.status(), StatusCode::BAD_REQUEST); // Allow because correct content type - let bytes = Cursor::new("{\"key1\": \"value1\", \"key2\": \"value2\"}"); - let mut form = multipart::Form::default(); - form.add_reader_file_with_mime("json", bytes, "", mime::APPLICATION_JSON); - let response = send_form(&srv, form, "/").await; - assert_eq!(response.status(), StatusCode::OK); + let (body, headers) = crate::test::create_form_data_payload_and_headers( + "json", + None, + Some(mime::APPLICATION_JSON), + Bytes::from_static(TEST_JSON.as_bytes()), + ); + let mut req = srv.post("/"); + *req.headers_mut() = headers; + let res = req.send_body(body).await.unwrap(); + assert_eq!(res.status(), StatusCode::OK); } } diff --git a/actix-multipart/src/lib.rs b/actix-multipart/src/lib.rs index 495bae9c..c06a00ca 100644 --- a/actix-multipart/src/lib.rs +++ b/actix-multipart/src/lib.rs @@ -13,11 +13,14 @@ extern crate self as actix_multipart; mod error; mod extractor; -mod server; - pub mod form; +mod server; +pub mod test; pub use self::{ error::MultipartError, server::{Field, Multipart}, + test::{ + create_form_data_payload_and_headers, create_form_data_payload_and_headers_with_boundary, + }, }; diff --git a/actix-multipart/src/server.rs b/actix-multipart/src/server.rs index c08031eb..ae32cf0c 100644 --- a/actix-multipart/src/server.rs +++ b/actix-multipart/src/server.rs @@ -863,13 +863,15 @@ mod tests { test::TestRequest, FromRequest, }; - use bytes::Bytes; + use bytes::{BufMut as _, Bytes}; use futures_util::{future::lazy, StreamExt as _}; use tokio::sync::mpsc; use tokio_stream::wrappers::UnboundedReceiverStream; use super::*; + const BOUNDARY: &str = "abbc761f78ff4d7cb7573b5a23f96ef0"; + #[actix_rt::test] async fn test_boundary() { let headers = HeaderMap::new(); @@ -965,6 +967,26 @@ mod tests { } fn create_simple_request_with_header() -> (Bytes, HeaderMap) { + let (body, headers) = crate::test::create_form_data_payload_and_headers_with_boundary( + BOUNDARY, + "file", + Some("fn.txt".to_owned()), + Some(mime::TEXT_PLAIN_UTF_8), + Bytes::from_static(b"data"), + ); + + let mut buf = BytesMut::with_capacity(body.len() + 14); + + // add junk before form to test pre-boundary data rejection + buf.put("testasdadsad\r\n".as_bytes()); + + buf.put(body); + + (buf.freeze(), headers) + } + + // TODO: use test utility when multi-file support is introduced + fn create_double_request_with_header() -> (Bytes, HeaderMap) { let bytes = Bytes::from( "testasdadsad\r\n\ --abbc761f78ff4d7cb7573b5a23f96ef0\r\n\ @@ -990,7 +1012,7 @@ mod tests { #[actix_rt::test] async fn test_multipart_no_end_crlf() { let (sender, payload) = create_stream(); - let (mut bytes, headers) = create_simple_request_with_header(); + let (mut bytes, headers) = create_double_request_with_header(); let bytes_stripped = bytes.split_to(bytes.len()); // strip crlf sender.send(Ok(bytes_stripped)).unwrap(); @@ -1017,7 +1039,7 @@ mod tests { #[actix_rt::test] async fn test_multipart() { let (sender, payload) = create_stream(); - let (bytes, headers) = create_simple_request_with_header(); + let (bytes, headers) = create_double_request_with_header(); sender.send(Ok(bytes)).unwrap(); @@ -1080,7 +1102,7 @@ mod tests { #[actix_rt::test] async fn test_stream() { - let (bytes, headers) = create_simple_request_with_header(); + let (bytes, headers) = create_double_request_with_header(); let payload = SlowStream::new(bytes); let mut multipart = Multipart::new(&headers, payload); @@ -1319,7 +1341,7 @@ mod tests { #[actix_rt::test] async fn test_drop_field_awaken_multipart() { let (sender, payload) = create_stream(); - let (bytes, headers) = create_simple_request_with_header(); + let (bytes, headers) = create_double_request_with_header(); sender.send(Ok(bytes)).unwrap(); drop(sender); // eof diff --git a/actix-multipart/src/test.rs b/actix-multipart/src/test.rs new file mode 100644 index 00000000..77d91828 --- /dev/null +++ b/actix-multipart/src/test.rs @@ -0,0 +1,217 @@ +use actix_web::http::header::{self, HeaderMap}; +use bytes::{BufMut as _, Bytes, BytesMut}; +use mime::Mime; +use rand::{ + distributions::{Alphanumeric, DistString as _}, + thread_rng, +}; + +const CRLF: &[u8] = b"\r\n"; +const CRLF_CRLF: &[u8] = b"\r\n\r\n"; +const HYPHENS: &[u8] = b"--"; +const BOUNDARY_PREFIX: &str = "------------------------"; + +/// Constructs a `multipart/form-data` payload from bytes and metadata. +/// +/// Returned header map can be extended or merged with existing headers. +/// +/// Multipart boundary used is a random alphanumeric string. +/// +/// # Examples +/// +/// ``` +/// use actix_multipart::test::create_form_data_payload_and_headers; +/// use actix_web::test::TestRequest; +/// use bytes::Bytes; +/// use memchr::memmem::find; +/// +/// let (body, headers) = create_form_data_payload_and_headers( +/// "foo", +/// Some("lorem.txt".to_owned()), +/// Some(mime::TEXT_PLAIN_UTF_8), +/// Bytes::from_static(b"Lorem ipsum."), +/// ); +/// +/// assert!(find(&body, b"foo").is_some()); +/// assert!(find(&body, b"lorem.txt").is_some()); +/// assert!(find(&body, b"text/plain; charset=utf-8").is_some()); +/// assert!(find(&body, b"Lorem ipsum.").is_some()); +/// +/// let req = TestRequest::default(); +/// +/// // merge header map into existing test request and set multipart body +/// let req = headers +/// .into_iter() +/// .fold(req, |req, hdr| req.insert_header(hdr)) +/// .set_payload(body) +/// .to_http_request(); +/// +/// assert!( +/// req.headers() +/// .get("content-type") +/// .unwrap() +/// .to_str() +/// .unwrap() +/// .starts_with("multipart/form-data; boundary=\"") +/// ); +/// ``` +pub fn create_form_data_payload_and_headers( + name: &str, + filename: Option, + content_type: Option, + file: Bytes, +) -> (Bytes, HeaderMap) { + let boundary = Alphanumeric.sample_string(&mut thread_rng(), 32); + + create_form_data_payload_and_headers_with_boundary( + &boundary, + name, + filename, + content_type, + file, + ) +} + +/// Constructs a `multipart/form-data` payload from bytes and metadata with a fixed boundary. +/// +/// See [`create_form_data_payload_and_headers`] for more details. +pub fn create_form_data_payload_and_headers_with_boundary( + boundary: &str, + name: &str, + filename: Option, + content_type: Option, + file: Bytes, +) -> (Bytes, HeaderMap) { + let mut buf = BytesMut::with_capacity(file.len() + 128); + + let boundary_str = [BOUNDARY_PREFIX, boundary].concat(); + let boundary = boundary_str.as_bytes(); + + buf.put(HYPHENS); + buf.put(boundary); + buf.put(CRLF); + + buf.put(format!("Content-Disposition: form-data; name=\"{name}\"").as_bytes()); + if let Some(filename) = filename { + buf.put(format!("; filename=\"{filename}\"").as_bytes()); + } + buf.put(CRLF); + + if let Some(ct) = content_type { + buf.put(format!("Content-Type: {ct}").as_bytes()); + buf.put(CRLF); + } + + buf.put(format!("Content-Length: {}", file.len()).as_bytes()); + buf.put(CRLF_CRLF); + + buf.put(file); + buf.put(CRLF); + + buf.put(HYPHENS); + buf.put(boundary); + buf.put(HYPHENS); + buf.put(CRLF); + + let mut headers = HeaderMap::new(); + headers.insert( + header::CONTENT_TYPE, + format!("multipart/form-data; boundary=\"{boundary_str}\"") + .parse() + .unwrap(), + ); + + (buf.freeze(), headers) +} + +#[cfg(test)] +mod tests { + use std::convert::Infallible; + + use futures_util::stream; + + use super::*; + + fn find_boundary(headers: &HeaderMap) -> String { + headers + .get("content-type") + .unwrap() + .to_str() + .unwrap() + .parse::() + .unwrap() + .get_param(mime::BOUNDARY) + .unwrap() + .as_str() + .to_owned() + } + + #[test] + fn wire_format() { + let (pl, headers) = create_form_data_payload_and_headers_with_boundary( + "qWeRtYuIoP", + "foo", + None, + None, + Bytes::from_static(b"Lorem ipsum dolor\nsit ame."), + ); + + assert_eq!( + find_boundary(&headers), + "------------------------qWeRtYuIoP", + ); + + assert_eq!( + std::str::from_utf8(&pl).unwrap(), + "--------------------------qWeRtYuIoP\r\n\ + Content-Disposition: form-data; name=\"foo\"\r\n\ + Content-Length: 26\r\n\ + \r\n\ + Lorem ipsum dolor\n\ + sit ame.\r\n\ + --------------------------qWeRtYuIoP--\r\n", + ); + + let (pl, _headers) = create_form_data_payload_and_headers_with_boundary( + "qWeRtYuIoP", + "foo", + Some("Lorem.txt".to_owned()), + Some(mime::TEXT_PLAIN_UTF_8), + Bytes::from_static(b"Lorem ipsum dolor\nsit ame."), + ); + + assert_eq!( + std::str::from_utf8(&pl).unwrap(), + "--------------------------qWeRtYuIoP\r\n\ + Content-Disposition: form-data; name=\"foo\"; filename=\"Lorem.txt\"\r\n\ + Content-Type: text/plain; charset=utf-8\r\n\ + Content-Length: 26\r\n\ + \r\n\ + Lorem ipsum dolor\n\ + sit ame.\r\n\ + --------------------------qWeRtYuIoP--\r\n", + ); + } + + /// Test using an external library to prevent the two-wrongs-make-a-right class of errors. + #[actix_web::test] + async fn ecosystem_compat() { + let (pl, headers) = create_form_data_payload_and_headers( + "foo", + None, + None, + Bytes::from_static(b"Lorem ipsum dolor\nsit ame."), + ); + + let boundary = find_boundary(&headers); + + let pl = stream::once(async { Ok::<_, Infallible>(pl) }); + + let mut form = multer::Multipart::new(pl, boundary); + let field = form.next_field().await.unwrap().unwrap(); + assert_eq!(field.name().unwrap(), "foo"); + assert_eq!(field.file_name(), None); + assert_eq!(field.content_type(), None); + assert!(field.bytes().await.unwrap().starts_with(b"Lorem")); + } +} From 289f749e9f29efbfdf5c965794056d441302a75f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 16 Feb 2024 13:38:38 +0000 Subject: [PATCH 055/151] build(deps): bump taiki-e/install-action from 2.26.12 to 2.26.18 (#3289) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/ci-post-merge.yml | 6 +++--- .github/workflows/ci.yml | 2 +- .github/workflows/coverage.yml | 2 +- .github/workflows/lint.yml | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci-post-merge.yml b/.github/workflows/ci-post-merge.yml index 1a0437cb..23a6be2f 100644 --- a/.github/workflows/ci-post-merge.yml +++ b/.github/workflows/ci-post-merge.yml @@ -45,7 +45,7 @@ jobs: toolchain: ${{ matrix.version.version }} - name: Install cargo-hack and cargo-ci-cache-clean - uses: taiki-e/install-action@v2.26.12 + uses: taiki-e/install-action@v2.26.18 with: tool: cargo-hack,cargo-ci-cache-clean @@ -85,7 +85,7 @@ jobs: uses: actions-rust-lang/setup-rust-toolchain@v1.8.0 - name: Install cargo-hack - uses: taiki-e/install-action@v2.26.12 + uses: taiki-e/install-action@v2.26.18 with: tool: cargo-hack @@ -106,7 +106,7 @@ jobs: uses: actions-rust-lang/setup-rust-toolchain@v1.8.0 - name: Install nextest - uses: taiki-e/install-action@v2.26.12 + uses: taiki-e/install-action@v2.26.18 with: tool: nextest diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 915eb7ea..e0b4f098 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -50,7 +50,7 @@ jobs: toolchain: ${{ matrix.version.version }} - name: Install cargo-hack and cargo-ci-cache-clean - uses: taiki-e/install-action@v2.26.12 + uses: taiki-e/install-action@v2.26.18 with: tool: cargo-hack,cargo-ci-cache-clean diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 180a9a0e..be56d0a7 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -23,7 +23,7 @@ jobs: components: llvm-tools-preview - name: Install cargo-llvm-cov - uses: taiki-e/install-action@v2.26.12 + uses: taiki-e/install-action@v2.26.18 with: tool: cargo-llvm-cov diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index bb03acce..8e5b2881 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -82,7 +82,7 @@ jobs: toolchain: nightly-2023-08-25 - name: Install cargo-public-api - uses: taiki-e/install-action@v2.26.12 + uses: taiki-e/install-action@v2.26.18 with: tool: cargo-public-api From 8c31d137aaf9ce8f536e5a71aa04cf68b556a7cb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 19 Feb 2024 12:31:10 +0000 Subject: [PATCH 056/151] build(deps): bump taiki-e/install-action from 2.26.18 to 2.27.2 (#3294) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Rob Ede --- .github/workflows/ci-post-merge.yml | 6 +++--- .github/workflows/ci.yml | 2 +- .github/workflows/coverage.yml | 2 +- .github/workflows/lint.yml | 2 +- actix-files/src/lib.rs | 2 +- actix-http/src/body/message_body.rs | 1 - actix-http/src/error.rs | 4 +--- actix-http/src/h1/codec.rs | 3 --- actix-http/src/h1/decoder.rs | 9 +-------- actix-http/src/ws/mod.rs | 2 +- actix-http/src/ws/proto.rs | 5 +---- actix-multipart/src/server.rs | 2 +- actix-router/src/de.rs | 4 ++-- actix-web-actors/src/context.rs | 2 -- actix-web-actors/src/ws.rs | 5 +---- actix-web/src/app.rs | 1 - actix-web/src/guard/mod.rs | 2 +- actix-web/src/http/header/content_length.rs | 2 +- actix-web/src/middleware/condition.rs | 2 +- actix-web/src/middleware/default_headers.rs | 2 -- actix-web/src/middleware/err_handlers.rs | 5 +---- actix-web/src/middleware/logger.rs | 2 +- actix-web/src/middleware/normalize.rs | 1 - actix-web/src/redirect.rs | 2 +- actix-web/src/request.rs | 2 +- actix-web/src/resource.rs | 10 ++-------- actix-web/src/response/builder.rs | 5 +---- actix-web/src/response/customize_responder.rs | 5 +---- actix-web/src/response/responder.rs | 6 +----- actix-web/src/response/response.rs | 2 +- actix-web/src/scope.rs | 2 -- actix-web/src/service.rs | 2 +- actix-web/src/test/test_request.rs | 2 +- actix-web/src/types/either.rs | 5 +---- actix-web/src/types/form.rs | 2 +- actix-web/src/types/payload.rs | 6 ++---- awc/src/client/connection.rs | 2 -- awc/src/client/connector.rs | 1 - awc/src/client/pool.rs | 3 +-- awc/src/middleware/redirect.rs | 5 +---- awc/src/responses/json_body.rs | 2 +- awc/src/responses/response_body.rs | 2 +- awc/src/test.rs | 2 +- 43 files changed, 39 insertions(+), 97 deletions(-) diff --git a/.github/workflows/ci-post-merge.yml b/.github/workflows/ci-post-merge.yml index 23a6be2f..4d668415 100644 --- a/.github/workflows/ci-post-merge.yml +++ b/.github/workflows/ci-post-merge.yml @@ -45,7 +45,7 @@ jobs: toolchain: ${{ matrix.version.version }} - name: Install cargo-hack and cargo-ci-cache-clean - uses: taiki-e/install-action@v2.26.18 + uses: taiki-e/install-action@v2.27.2 with: tool: cargo-hack,cargo-ci-cache-clean @@ -85,7 +85,7 @@ jobs: uses: actions-rust-lang/setup-rust-toolchain@v1.8.0 - name: Install cargo-hack - uses: taiki-e/install-action@v2.26.18 + uses: taiki-e/install-action@v2.27.2 with: tool: cargo-hack @@ -106,7 +106,7 @@ jobs: uses: actions-rust-lang/setup-rust-toolchain@v1.8.0 - name: Install nextest - uses: taiki-e/install-action@v2.26.18 + uses: taiki-e/install-action@v2.27.2 with: tool: nextest diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e0b4f098..b40a9f13 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -50,7 +50,7 @@ jobs: toolchain: ${{ matrix.version.version }} - name: Install cargo-hack and cargo-ci-cache-clean - uses: taiki-e/install-action@v2.26.18 + uses: taiki-e/install-action@v2.27.2 with: tool: cargo-hack,cargo-ci-cache-clean diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index be56d0a7..180ba35d 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -23,7 +23,7 @@ jobs: components: llvm-tools-preview - name: Install cargo-llvm-cov - uses: taiki-e/install-action@v2.26.18 + uses: taiki-e/install-action@v2.27.2 with: tool: cargo-llvm-cov diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 8e5b2881..79f53ce1 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -82,7 +82,7 @@ jobs: toolchain: nightly-2023-08-25 - name: Install cargo-public-api - uses: taiki-e/install-action@v2.26.18 + uses: taiki-e/install-action@v2.27.2 with: tool: cargo-public-api diff --git a/actix-files/src/lib.rs b/actix-files/src/lib.rs index 8381519a..167f996c 100644 --- a/actix-files/src/lib.rs +++ b/actix-files/src/lib.rs @@ -75,7 +75,7 @@ mod tests { dev::ServiceFactory, guard, http::{ - header::{self, ContentDisposition, DispositionParam, DispositionType}, + header::{self, ContentDisposition, DispositionParam}, Method, StatusCode, }, middleware::Compress, diff --git a/actix-http/src/body/message_body.rs b/actix-http/src/body/message_body.rs index c3f55ce7..739fe502 100644 --- a/actix-http/src/body/message_body.rs +++ b/actix-http/src/body/message_body.rs @@ -531,7 +531,6 @@ where mod tests { use actix_rt::pin; use actix_utils::future::poll_fn; - use bytes::{Bytes, BytesMut}; use futures_util::stream; use super::*; diff --git a/actix-http/src/error.rs b/actix-http/src/error.rs index fbd2eb7a..69e2f14a 100644 --- a/actix-http/src/error.rs +++ b/actix-http/src/error.rs @@ -399,9 +399,7 @@ pub enum ContentTypeError { #[cfg(test)] mod tests { - use std::io; - - use http::{Error as HttpError, StatusCode}; + use http::Error as HttpError; use super::*; diff --git a/actix-http/src/h1/codec.rs b/actix-http/src/h1/codec.rs index 8dae2e43..2b452f8f 100644 --- a/actix-http/src/h1/codec.rs +++ b/actix-http/src/h1/codec.rs @@ -198,9 +198,6 @@ impl Encoder, BodySize)>> for Codec { #[cfg(test)] mod tests { - use bytes::BytesMut; - use http::Method; - use super::*; use crate::HttpMessage as _; diff --git a/actix-http/src/h1/decoder.rs b/actix-http/src/h1/decoder.rs index 5c26515f..af64e880 100644 --- a/actix-http/src/h1/decoder.rs +++ b/actix-http/src/h1/decoder.rs @@ -563,15 +563,8 @@ impl Decoder for PayloadDecoder { #[cfg(test)] mod tests { - use bytes::{Bytes, BytesMut}; - use http::{Method, Version}; - use super::*; - use crate::{ - error::ParseError, - header::{HeaderName, SET_COOKIE}, - HttpMessage as _, - }; + use crate::{header::SET_COOKIE, HttpMessage as _}; impl PayloadType { pub(crate) fn unwrap(self) -> PayloadDecoder { diff --git a/actix-http/src/ws/mod.rs b/actix-http/src/ws/mod.rs index 87f9b38f..3ed53b70 100644 --- a/actix-http/src/ws/mod.rs +++ b/actix-http/src/ws/mod.rs @@ -221,7 +221,7 @@ pub fn handshake_response(req: &RequestHead) -> ResponseBuilder { #[cfg(test)] mod tests { use super::*; - use crate::{header, test::TestRequest, Method}; + use crate::{header, test::TestRequest}; #[test] fn test_handshake() { diff --git a/actix-http/src/ws/proto.rs b/actix-http/src/ws/proto.rs index 0653c00b..27815eaf 100644 --- a/actix-http/src/ws/proto.rs +++ b/actix-http/src/ws/proto.rs @@ -1,7 +1,4 @@ -use std::{ - convert::{From, Into}, - fmt, -}; +use std::fmt; use base64::prelude::*; use tracing::error; diff --git a/actix-multipart/src/server.rs b/actix-multipart/src/server.rs index ae32cf0c..d0f83331 100644 --- a/actix-multipart/src/server.rs +++ b/actix-multipart/src/server.rs @@ -863,7 +863,7 @@ mod tests { test::TestRequest, FromRequest, }; - use bytes::{BufMut as _, Bytes}; + use bytes::BufMut as _; use futures_util::{future::lazy, StreamExt as _}; use tokio::sync::mpsc; use tokio_stream::wrappers::UnboundedReceiverStream; diff --git a/actix-router/src/de.rs b/actix-router/src/de.rs index e8c7c658..ce2dcf8f 100644 --- a/actix-router/src/de.rs +++ b/actix-router/src/de.rs @@ -500,10 +500,10 @@ impl<'de> de::VariantAccess<'de> for UnitVariant { #[cfg(test)] mod tests { - use serde::{de, Deserialize}; + use serde::Deserialize; use super::*; - use crate::{path::Path, router::Router, ResourceDef}; + use crate::{router::Router, ResourceDef}; #[derive(Deserialize)] struct MyStruct { diff --git a/actix-web-actors/src/context.rs b/actix-web-actors/src/context.rs index be8fd387..23e33645 100644 --- a/actix-web-actors/src/context.rs +++ b/actix-web-actors/src/context.rs @@ -248,13 +248,11 @@ where mod tests { use std::time::Duration; - use actix::Actor; use actix_web::{ http::StatusCode, test::{call_service, init_service, read_body, TestRequest}, web, App, HttpResponse, }; - use bytes::Bytes; use super::*; diff --git a/actix-web-actors/src/ws.rs b/actix-web-actors/src/ws.rs index 04dbf5e1..1fb90322 100644 --- a/actix-web-actors/src/ws.rs +++ b/actix-web-actors/src/ws.rs @@ -817,10 +817,7 @@ where #[cfg(test)] mod tests { - use actix_web::{ - http::{header, Method}, - test::TestRequest, - }; + use actix_web::test::TestRequest; use super::*; diff --git a/actix-web/src/app.rs b/actix-web/src/app.rs index 26b278bc..1a3b7908 100644 --- a/actix-web/src/app.rs +++ b/actix-web/src/app.rs @@ -471,7 +471,6 @@ mod tests { Method, StatusCode, }, middleware::DefaultHeaders, - service::ServiceRequest, test::{call_service, init_service, read_body, try_init_service, TestRequest}, web, HttpRequest, HttpResponse, }; diff --git a/actix-web/src/guard/mod.rs b/actix-web/src/guard/mod.rs index 35294a3c..9451a60f 100644 --- a/actix-web/src/guard/mod.rs +++ b/actix-web/src/guard/mod.rs @@ -380,7 +380,7 @@ impl Guard for HeaderGuard { #[cfg(test)] mod tests { - use actix_http::{header, Method}; + use actix_http::Method; use super::*; use crate::test::TestRequest; diff --git a/actix-web/src/http/header/content_length.rs b/actix-web/src/http/header/content_length.rs index ad16dc40..557c7c9f 100644 --- a/actix-web/src/http/header/content_length.rs +++ b/actix-web/src/http/header/content_length.rs @@ -126,7 +126,7 @@ mod tests { use std::fmt; use super::*; - use crate::{http::header::Header, test::TestRequest, HttpRequest}; + use crate::{test::TestRequest, HttpRequest}; fn req_from_raw_headers, V: AsRef<[u8]>>( header_lines: I, diff --git a/actix-web/src/middleware/condition.rs b/actix-web/src/middleware/condition.rs index 5e106c11..55c56d49 100644 --- a/actix-web/src/middleware/condition.rs +++ b/actix-web/src/middleware/condition.rs @@ -135,7 +135,7 @@ mod tests { use super::*; use crate::{ body::BoxBody, - dev::{ServiceRequest, ServiceResponse}, + dev::ServiceRequest, error::Result, http::{ header::{HeaderValue, CONTENT_TYPE}, diff --git a/actix-web/src/middleware/default_headers.rs b/actix-web/src/middleware/default_headers.rs index b5a5a699..f21afe6e 100644 --- a/actix-web/src/middleware/default_headers.rs +++ b/actix-web/src/middleware/default_headers.rs @@ -190,8 +190,6 @@ mod tests { use super::*; use crate::{ - dev::ServiceRequest, - http::header::CONTENT_TYPE, test::{self, TestRequest}, HttpResponse, }; diff --git a/actix-web/src/middleware/err_handlers.rs b/actix-web/src/middleware/err_handlers.rs index e640bba0..aa6d1c8a 100644 --- a/actix-web/src/middleware/err_handlers.rs +++ b/actix-web/src/middleware/err_handlers.rs @@ -407,10 +407,7 @@ mod tests { use super::*; use crate::{ body, - http::{ - header::{HeaderValue, CONTENT_TYPE}, - StatusCode, - }, + http::header::{HeaderValue, CONTENT_TYPE}, test::{self, TestRequest}, }; diff --git a/actix-web/src/middleware/logger.rs b/actix-web/src/middleware/logger.rs index ce2caacd..ce42c3af 100644 --- a/actix-web/src/middleware/logger.rs +++ b/actix-web/src/middleware/logger.rs @@ -716,7 +716,7 @@ impl<'a> fmt::Display for FormatDisplay<'a> { #[cfg(test)] mod tests { - use actix_service::{IntoService, Service, Transform}; + use actix_service::IntoService; use actix_utils::future::ok; use super::*; diff --git a/actix-web/src/middleware/normalize.rs b/actix-web/src/middleware/normalize.rs index afcc0faa..3f20431c 100644 --- a/actix-web/src/middleware/normalize.rs +++ b/actix-web/src/middleware/normalize.rs @@ -205,7 +205,6 @@ mod tests { use super::*; use crate::{ - dev::ServiceRequest, guard::fn_guard, test::{call_service, init_service, TestRequest}, web, App, HttpResponse, diff --git a/actix-web/src/redirect.rs b/actix-web/src/redirect.rs index 5ce960aa..bd29a140 100644 --- a/actix-web/src/redirect.rs +++ b/actix-web/src/redirect.rs @@ -182,7 +182,7 @@ impl Responder for Redirect { #[cfg(test)] mod tests { use super::*; - use crate::{dev::Service, http::StatusCode, test, App}; + use crate::{dev::Service, test, App}; #[actix_rt::test] async fn absolute_redirects() { diff --git a/actix-web/src/request.rs b/actix-web/src/request.rs index ece36a38..08a222c8 100644 --- a/actix-web/src/request.rs +++ b/actix-web/src/request.rs @@ -523,7 +523,7 @@ mod tests { use super::*; use crate::{ - dev::{ResourceDef, ResourceMap, Service}, + dev::{ResourceDef, Service}, http::{header, StatusCode}, test::{self, call_service, init_service, read_body, TestRequest}, web, App, HttpResponse, diff --git a/actix-web/src/resource.rs b/actix-web/src/resource.rs index 95185b80..291d6746 100644 --- a/actix-web/src/resource.rs +++ b/actix-web/src/resource.rs @@ -540,20 +540,14 @@ mod tests { use std::time::Duration; use actix_rt::time::sleep; - use actix_service::Service; use actix_utils::future::ok; use super::*; use crate::{ - guard, - http::{ - header::{self, HeaderValue}, - Method, StatusCode, - }, + http::{header::HeaderValue, Method, StatusCode}, middleware::DefaultHeaders, - service::{ServiceRequest, ServiceResponse}, test::{call_service, init_service, TestRequest}, - web, App, Error, HttpMessage, HttpResponse, + App, HttpMessage, }; #[test] diff --git a/actix-web/src/response/builder.rs b/actix-web/src/response/builder.rs index 28a0adff..023842ee 100644 --- a/actix-web/src/response/builder.rs +++ b/actix-web/src/response/builder.rs @@ -408,10 +408,7 @@ mod tests { use super::*; use crate::{ body, - http::{ - header::{self, HeaderValue, CONTENT_TYPE}, - StatusCode, - }, + http::header::{HeaderValue, CONTENT_TYPE}, test::assert_body_eq, }; diff --git a/actix-web/src/response/customize_responder.rs b/actix-web/src/response/customize_responder.rs index aad0039e..4cbd96e2 100644 --- a/actix-web/src/response/customize_responder.rs +++ b/actix-web/src/response/customize_responder.rs @@ -175,10 +175,7 @@ mod tests { use super::*; use crate::{ - http::{ - header::{HeaderValue, CONTENT_TYPE}, - StatusCode, - }, + http::header::{HeaderValue, CONTENT_TYPE}, test::TestRequest, }; diff --git a/actix-web/src/response/responder.rs b/actix-web/src/response/responder.rs index 7d0b0e58..90d8f6e5 100644 --- a/actix-web/src/response/responder.rs +++ b/actix-web/src/response/responder.rs @@ -188,15 +188,11 @@ impl_into_string_responder!(Cow<'_, str>); pub(crate) mod tests { use actix_http::body::to_bytes; use actix_service::Service; - use bytes::{Bytes, BytesMut}; use super::*; use crate::{ error, - http::{ - header::{HeaderValue, CONTENT_TYPE}, - StatusCode, - }, + http::header::{HeaderValue, CONTENT_TYPE}, test::{assert_body_eq, init_service, TestRequest}, web, App, }; diff --git a/actix-web/src/response/response.rs b/actix-web/src/response/response.rs index fbd87e10..e16dc0cd 100644 --- a/actix-web/src/response/response.rs +++ b/actix-web/src/response/response.rs @@ -399,7 +399,7 @@ mod tests { use static_assertions::assert_impl_all; use super::*; - use crate::http::header::{HeaderValue, COOKIE}; + use crate::http::header::COOKIE; assert_impl_all!(HttpResponse: Responder); assert_impl_all!(HttpResponse: Responder); diff --git a/actix-web/src/scope.rs b/actix-web/src/scope.rs index e7c4e047..27a2827a 100644 --- a/actix-web/src/scope.rs +++ b/actix-web/src/scope.rs @@ -547,7 +547,6 @@ impl ServiceFactory for ScopeEndpoint { #[cfg(test)] mod tests { - use actix_service::Service; use actix_utils::future::ok; use bytes::Bytes; @@ -559,7 +558,6 @@ mod tests { Method, StatusCode, }, middleware::DefaultHeaders, - service::{ServiceRequest, ServiceResponse}, test::{assert_body_eq, call_service, init_service, read_body, TestRequest}, web, App, HttpMessage, HttpRequest, HttpResponse, }; diff --git a/actix-web/src/service.rs b/actix-web/src/service.rs index 45122483..a1672eba 100644 --- a/actix-web/src/service.rs +++ b/actix-web/src/service.rs @@ -700,7 +700,7 @@ mod tests { use crate::{ guard, http, test::{self, init_service, TestRequest}, - web, App, HttpResponse, + web, App, }; #[actix_rt::test] diff --git a/actix-web/src/test/test_request.rs b/actix-web/src/test/test_request.rs index a3945456..f178d6f4 100644 --- a/actix-web/src/test/test_request.rs +++ b/actix-web/src/test/test_request.rs @@ -350,7 +350,7 @@ mod tests { use std::time::SystemTime; use super::*; - use crate::{http::header, test::init_service, web, App, Error, HttpResponse, Responder}; + use crate::{http::header, test::init_service, web, App, Error, Responder}; #[actix_rt::test] async fn test_basics() { diff --git a/actix-web/src/types/either.rs b/actix-web/src/types/either.rs index db244fd9..7883e89f 100644 --- a/actix-web/src/types/either.rs +++ b/actix-web/src/types/either.rs @@ -287,10 +287,7 @@ mod tests { use serde::{Deserialize, Serialize}; use super::*; - use crate::{ - test::TestRequest, - web::{Form, Json}, - }; + use crate::test::TestRequest; #[derive(Debug, Clone, Serialize, Deserialize)] struct TestForm { diff --git a/actix-web/src/types/form.rs b/actix-web/src/types/form.rs index 7096b1e9..d6381b99 100644 --- a/actix-web/src/types/form.rs +++ b/actix-web/src/types/form.rs @@ -418,7 +418,7 @@ mod tests { use super::*; use crate::{ http::{ - header::{HeaderValue, CONTENT_LENGTH, CONTENT_TYPE}, + header::{HeaderValue, CONTENT_TYPE}, StatusCode, }, test::{assert_body_eq, TestRequest}, diff --git a/actix-web/src/types/payload.rs b/actix-web/src/types/payload.rs index abb4e6b7..e4db37d0 100644 --- a/actix-web/src/types/payload.rs +++ b/actix-web/src/types/payload.rs @@ -440,13 +440,11 @@ impl Future for HttpMessageBody { #[cfg(test)] mod tests { - use bytes::Bytes; - use super::*; use crate::{ - http::{header, StatusCode}, + http::StatusCode, test::{call_service, init_service, read_body, TestRequest}, - web, App, Responder, + App, Responder, }; #[actix_rt::test] diff --git a/awc/src/client/connection.rs b/awc/src/client/connection.rs index 5ed965be..8164e2b5 100644 --- a/awc/src/client/connection.rs +++ b/awc/src/client/connection.rs @@ -380,8 +380,6 @@ mod test { use std::{ future::Future, net, - pin::Pin, - task::{Context, Poll}, time::{Duration, Instant}, }; diff --git a/awc/src/client/connector.rs b/awc/src/client/connector.rs index df6e422f..49da2015 100644 --- a/awc/src/client/connector.rs +++ b/awc/src/client/connector.rs @@ -935,7 +935,6 @@ mod resolver { use std::{cell::RefCell, net::SocketAddr}; use actix_tls::connect::Resolve; - use futures_core::future::LocalBoxFuture; use trust_dns_resolver::{ config::{ResolverConfig, ResolverOpts}, system_conf::read_system_conf, diff --git a/awc/src/client/pool.rs b/awc/src/client/pool.rs index 2cf1f3ac..2938353f 100644 --- a/awc/src/client/pool.rs +++ b/awc/src/client/pool.rs @@ -374,12 +374,11 @@ impl Acquired { #[cfg(test)] mod test { - use std::{cell::Cell, io}; + use std::cell::Cell; use http::Uri; use super::*; - use crate::client::connection::ConnectionType; /// A stream type that always returns pending on async read. /// diff --git a/awc/src/middleware/redirect.rs b/awc/src/middleware/redirect.rs index c38d6ad9..0ea5f174 100644 --- a/awc/src/middleware/redirect.rs +++ b/awc/src/middleware/redirect.rs @@ -303,10 +303,7 @@ mod tests { use actix_web::{web, App, Error, HttpRequest, HttpResponse}; use super::*; - use crate::{ - http::{header::HeaderValue, StatusCode}, - ClientBuilder, - }; + use crate::{http::header::HeaderValue, ClientBuilder}; #[actix_rt::test] async fn basic_redirect() { diff --git a/awc/src/responses/json_body.rs b/awc/src/responses/json_body.rs index 3912324b..e9c03d81 100644 --- a/awc/src/responses/json_body.rs +++ b/awc/src/responses/json_body.rs @@ -118,7 +118,7 @@ mod tests { use static_assertions::assert_impl_all; use super::*; - use crate::{http::header, test::TestResponse}; + use crate::test::TestResponse; assert_impl_all!(JsonBody: Unpin); diff --git a/awc/src/responses/response_body.rs b/awc/src/responses/response_body.rs index 8d9d1274..0ff58341 100644 --- a/awc/src/responses/response_body.rs +++ b/awc/src/responses/response_body.rs @@ -110,7 +110,7 @@ mod tests { use static_assertions::assert_impl_all; use super::*; - use crate::{http::header, test::TestResponse}; + use crate::test::TestResponse; assert_impl_all!(ResponseBody<()>: Unpin); diff --git a/awc/src/test.rs b/awc/src/test.rs index 96ae1f0a..12658317 100644 --- a/awc/src/test.rs +++ b/awc/src/test.rs @@ -103,7 +103,7 @@ mod tests { use actix_http::header::HttpDate; use super::*; - use crate::{cookie, http::header}; + use crate::http::header; #[test] fn test_basics() { From 7f0504e32bf83adae4a46f9c6ca5d06f5dc93785 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Fri, 1 Mar 2024 18:11:30 +0000 Subject: [PATCH 057/151] chore: temp allow #[allow(non_local_definitions)] --- awc/src/client/connector.rs | 5 +++++ awc/src/lib.rs | 1 + 2 files changed, 6 insertions(+) diff --git a/awc/src/client/connector.rs b/awc/src/client/connector.rs index 49da2015..94629b95 100644 --- a/awc/src/client/connector.rs +++ b/awc/src/client/connector.rs @@ -401,6 +401,7 @@ where use actix_tls::connect::Connection; use actix_utils::future::{ready, Ready}; + #[allow(non_local_definitions)] impl IntoConnectionIo for TcpConnection> { fn into_connection_io(self) -> (Box, Protocol) { let io = self.into_parts().0; @@ -451,6 +452,7 @@ where use actix_tls::connect::openssl::{reexports::AsyncSslStream, TlsConnector}; + #[allow(non_local_definitions)] impl IntoConnectionIo for TcpConnection> { fn into_connection_io(self) -> (Box, Protocol) { let sock = self.into_parts().0; @@ -488,6 +490,7 @@ where use actix_tls::connect::rustls_0_20::{reexports::AsyncTlsStream, TlsConnector}; + #[allow(non_local_definitions)] impl IntoConnectionIo for TcpConnection> { fn into_connection_io(self) -> (Box, Protocol) { let sock = self.into_parts().0; @@ -521,6 +524,7 @@ where use actix_tls::connect::rustls_0_21::{reexports::AsyncTlsStream, TlsConnector}; + #[allow(non_local_definitions)] impl IntoConnectionIo for TcpConnection> { fn into_connection_io(self) -> (Box, Protocol) { let sock = self.into_parts().0; @@ -557,6 +561,7 @@ where use actix_tls::connect::rustls_0_22::{reexports::AsyncTlsStream, TlsConnector}; + #[allow(non_local_definitions)] impl IntoConnectionIo for TcpConnection> { fn into_connection_io(self) -> (Box, Protocol) { let sock = self.into_parts().0; diff --git a/awc/src/lib.rs b/awc/src/lib.rs index 253b5161..46048099 100644 --- a/awc/src/lib.rs +++ b/awc/src/lib.rs @@ -102,6 +102,7 @@ #![deny(rust_2018_idioms, nonstandard_style)] #![warn(future_incompatible)] +#![allow(unknown_lints)] // temp: #[allow(non_local_definitions)] #![allow( clippy::type_complexity, clippy::borrow_interior_mutable_const, From f8a0f3e1888664f6e05c6bc97d985e62c9d6635d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 2 Mar 2024 18:24:18 +0000 Subject: [PATCH 058/151] build(deps): bump taiki-e/install-action from 2.27.2 to 2.27.9 (#3297) Bumps [taiki-e/install-action](https://github.com/taiki-e/install-action) from 2.27.2 to 2.27.9. - [Release notes](https://github.com/taiki-e/install-action/releases) - [Changelog](https://github.com/taiki-e/install-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/taiki-e/install-action/compare/v2.27.2...v2.27.9) --- updated-dependencies: - dependency-name: taiki-e/install-action dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Rob Ede --- .github/workflows/ci-post-merge.yml | 6 +++--- .github/workflows/ci.yml | 2 +- .github/workflows/coverage.yml | 2 +- .github/workflows/lint.yml | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci-post-merge.yml b/.github/workflows/ci-post-merge.yml index 4d668415..ad7340ba 100644 --- a/.github/workflows/ci-post-merge.yml +++ b/.github/workflows/ci-post-merge.yml @@ -45,7 +45,7 @@ jobs: toolchain: ${{ matrix.version.version }} - name: Install cargo-hack and cargo-ci-cache-clean - uses: taiki-e/install-action@v2.27.2 + uses: taiki-e/install-action@v2.27.9 with: tool: cargo-hack,cargo-ci-cache-clean @@ -85,7 +85,7 @@ jobs: uses: actions-rust-lang/setup-rust-toolchain@v1.8.0 - name: Install cargo-hack - uses: taiki-e/install-action@v2.27.2 + uses: taiki-e/install-action@v2.27.9 with: tool: cargo-hack @@ -106,7 +106,7 @@ jobs: uses: actions-rust-lang/setup-rust-toolchain@v1.8.0 - name: Install nextest - uses: taiki-e/install-action@v2.27.2 + uses: taiki-e/install-action@v2.27.9 with: tool: nextest diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b40a9f13..cd293f5d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -50,7 +50,7 @@ jobs: toolchain: ${{ matrix.version.version }} - name: Install cargo-hack and cargo-ci-cache-clean - uses: taiki-e/install-action@v2.27.2 + uses: taiki-e/install-action@v2.27.9 with: tool: cargo-hack,cargo-ci-cache-clean diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 180ba35d..053d8c98 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -23,7 +23,7 @@ jobs: components: llvm-tools-preview - name: Install cargo-llvm-cov - uses: taiki-e/install-action@v2.27.2 + uses: taiki-e/install-action@v2.27.9 with: tool: cargo-llvm-cov diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 79f53ce1..90c25b3f 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -82,7 +82,7 @@ jobs: toolchain: nightly-2023-08-25 - name: Install cargo-public-api - uses: taiki-e/install-action@v2.27.2 + uses: taiki-e/install-action@v2.27.9 with: tool: cargo-public-api From 994ea45d91c2b4a0b020105d57c5d63b5869b037 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 2 Mar 2024 18:40:38 +0000 Subject: [PATCH 059/151] build(deps): bump codecov/codecov-action from 4.0.1 to 4.0.2 (#3296) Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 4.0.1 to 4.0.2. - [Release notes](https://github.com/codecov/codecov-action/releases) - [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/codecov/codecov-action/compare/v4.0.1...v4.0.2) --- updated-dependencies: - dependency-name: codecov/codecov-action dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Rob Ede --- .github/workflows/coverage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 053d8c98..bdc6f588 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -31,7 +31,7 @@ jobs: run: cargo llvm-cov --workspace --all-features --codecov --output-path codecov.json - name: Upload coverage to Codecov - uses: codecov/codecov-action@v4.0.1 + uses: codecov/codecov-action@v4.0.2 with: files: codecov.json fail_ci_if_error: true From c10f05a8672e53ecada8ec2f15bf9d927efade57 Mon Sep 17 00:00:00 2001 From: LoveSy Date: Sun, 3 Mar 2024 23:50:16 +0800 Subject: [PATCH 060/151] Add `unicode` feature to switch between `regex` and `regex-lite` crates as a trade-off between full unicode support and binary size (#3291) * - Add `unicode` feature to switch between `regex` and `regex-lite` as a trade-off between full unicode support and binary size. * Update CHANGES.md * Update CHANGES.md * refactor: move regexset code selection to own module * docs: add docs within RegexSet module * chore: restore manifests * test: ensure all actix-router codepaths are tested --------- Co-authored-by: Rob Ede --- .github/workflows/ci.yml | 1 + actix-router/CHANGES.md | 1 + actix-router/Cargo.toml | 9 ++- actix-router/src/lib.rs | 1 + actix-router/src/regex_set.rs | 66 +++++++++++++++++++ actix-router/src/resource.rs | 15 +++-- actix-web/CHANGES.md | 1 + actix-web/Cargo.toml | 10 ++- .../src/http/header/content_disposition.rs | 3 + actix-web/src/middleware/logger.rs | 22 ++++--- actix-web/src/middleware/normalize.rs | 3 + 11 files changed, 112 insertions(+), 20 deletions(-) create mode 100644 actix-router/src/regex_set.rs diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cd293f5d..7a7adb24 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -70,6 +70,7 @@ jobs: shell: bash run: | set -e + cargo test --lib --tests -p=actix-router --no-default-features cargo test --lib --tests -p=actix-router --all-features cargo test --lib --tests -p=actix-http --all-features cargo test --lib --tests -p=actix-web --features=rustls-0_20,rustls-0_21,rustls-0_22,openssl -- --skip=test_reading_deflate_encoding_large_random_rustls diff --git a/actix-router/CHANGES.md b/actix-router/CHANGES.md index a80b15e6..8aa3c863 100644 --- a/actix-router/CHANGES.md +++ b/actix-router/CHANGES.md @@ -2,6 +2,7 @@ ## Unreleased +- Add `unicode` crate feature (on-by-default) to switch between `regex` and `regex-lite` as a trade-off between full unicode support and binary size. - Minimum supported Rust version (MSRV) is now 1.72. ## 0.5.2 diff --git a/actix-router/Cargo.toml b/actix-router/Cargo.toml index de39944c..0b02e84b 100644 --- a/actix-router/Cargo.toml +++ b/actix-router/Cargo.toml @@ -17,12 +17,16 @@ name = "actix_router" path = "src/lib.rs" [features] -default = ["http"] +default = ["http", "unicode"] +http = ["dep:http"] +unicode = ["dep:regex"] [dependencies] bytestring = ">=0.1.5, <2" +cfg-if = "1" http = { version = "0.2.7", optional = true } -regex = "1.5" +regex = { version = "1.5", optional = true } +regex-lite = "0.1" serde = "1" tracing = { version = "0.1.30", default-features = false, features = ["log"] } @@ -35,6 +39,7 @@ percent-encoding = "2.1" [[bench]] name = "router" harness = false +required-features = ["unicode"] [[bench]] name = "quoter" diff --git a/actix-router/src/lib.rs b/actix-router/src/lib.rs index f1009343..c4d0d2c8 100644 --- a/actix-router/src/lib.rs +++ b/actix-router/src/lib.rs @@ -10,6 +10,7 @@ mod de; mod path; mod pattern; mod quoter; +mod regex_set; mod resource; mod resource_path; mod router; diff --git a/actix-router/src/regex_set.rs b/actix-router/src/regex_set.rs new file mode 100644 index 00000000..48f38df2 --- /dev/null +++ b/actix-router/src/regex_set.rs @@ -0,0 +1,66 @@ +//! Abstraction over `regex` and `regex-lite` depending on whether we have `unicode` crate feature +//! enabled. + +use cfg_if::cfg_if; +#[cfg(feature = "unicode")] +pub(crate) use regex::{escape, Regex}; +#[cfg(not(feature = "unicode"))] +pub(crate) use regex_lite::{escape, Regex}; + +#[cfg(feature = "unicode")] +#[derive(Debug, Clone)] +pub(crate) struct RegexSet(regex::RegexSet); + +#[cfg(not(feature = "unicode"))] +#[derive(Debug, Clone)] +pub(crate) struct RegexSet(Vec); + +impl RegexSet { + /// Create a new regex set. + /// + /// # Panics + /// + /// Panics if any path patterns are malformed. + pub(crate) fn new(re_set: Vec) -> Self { + cfg_if! { + if #[cfg(feature = "unicode")] { + Self(regex::RegexSet::new(re_set).unwrap()) + } else { + Self(re_set.iter().map(|re| Regex::new(re).unwrap()).collect()) + } + } + } + + /// Create a new empty regex set. + pub(crate) fn empty() -> Self { + cfg_if! { + if #[cfg(feature = "unicode")] { + Self(regex::RegexSet::empty()) + } else { + Self(Vec::new()) + } + } + } + + /// Returns true if regex set matches `path`. + pub(crate) fn is_match(&self, path: &str) -> bool { + cfg_if! { + if #[cfg(feature = "unicode")] { + self.0.is_match(path) + } else { + self.0.iter().any(|re| re.is_match(path)) + } + } + } + + /// Returns index within `path` of first match. + pub(crate) fn first_match_idx(&self, path: &str) -> Option { + cfg_if! { + if #[cfg(feature = "unicode")] { + self.0.matches(path).into_iter().next() + } else { + Some(self.0.iter().enumerate().find(|(_, re)| re.is_match(path))?.0) + } + } + } +} diff --git a/actix-router/src/resource.rs b/actix-router/src/resource.rs index abd13221..3a102945 100644 --- a/actix-router/src/resource.rs +++ b/actix-router/src/resource.rs @@ -5,10 +5,13 @@ use std::{ mem, }; -use regex::{escape, Regex, RegexSet}; use tracing::error; -use crate::{path::PathItem, IntoPatterns, Patterns, Resource, ResourcePath}; +use crate::{ + path::PathItem, + regex_set::{escape, Regex, RegexSet}, + IntoPatterns, Patterns, Resource, ResourcePath, +}; const MAX_DYNAMIC_SEGMENTS: usize = 16; @@ -233,7 +236,7 @@ enum PatternSegment { Var(String), } -#[derive(Clone, Debug)] +#[derive(Debug, Clone)] #[allow(clippy::large_enum_variant)] enum PatternType { /// Single constant/literal segment. @@ -603,7 +606,7 @@ impl ResourceDef { PatternType::Dynamic(re, _) => Some(re.captures(path)?[1].len()), PatternType::DynamicSet(re, params) => { - let idx = re.matches(path).into_iter().next()?; + let idx = re.first_match_idx(path)?; let (ref pattern, _) = params[idx]; Some(pattern.captures(path)?[1].len()) } @@ -706,7 +709,7 @@ impl ResourceDef { PatternType::DynamicSet(re, params) => { let path = path.unprocessed(); - let (pattern, names) = match re.matches(path).into_iter().next() { + let (pattern, names) = match re.first_match_idx(path) { Some(idx) => ¶ms[idx], _ => return false, }; @@ -870,7 +873,7 @@ impl ResourceDef { } } - let pattern_re_set = RegexSet::new(re_set).unwrap(); + let pattern_re_set = RegexSet::new(re_set); let segments = segments.unwrap_or_default(); ( diff --git a/actix-web/CHANGES.md b/actix-web/CHANGES.md index 88215293..8fa7ae27 100644 --- a/actix-web/CHANGES.md +++ b/actix-web/CHANGES.md @@ -4,6 +4,7 @@ ### Changed +- Add `unicode` crate feature (on-by-default) to switch between `regex` and `regex-lite` as a trade-off between full unicode support and binary size. - Minimum supported Rust version (MSRV) is now 1.72. ## 4.5.1 diff --git a/actix-web/Cargo.toml b/actix-web/Cargo.toml index b045589b..aafc3dda 100644 --- a/actix-web/Cargo.toml +++ b/actix-web/Cargo.toml @@ -40,7 +40,7 @@ name = "actix_web" path = "src/lib.rs" [features] -default = ["macros", "compress-brotli", "compress-gzip", "compress-zstd", "cookies", "http2"] +default = ["macros", "compress-brotli", "compress-gzip", "compress-zstd", "cookies", "http2", "unicode"] # Brotli algorithm content-encoding support compress-brotli = ["actix-http/compress-brotli", "__compress"] @@ -72,6 +72,9 @@ rustls-0_21 = ["http2", "actix-http/rustls-0_21", "actix-tls/accept", "actix-tls # TLS via Rustls v0.22 rustls-0_22 = ["http2", "actix-http/rustls-0_22", "actix-tls/accept", "actix-tls/rustls-0_22"] +# Full unicode support +unicode = ["dep:regex", "actix-router/unicode"] + # Internal (PRIVATE!) features used to aid testing and checking feature status. # Don't rely on these whatsoever. They may disappear at anytime. __compress = [] @@ -89,7 +92,7 @@ actix-utils = "3" actix-tls = { version = "3.3", default-features = false, optional = true } actix-http = { version = "3.6", features = ["ws"] } -actix-router = "0.5" +actix-router = { version = "0.5", default-features = false, features = ["http"] } actix-web-codegen = { version = "4.2", optional = true } ahash = "0.8" @@ -107,7 +110,8 @@ log = "0.4" mime = "0.3" once_cell = "1.5" pin-project-lite = "0.2.7" -regex = "1.5.5" +regex = { version = "1.5.5", optional = true } +regex-lite = "0.1" serde = "1.0" serde_json = "1.0" serde_urlencoded = "0.7" diff --git a/actix-web/src/http/header/content_disposition.rs b/actix-web/src/http/header/content_disposition.rs index 0606f5ae..9725cd19 100644 --- a/actix-web/src/http/header/content_disposition.rs +++ b/actix-web/src/http/header/content_disposition.rs @@ -13,7 +13,10 @@ use std::fmt::{self, Write}; use once_cell::sync::Lazy; +#[cfg(feature = "unicode")] use regex::Regex; +#[cfg(not(feature = "unicode"))] +use regex_lite::Regex; use super::{ExtendedValue, Header, TryIntoHeaderValue, Writer}; use crate::http::header; diff --git a/actix-web/src/middleware/logger.rs b/actix-web/src/middleware/logger.rs index ce42c3af..dc1b0239 100644 --- a/actix-web/src/middleware/logger.rs +++ b/actix-web/src/middleware/logger.rs @@ -18,7 +18,10 @@ use bytes::Bytes; use futures_core::ready; use log::{debug, warn}; use pin_project_lite::pin_project; -use regex::{Regex, RegexSet}; +#[cfg(feature = "unicode")] +use regex::Regex; +#[cfg(not(feature = "unicode"))] +use regex_lite::Regex; use time::{format_description::well_known::Rfc3339, OffsetDateTime}; use crate::{ @@ -87,7 +90,7 @@ pub struct Logger(Rc); struct Inner { format: Format, exclude: HashSet, - exclude_regex: RegexSet, + exclude_regex: Vec, log_target: Cow<'static, str>, } @@ -97,7 +100,7 @@ impl Logger { Logger(Rc::new(Inner { format: Format::new(format), exclude: HashSet::new(), - exclude_regex: RegexSet::empty(), + exclude_regex: Vec::new(), log_target: Cow::Borrowed(module_path!()), })) } @@ -114,10 +117,7 @@ impl Logger { /// Ignore and do not log access info for paths that match regex. pub fn exclude_regex>(mut self, path: T) -> Self { let inner = Rc::get_mut(&mut self.0).unwrap(); - let mut patterns = inner.exclude_regex.patterns().to_vec(); - patterns.push(path.into()); - let regex_set = RegexSet::new(patterns).unwrap(); - inner.exclude_regex = regex_set; + inner.exclude_regex.push(Regex::new(&path.into()).unwrap()); self } @@ -240,7 +240,7 @@ impl Default for Logger { Logger(Rc::new(Inner { format: Format::default(), exclude: HashSet::new(), - exclude_regex: RegexSet::empty(), + exclude_regex: Vec::new(), log_target: Cow::Borrowed(module_path!()), })) } @@ -300,7 +300,11 @@ where fn call(&self, req: ServiceRequest) -> Self::Future { let excluded = self.inner.exclude.contains(req.path()) - || self.inner.exclude_regex.is_match(req.path()); + || self + .inner + .exclude_regex + .iter() + .any(|r| r.is_match(req.path())); if excluded { LoggerResponse { diff --git a/actix-web/src/middleware/normalize.rs b/actix-web/src/middleware/normalize.rs index 3f20431c..482107ec 100644 --- a/actix-web/src/middleware/normalize.rs +++ b/actix-web/src/middleware/normalize.rs @@ -4,7 +4,10 @@ use actix_http::uri::{PathAndQuery, Uri}; use actix_service::{Service, Transform}; use actix_utils::future::{ready, Ready}; use bytes::Bytes; +#[cfg(feature = "unicode")] use regex::Regex; +#[cfg(not(feature = "unicode"))] +use regex_lite::Regex; use crate::{ service::{ServiceRequest, ServiceResponse}, From 49020e79ae7b7abc2cd98a0e2ef20aecdf6a975e Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Sun, 3 Mar 2024 22:18:29 +0000 Subject: [PATCH 061/151] chore: update base64 to v0.22 --- actix-http/Cargo.toml | 2 +- actix-web/CHANGES.md | 5 ++++- awc/Cargo.toml | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/actix-http/Cargo.toml b/actix-http/Cargo.toml index e8f315cb..7e1a8c55 100644 --- a/actix-http/Cargo.toml +++ b/actix-http/Cargo.toml @@ -106,7 +106,7 @@ h2 = { version = "0.3.24", optional = true } # websockets local-channel = { version = "0.1", optional = true } -base64 = { version = "0.21", optional = true } +base64 = { version = "0.22", optional = true } rand = { version = "0.8", optional = true } sha1 = { version = "0.10", optional = true } diff --git a/actix-web/CHANGES.md b/actix-web/CHANGES.md index 8fa7ae27..c6454ed6 100644 --- a/actix-web/CHANGES.md +++ b/actix-web/CHANGES.md @@ -2,9 +2,12 @@ ## Unreleased -### Changed +### Added - Add `unicode` crate feature (on-by-default) to switch between `regex` and `regex-lite` as a trade-off between full unicode support and binary size. + +### Changed + - Minimum supported Rust version (MSRV) is now 1.72. ## 4.5.1 diff --git a/awc/Cargo.toml b/awc/Cargo.toml index 14d93ac3..ab88ca81 100644 --- a/awc/Cargo.toml +++ b/awc/Cargo.toml @@ -79,7 +79,7 @@ actix-rt = { version = "2.1", default-features = false } actix-tls = { version = "3.3", features = ["connect", "uri"] } actix-utils = "3" -base64 = "0.21" +base64 = "0.22" bytes = "1" cfg-if = "1" derive_more = "0.99.5" From a4df623b0c8995e44af2218da884901f0c3cb47a Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Sun, 3 Mar 2024 23:43:54 +0000 Subject: [PATCH 062/151] chore: bump env_logger to v0.11 --- actix-files/Cargo.toml | 2 +- actix-http/Cargo.toml | 2 +- actix-web-actors/Cargo.toml | 2 +- actix-web/Cargo.toml | 2 +- actix-web/src/route.rs | 1 + awc/Cargo.toml | 2 +- 6 files changed, 6 insertions(+), 5 deletions(-) diff --git a/actix-files/Cargo.toml b/actix-files/Cargo.toml index 098d71bd..3d82f8a7 100644 --- a/actix-files/Cargo.toml +++ b/actix-files/Cargo.toml @@ -47,5 +47,5 @@ actix-server = { version = "2.2", optional = true } # ensure matching tokio-urin actix-rt = "2.7" actix-test = "0.1" actix-web = "4" -env_logger = "0.10" +env_logger = "0.11" tempfile = "3.2" diff --git a/actix-http/Cargo.toml b/actix-http/Cargo.toml index 7e1a8c55..38969e90 100644 --- a/actix-http/Cargo.toml +++ b/actix-http/Cargo.toml @@ -127,7 +127,7 @@ actix-web = "4" async-stream = "0.3" criterion = { version = "0.5", features = ["html_reports"] } divan = "0.1.8" -env_logger = "0.10" +env_logger = "0.11" futures-util = { version = "0.3.17", default-features = false, features = ["alloc"] } memchr = "2.4" once_cell = "1.9" diff --git a/actix-web-actors/Cargo.toml b/actix-web-actors/Cargo.toml index 0263e9b2..114ec5a8 100644 --- a/actix-web-actors/Cargo.toml +++ b/actix-web-actors/Cargo.toml @@ -32,6 +32,6 @@ actix-test = "0.1" awc = { version = "3", default-features = false } actix-web = { version = "4", features = ["macros"] } -env_logger = "0.10" +env_logger = "0.11" futures-util = { version = "0.3.17", default-features = false, features = ["std"] } mime = "0.3" diff --git a/actix-web/Cargo.toml b/actix-web/Cargo.toml index aafc3dda..aea8856b 100644 --- a/actix-web/Cargo.toml +++ b/actix-web/Cargo.toml @@ -128,7 +128,7 @@ awc = { version = "3", features = ["openssl"] } brotli = "3.3.3" const-str = "0.5" criterion = { version = "0.5", features = ["html_reports"] } -env_logger = "0.10" +env_logger = "0.11" flate2 = "1.0.13" futures-util = { version = "0.3.17", default-features = false, features = ["std"] } rand = "0.8" diff --git a/actix-web/src/route.rs b/actix-web/src/route.rs index a46c1fdd..261e6b9a 100644 --- a/actix-web/src/route.rs +++ b/actix-web/src/route.rs @@ -92,6 +92,7 @@ pub struct RouteService { } impl RouteService { + // TODO(breaking): remove pass by ref mut #[allow(clippy::needless_pass_by_ref_mut)] pub fn check(&self, req: &mut ServiceRequest) -> bool { let guard_ctx = req.guard_ctx(); diff --git a/awc/Cargo.toml b/awc/Cargo.toml index ab88ca81..da9e78ae 100644 --- a/awc/Cargo.toml +++ b/awc/Cargo.toml @@ -118,7 +118,7 @@ actix-web = { version = "4", features = ["openssl"] } brotli = "3.3.3" const-str = "0.5" -env_logger = "0.10" +env_logger = "0.11" flate2 = "1.0.13" futures-util = { version = "0.3.17", default-features = false } static_assertions = "1.1" From 58dd00bccfbc353a8459ec3c9d576cbac1c0c13b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 4 Mar 2024 02:18:38 +0000 Subject: [PATCH 063/151] build(deps): bump codecov/codecov-action from 4.0.2 to 4.1.0 (#3302) Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 4.0.2 to 4.1.0. - [Release notes](https://github.com/codecov/codecov-action/releases) - [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/codecov/codecov-action/compare/v4.0.2...v4.1.0) --- updated-dependencies: - dependency-name: codecov/codecov-action dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/coverage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index bdc6f588..67edc483 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -31,7 +31,7 @@ jobs: run: cargo llvm-cov --workspace --all-features --codecov --output-path codecov.json - name: Upload coverage to Codecov - uses: codecov/codecov-action@v4.0.2 + uses: codecov/codecov-action@v4.1.0 with: files: codecov.json fail_ci_if_error: true From d2150a3312d43ac4dcfe9afed1320bb18bcbf680 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 4 Mar 2024 02:18:50 +0000 Subject: [PATCH 064/151] build(deps): bump taiki-e/install-action from 2.27.9 to 2.28.0 (#3301) Bumps [taiki-e/install-action](https://github.com/taiki-e/install-action) from 2.27.9 to 2.28.0. - [Release notes](https://github.com/taiki-e/install-action/releases) - [Changelog](https://github.com/taiki-e/install-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/taiki-e/install-action/compare/v2.27.9...v2.28.0) --- updated-dependencies: - dependency-name: taiki-e/install-action dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/ci-post-merge.yml | 6 +++--- .github/workflows/ci.yml | 2 +- .github/workflows/coverage.yml | 2 +- .github/workflows/lint.yml | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci-post-merge.yml b/.github/workflows/ci-post-merge.yml index ad7340ba..17738483 100644 --- a/.github/workflows/ci-post-merge.yml +++ b/.github/workflows/ci-post-merge.yml @@ -45,7 +45,7 @@ jobs: toolchain: ${{ matrix.version.version }} - name: Install cargo-hack and cargo-ci-cache-clean - uses: taiki-e/install-action@v2.27.9 + uses: taiki-e/install-action@v2.28.0 with: tool: cargo-hack,cargo-ci-cache-clean @@ -85,7 +85,7 @@ jobs: uses: actions-rust-lang/setup-rust-toolchain@v1.8.0 - name: Install cargo-hack - uses: taiki-e/install-action@v2.27.9 + uses: taiki-e/install-action@v2.28.0 with: tool: cargo-hack @@ -106,7 +106,7 @@ jobs: uses: actions-rust-lang/setup-rust-toolchain@v1.8.0 - name: Install nextest - uses: taiki-e/install-action@v2.27.9 + uses: taiki-e/install-action@v2.28.0 with: tool: nextest diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7a7adb24..ac76476a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -50,7 +50,7 @@ jobs: toolchain: ${{ matrix.version.version }} - name: Install cargo-hack and cargo-ci-cache-clean - uses: taiki-e/install-action@v2.27.9 + uses: taiki-e/install-action@v2.28.0 with: tool: cargo-hack,cargo-ci-cache-clean diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 67edc483..65fb25ca 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -23,7 +23,7 @@ jobs: components: llvm-tools-preview - name: Install cargo-llvm-cov - uses: taiki-e/install-action@v2.27.9 + uses: taiki-e/install-action@v2.28.0 with: tool: cargo-llvm-cov diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 90c25b3f..468cc4d0 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -82,7 +82,7 @@ jobs: toolchain: nightly-2023-08-25 - name: Install cargo-public-api - uses: taiki-e/install-action@v2.27.9 + uses: taiki-e/install-action@v2.28.0 with: tool: cargo-public-api From ba7bddeadc30a40c1e0a53049c3f726f0f661f4d Mon Sep 17 00:00:00 2001 From: Nelson Dominguez Date: Wed, 6 Mar 2024 01:17:18 +0100 Subject: [PATCH 065/151] docs(actix-web): add missing 'that' to doc comments for Compress middleware (#3304) docs(actix-web): add missing 'that' in doc comments for Compress middleware --- actix-web/src/middleware/compress.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/actix-web/src/middleware/compress.rs b/actix-web/src/middleware/compress.rs index 8ff518cd..943868d2 100644 --- a/actix-web/src/middleware/compress.rs +++ b/actix-web/src/middleware/compress.rs @@ -33,7 +33,7 @@ use crate::{ /// considered in this selection process. /// /// # Pre-compressed Payload -/// If you are serving some data is already using a compressed representation (e.g., a gzip +/// If you are serving some data that is already using a compressed representation (e.g., a gzip /// compressed HTML file from disk) you can signal this to `Compress` by setting an appropriate /// `Content-Encoding` header. In addition to preventing double compressing the payload, this header /// is required by the spec when using compressed representations and will inform the client that From 52b0d5fbf90d6aecb25fc8b00aa23ff367486931 Mon Sep 17 00:00:00 2001 From: LoveSy Date: Mon, 11 Mar 2024 23:34:04 +0800 Subject: [PATCH 066/151] CI: Free space before test (#3303) --- .github/workflows/ci-post-merge.yml | 3 ++ scripts/free-disk-space.sh | 53 +++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100755 scripts/free-disk-space.sh diff --git a/.github/workflows/ci-post-merge.yml b/.github/workflows/ci-post-merge.yml index 17738483..3889c258 100644 --- a/.github/workflows/ci-post-merge.yml +++ b/.github/workflows/ci-post-merge.yml @@ -81,6 +81,9 @@ jobs: steps: - uses: actions/checkout@v4 + - name: Free Disk Space + run: ./scripts/free-disk-space.sh + - name: Install Rust uses: actions-rust-lang/setup-rust-toolchain@v1.8.0 diff --git a/scripts/free-disk-space.sh b/scripts/free-disk-space.sh new file mode 100755 index 00000000..2946cfcf --- /dev/null +++ b/scripts/free-disk-space.sh @@ -0,0 +1,53 @@ +#!/usr/bin/env bash + +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# The Azure provided machines typically have the following disk allocation: +# Total space: 85GB +# Allocated: 67 GB +# Free: 17 GB +# This script frees up 28 GB of disk space by deleting unneeded packages and +# large directories. +# The Flink end to end tests download and generate more than 17 GB of files, +# causing unpredictable behavior and build failures. + +echo "==============================================================================" +echo "Freeing up disk space on CI system" +echo "==============================================================================" + +echo "Listing 100 largest packages" +dpkg-query -Wf '${Installed-Size}\t${Package}\n' | sort -n | tail -n 100 +df -h + +echo "Removing large packages" +sudo apt-get remove -y '^dotnet-.*' +sudo apt-get remove -y 'php.*' +sudo apt-get remove -y '^mongodb-.*' +sudo apt-get remove -y '^mysql-.*' +sudo apt-get remove -y azure-cli google-cloud-sdk hhvm google-chrome-stable firefox powershell mono-devel libgl1-mesa-dri +sudo apt-get autoremove -y +sudo apt-get clean +df -h + +echo "Removing large directories" +sudo rm -rf /usr/share/dotnet/ +sudo rm -rf /usr/local/graalvm/ +sudo rm -rf /usr/local/.ghcup/ +sudo rm -rf /usr/local/share/powershell +sudo rm -rf /usr/local/share/chromium +sudo rm -rf /usr/local/lib/android +sudo rm -rf /usr/local/lib/node_modules +df -h From 9c3b4c61f73df122ea377ead3d50e688dc5227db Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 16 Mar 2024 11:14:22 +0000 Subject: [PATCH 067/151] build(deps): bump taiki-e/install-action from 2.28.0 to 2.28.10 (#3305) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/ci-post-merge.yml | 6 +++--- .github/workflows/ci.yml | 2 +- .github/workflows/coverage.yml | 2 +- .github/workflows/lint.yml | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci-post-merge.yml b/.github/workflows/ci-post-merge.yml index 3889c258..2b5678f8 100644 --- a/.github/workflows/ci-post-merge.yml +++ b/.github/workflows/ci-post-merge.yml @@ -45,7 +45,7 @@ jobs: toolchain: ${{ matrix.version.version }} - name: Install cargo-hack and cargo-ci-cache-clean - uses: taiki-e/install-action@v2.28.0 + uses: taiki-e/install-action@v2.28.10 with: tool: cargo-hack,cargo-ci-cache-clean @@ -88,7 +88,7 @@ jobs: uses: actions-rust-lang/setup-rust-toolchain@v1.8.0 - name: Install cargo-hack - uses: taiki-e/install-action@v2.28.0 + uses: taiki-e/install-action@v2.28.10 with: tool: cargo-hack @@ -109,7 +109,7 @@ jobs: uses: actions-rust-lang/setup-rust-toolchain@v1.8.0 - name: Install nextest - uses: taiki-e/install-action@v2.28.0 + uses: taiki-e/install-action@v2.28.10 with: tool: nextest diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ac76476a..d22df5e8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -50,7 +50,7 @@ jobs: toolchain: ${{ matrix.version.version }} - name: Install cargo-hack and cargo-ci-cache-clean - uses: taiki-e/install-action@v2.28.0 + uses: taiki-e/install-action@v2.28.10 with: tool: cargo-hack,cargo-ci-cache-clean diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 65fb25ca..f0d3b251 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -23,7 +23,7 @@ jobs: components: llvm-tools-preview - name: Install cargo-llvm-cov - uses: taiki-e/install-action@v2.28.0 + uses: taiki-e/install-action@v2.28.10 with: tool: cargo-llvm-cov diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 468cc4d0..940d68a5 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -82,7 +82,7 @@ jobs: toolchain: nightly-2023-08-25 - name: Install cargo-public-api - uses: taiki-e/install-action@v2.28.0 + uses: taiki-e/install-action@v2.28.10 with: tool: cargo-public-api From 0383f4bdd1210e726143ca1ebcf01169b67a4b6c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Mar 2024 02:47:10 +0000 Subject: [PATCH 068/151] build(deps): bump taiki-e/install-action from 2.28.10 to 2.28.16 (#3312) Bumps [taiki-e/install-action](https://github.com/taiki-e/install-action) from 2.28.10 to 2.28.16. - [Release notes](https://github.com/taiki-e/install-action/releases) - [Changelog](https://github.com/taiki-e/install-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/taiki-e/install-action/compare/v2.28.10...v2.28.16) --- updated-dependencies: - dependency-name: taiki-e/install-action dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/ci-post-merge.yml | 6 +++--- .github/workflows/ci.yml | 2 +- .github/workflows/coverage.yml | 2 +- .github/workflows/lint.yml | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci-post-merge.yml b/.github/workflows/ci-post-merge.yml index 2b5678f8..1678bbff 100644 --- a/.github/workflows/ci-post-merge.yml +++ b/.github/workflows/ci-post-merge.yml @@ -45,7 +45,7 @@ jobs: toolchain: ${{ matrix.version.version }} - name: Install cargo-hack and cargo-ci-cache-clean - uses: taiki-e/install-action@v2.28.10 + uses: taiki-e/install-action@v2.28.16 with: tool: cargo-hack,cargo-ci-cache-clean @@ -88,7 +88,7 @@ jobs: uses: actions-rust-lang/setup-rust-toolchain@v1.8.0 - name: Install cargo-hack - uses: taiki-e/install-action@v2.28.10 + uses: taiki-e/install-action@v2.28.16 with: tool: cargo-hack @@ -109,7 +109,7 @@ jobs: uses: actions-rust-lang/setup-rust-toolchain@v1.8.0 - name: Install nextest - uses: taiki-e/install-action@v2.28.10 + uses: taiki-e/install-action@v2.28.16 with: tool: nextest diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d22df5e8..9ce792b3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -50,7 +50,7 @@ jobs: toolchain: ${{ matrix.version.version }} - name: Install cargo-hack and cargo-ci-cache-clean - uses: taiki-e/install-action@v2.28.10 + uses: taiki-e/install-action@v2.28.16 with: tool: cargo-hack,cargo-ci-cache-clean diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index f0d3b251..2c394b32 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -23,7 +23,7 @@ jobs: components: llvm-tools-preview - name: Install cargo-llvm-cov - uses: taiki-e/install-action@v2.28.10 + uses: taiki-e/install-action@v2.28.16 with: tool: cargo-llvm-cov diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 940d68a5..4468708b 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -82,7 +82,7 @@ jobs: toolchain: nightly-2023-08-25 - name: Install cargo-public-api - uses: taiki-e/install-action@v2.28.10 + uses: taiki-e/install-action@v2.28.16 with: tool: cargo-public-api From db76ad0f6139160f86411d7107dbbf27954d9d3d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 25 Mar 2024 15:03:40 +0000 Subject: [PATCH 069/151] build(deps): bump taiki-e/install-action from 2.28.16 to 2.29.7 (#3316) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/ci-post-merge.yml | 6 +++--- .github/workflows/ci.yml | 2 +- .github/workflows/coverage.yml | 2 +- .github/workflows/lint.yml | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci-post-merge.yml b/.github/workflows/ci-post-merge.yml index 1678bbff..cc03fe71 100644 --- a/.github/workflows/ci-post-merge.yml +++ b/.github/workflows/ci-post-merge.yml @@ -45,7 +45,7 @@ jobs: toolchain: ${{ matrix.version.version }} - name: Install cargo-hack and cargo-ci-cache-clean - uses: taiki-e/install-action@v2.28.16 + uses: taiki-e/install-action@v2.29.7 with: tool: cargo-hack,cargo-ci-cache-clean @@ -88,7 +88,7 @@ jobs: uses: actions-rust-lang/setup-rust-toolchain@v1.8.0 - name: Install cargo-hack - uses: taiki-e/install-action@v2.28.16 + uses: taiki-e/install-action@v2.29.7 with: tool: cargo-hack @@ -109,7 +109,7 @@ jobs: uses: actions-rust-lang/setup-rust-toolchain@v1.8.0 - name: Install nextest - uses: taiki-e/install-action@v2.28.16 + uses: taiki-e/install-action@v2.29.7 with: tool: nextest diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9ce792b3..5a97f56d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -50,7 +50,7 @@ jobs: toolchain: ${{ matrix.version.version }} - name: Install cargo-hack and cargo-ci-cache-clean - uses: taiki-e/install-action@v2.28.16 + uses: taiki-e/install-action@v2.29.7 with: tool: cargo-hack,cargo-ci-cache-clean diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 2c394b32..ecb01267 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -23,7 +23,7 @@ jobs: components: llvm-tools-preview - name: Install cargo-llvm-cov - uses: taiki-e/install-action@v2.28.16 + uses: taiki-e/install-action@v2.29.7 with: tool: cargo-llvm-cov diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 4468708b..25339678 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -82,7 +82,7 @@ jobs: toolchain: nightly-2023-08-25 - name: Install cargo-public-api - uses: taiki-e/install-action@v2.28.16 + uses: taiki-e/install-action@v2.29.7 with: tool: cargo-public-api From 09851f4a548a4c2758685d8811254cf3f4c80f10 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 Apr 2024 01:38:30 +0000 Subject: [PATCH 070/151] build(deps): bump taiki-e/install-action from 2.29.7 to 2.32.0 (#3322) Bumps [taiki-e/install-action](https://github.com/taiki-e/install-action) from 2.29.7 to 2.32.0. - [Release notes](https://github.com/taiki-e/install-action/releases) - [Changelog](https://github.com/taiki-e/install-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/taiki-e/install-action/compare/v2.29.7...v2.32.0) --- updated-dependencies: - dependency-name: taiki-e/install-action dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/ci-post-merge.yml | 6 +++--- .github/workflows/ci.yml | 2 +- .github/workflows/coverage.yml | 2 +- .github/workflows/lint.yml | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci-post-merge.yml b/.github/workflows/ci-post-merge.yml index cc03fe71..63d670dc 100644 --- a/.github/workflows/ci-post-merge.yml +++ b/.github/workflows/ci-post-merge.yml @@ -45,7 +45,7 @@ jobs: toolchain: ${{ matrix.version.version }} - name: Install cargo-hack and cargo-ci-cache-clean - uses: taiki-e/install-action@v2.29.7 + uses: taiki-e/install-action@v2.32.0 with: tool: cargo-hack,cargo-ci-cache-clean @@ -88,7 +88,7 @@ jobs: uses: actions-rust-lang/setup-rust-toolchain@v1.8.0 - name: Install cargo-hack - uses: taiki-e/install-action@v2.29.7 + uses: taiki-e/install-action@v2.32.0 with: tool: cargo-hack @@ -109,7 +109,7 @@ jobs: uses: actions-rust-lang/setup-rust-toolchain@v1.8.0 - name: Install nextest - uses: taiki-e/install-action@v2.29.7 + uses: taiki-e/install-action@v2.32.0 with: tool: nextest diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5a97f56d..04814588 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -50,7 +50,7 @@ jobs: toolchain: ${{ matrix.version.version }} - name: Install cargo-hack and cargo-ci-cache-clean - uses: taiki-e/install-action@v2.29.7 + uses: taiki-e/install-action@v2.32.0 with: tool: cargo-hack,cargo-ci-cache-clean diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index ecb01267..22522776 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -23,7 +23,7 @@ jobs: components: llvm-tools-preview - name: Install cargo-llvm-cov - uses: taiki-e/install-action@v2.29.7 + uses: taiki-e/install-action@v2.32.0 with: tool: cargo-llvm-cov diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 25339678..188d1216 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -82,7 +82,7 @@ jobs: toolchain: nightly-2023-08-25 - name: Install cargo-public-api - uses: taiki-e/install-action@v2.29.7 + uses: taiki-e/install-action@v2.32.0 with: tool: cargo-public-api From ccfa8d3817704b05747f9c3c5839827378d1aab1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 Apr 2024 01:41:43 +0000 Subject: [PATCH 071/151] build(deps): bump codecov/codecov-action from 4.1.0 to 4.1.1 (#3321) Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 4.1.0 to 4.1.1. - [Release notes](https://github.com/codecov/codecov-action/releases) - [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/codecov/codecov-action/compare/v4.1.0...v4.1.1) --- updated-dependencies: - dependency-name: codecov/codecov-action dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/coverage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 22522776..1886d9c0 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -31,7 +31,7 @@ jobs: run: cargo llvm-cov --workspace --all-features --codecov --output-path codecov.json - name: Upload coverage to Codecov - uses: codecov/codecov-action@v4.1.0 + uses: codecov/codecov-action@v4.1.1 with: files: codecov.json fail_ci_if_error: true From 76b2b2734b5765e3e7878fcabab8073b91ddcb03 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 8 Apr 2024 08:17:45 +0100 Subject: [PATCH 072/151] build(deps): bump codecov/codecov-action from 4.1.1 to 4.2.0 (#3326) Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 4.1.1 to 4.2.0. - [Release notes](https://github.com/codecov/codecov-action/releases) - [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/codecov/codecov-action/compare/v4.1.1...v4.2.0) --- updated-dependencies: - dependency-name: codecov/codecov-action dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/coverage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 1886d9c0..004bc9a6 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -31,7 +31,7 @@ jobs: run: cargo llvm-cov --workspace --all-features --codecov --output-path codecov.json - name: Upload coverage to Codecov - uses: codecov/codecov-action@v4.1.1 + uses: codecov/codecov-action@v4.2.0 with: files: codecov.json fail_ci_if_error: true From 5a5486b484d4b9c4e9527b9a00411375d776ed21 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 8 Apr 2024 08:19:03 +0100 Subject: [PATCH 073/151] build(deps): bump taiki-e/install-action from 2.32.0 to 2.32.9 (#3325) Bumps [taiki-e/install-action](https://github.com/taiki-e/install-action) from 2.32.0 to 2.32.9. - [Release notes](https://github.com/taiki-e/install-action/releases) - [Changelog](https://github.com/taiki-e/install-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/taiki-e/install-action/compare/v2.32.0...v2.32.9) --- updated-dependencies: - dependency-name: taiki-e/install-action dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/ci-post-merge.yml | 6 +++--- .github/workflows/ci.yml | 2 +- .github/workflows/coverage.yml | 2 +- .github/workflows/lint.yml | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci-post-merge.yml b/.github/workflows/ci-post-merge.yml index 63d670dc..6b330b4e 100644 --- a/.github/workflows/ci-post-merge.yml +++ b/.github/workflows/ci-post-merge.yml @@ -45,7 +45,7 @@ jobs: toolchain: ${{ matrix.version.version }} - name: Install cargo-hack and cargo-ci-cache-clean - uses: taiki-e/install-action@v2.32.0 + uses: taiki-e/install-action@v2.32.9 with: tool: cargo-hack,cargo-ci-cache-clean @@ -88,7 +88,7 @@ jobs: uses: actions-rust-lang/setup-rust-toolchain@v1.8.0 - name: Install cargo-hack - uses: taiki-e/install-action@v2.32.0 + uses: taiki-e/install-action@v2.32.9 with: tool: cargo-hack @@ -109,7 +109,7 @@ jobs: uses: actions-rust-lang/setup-rust-toolchain@v1.8.0 - name: Install nextest - uses: taiki-e/install-action@v2.32.0 + uses: taiki-e/install-action@v2.32.9 with: tool: nextest diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 04814588..757ceaa8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -50,7 +50,7 @@ jobs: toolchain: ${{ matrix.version.version }} - name: Install cargo-hack and cargo-ci-cache-clean - uses: taiki-e/install-action@v2.32.0 + uses: taiki-e/install-action@v2.32.9 with: tool: cargo-hack,cargo-ci-cache-clean diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 004bc9a6..c9727012 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -23,7 +23,7 @@ jobs: components: llvm-tools-preview - name: Install cargo-llvm-cov - uses: taiki-e/install-action@v2.32.0 + uses: taiki-e/install-action@v2.32.9 with: tool: cargo-llvm-cov diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 188d1216..6af754c4 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -82,7 +82,7 @@ jobs: toolchain: nightly-2023-08-25 - name: Install cargo-public-api - uses: taiki-e/install-action@v2.32.0 + uses: taiki-e/install-action@v2.32.9 with: tool: cargo-public-api From d98938b1250293a98913d5c0a53f7a0cc6fe0002 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 15 Apr 2024 02:02:30 +0100 Subject: [PATCH 074/151] build(deps): bump taiki-e/install-action from 2.32.9 to 2.32.17 (#3332) Bumps [taiki-e/install-action](https://github.com/taiki-e/install-action) from 2.32.9 to 2.32.17. - [Release notes](https://github.com/taiki-e/install-action/releases) - [Changelog](https://github.com/taiki-e/install-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/taiki-e/install-action/compare/v2.32.9...v2.32.17) --- updated-dependencies: - dependency-name: taiki-e/install-action dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/ci-post-merge.yml | 6 +++--- .github/workflows/ci.yml | 2 +- .github/workflows/coverage.yml | 2 +- .github/workflows/lint.yml | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci-post-merge.yml b/.github/workflows/ci-post-merge.yml index 6b330b4e..55202ba6 100644 --- a/.github/workflows/ci-post-merge.yml +++ b/.github/workflows/ci-post-merge.yml @@ -45,7 +45,7 @@ jobs: toolchain: ${{ matrix.version.version }} - name: Install cargo-hack and cargo-ci-cache-clean - uses: taiki-e/install-action@v2.32.9 + uses: taiki-e/install-action@v2.32.17 with: tool: cargo-hack,cargo-ci-cache-clean @@ -88,7 +88,7 @@ jobs: uses: actions-rust-lang/setup-rust-toolchain@v1.8.0 - name: Install cargo-hack - uses: taiki-e/install-action@v2.32.9 + uses: taiki-e/install-action@v2.32.17 with: tool: cargo-hack @@ -109,7 +109,7 @@ jobs: uses: actions-rust-lang/setup-rust-toolchain@v1.8.0 - name: Install nextest - uses: taiki-e/install-action@v2.32.9 + uses: taiki-e/install-action@v2.32.17 with: tool: nextest diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 757ceaa8..2488f749 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -50,7 +50,7 @@ jobs: toolchain: ${{ matrix.version.version }} - name: Install cargo-hack and cargo-ci-cache-clean - uses: taiki-e/install-action@v2.32.9 + uses: taiki-e/install-action@v2.32.17 with: tool: cargo-hack,cargo-ci-cache-clean diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index c9727012..20aeeeb4 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -23,7 +23,7 @@ jobs: components: llvm-tools-preview - name: Install cargo-llvm-cov - uses: taiki-e/install-action@v2.32.9 + uses: taiki-e/install-action@v2.32.17 with: tool: cargo-llvm-cov diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 6af754c4..b0ac537a 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -82,7 +82,7 @@ jobs: toolchain: nightly-2023-08-25 - name: Install cargo-public-api - uses: taiki-e/install-action@v2.32.9 + uses: taiki-e/install-action@v2.32.17 with: tool: cargo-public-api From ba7fd048b601e32039ba13d95271f110980ff434 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 15 Apr 2024 02:02:44 +0100 Subject: [PATCH 075/151] build(deps): bump codecov/codecov-action from 4.2.0 to 4.3.0 (#3331) Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 4.2.0 to 4.3.0. - [Release notes](https://github.com/codecov/codecov-action/releases) - [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/codecov/codecov-action/compare/v4.2.0...v4.3.0) --- updated-dependencies: - dependency-name: codecov/codecov-action dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/coverage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 20aeeeb4..ac5143d5 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -31,7 +31,7 @@ jobs: run: cargo llvm-cov --workspace --all-features --codecov --output-path codecov.json - name: Upload coverage to Codecov - uses: codecov/codecov-action@v4.2.0 + uses: codecov/codecov-action@v4.3.0 with: files: codecov.json fail_ci_if_error: true From 7fc73d58a9de68f0dfcc809d263dc1ffea20da28 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Thu, 2 May 2024 03:22:13 +0100 Subject: [PATCH 076/151] ci: fix public api --- .github/workflows/lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index b0ac537a..a10c2411 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -79,7 +79,7 @@ jobs: - name: Install Rust uses: actions-rust-lang/setup-rust-toolchain@v1.8.0 with: - toolchain: nightly-2023-08-25 + toolchain: nightly-2024-04-26 - name: Install cargo-public-api uses: taiki-e/install-action@v2.32.17 From 7f15a95d8e15c3b09f64a301aa33ac89a82863a2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 2 May 2024 03:22:59 +0100 Subject: [PATCH 077/151] build(deps): bump JamesIves/github-pages-deploy-action from 4.5.0 to 4.6.0 (#3339) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/upload-doc.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/upload-doc.yml b/.github/workflows/upload-doc.yml index 963b7f6b..6352e44d 100644 --- a/.github/workflows/upload-doc.yml +++ b/.github/workflows/upload-doc.yml @@ -35,7 +35,7 @@ jobs: run: echo '' > target/doc/index.html - name: Deploy to GitHub Pages - uses: JamesIves/github-pages-deploy-action@v4.5.0 + uses: JamesIves/github-pages-deploy-action@v4.6.0 with: folder: target/doc single-commit: true From babac131d4bf2f9d8e343a77ff75d496a5249d10 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 2 May 2024 02:39:28 +0000 Subject: [PATCH 078/151] build(deps): bump taiki-e/install-action from 2.32.17 to 2.33.12 (#3347) Bumps [taiki-e/install-action](https://github.com/taiki-e/install-action) from 2.32.17 to 2.33.12. - [Release notes](https://github.com/taiki-e/install-action/releases) - [Changelog](https://github.com/taiki-e/install-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/taiki-e/install-action/compare/v2.32.17...v2.33.12) --- updated-dependencies: - dependency-name: taiki-e/install-action dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/ci-post-merge.yml | 6 +++--- .github/workflows/ci.yml | 2 +- .github/workflows/coverage.yml | 2 +- .github/workflows/lint.yml | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci-post-merge.yml b/.github/workflows/ci-post-merge.yml index 55202ba6..10670ab3 100644 --- a/.github/workflows/ci-post-merge.yml +++ b/.github/workflows/ci-post-merge.yml @@ -45,7 +45,7 @@ jobs: toolchain: ${{ matrix.version.version }} - name: Install cargo-hack and cargo-ci-cache-clean - uses: taiki-e/install-action@v2.32.17 + uses: taiki-e/install-action@v2.33.12 with: tool: cargo-hack,cargo-ci-cache-clean @@ -88,7 +88,7 @@ jobs: uses: actions-rust-lang/setup-rust-toolchain@v1.8.0 - name: Install cargo-hack - uses: taiki-e/install-action@v2.32.17 + uses: taiki-e/install-action@v2.33.12 with: tool: cargo-hack @@ -109,7 +109,7 @@ jobs: uses: actions-rust-lang/setup-rust-toolchain@v1.8.0 - name: Install nextest - uses: taiki-e/install-action@v2.32.17 + uses: taiki-e/install-action@v2.33.12 with: tool: nextest diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2488f749..b052cebd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -50,7 +50,7 @@ jobs: toolchain: ${{ matrix.version.version }} - name: Install cargo-hack and cargo-ci-cache-clean - uses: taiki-e/install-action@v2.32.17 + uses: taiki-e/install-action@v2.33.12 with: tool: cargo-hack,cargo-ci-cache-clean diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index ac5143d5..5698e271 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -23,7 +23,7 @@ jobs: components: llvm-tools-preview - name: Install cargo-llvm-cov - uses: taiki-e/install-action@v2.32.17 + uses: taiki-e/install-action@v2.33.12 with: tool: cargo-llvm-cov diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index a10c2411..fd0b96c7 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -82,7 +82,7 @@ jobs: toolchain: nightly-2024-04-26 - name: Install cargo-public-api - uses: taiki-e/install-action@v2.32.17 + uses: taiki-e/install-action@v2.33.12 with: tool: cargo-public-api From e4b9d17355d079160416cf8f86a5a87ddbc2e9b2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 6 May 2024 03:27:31 +0100 Subject: [PATCH 079/151] build(deps): bump codecov/codecov-action from 4.3.0 to 4.3.1 (#3354) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/coverage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 5698e271..5c228c97 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -31,7 +31,7 @@ jobs: run: cargo llvm-cov --workspace --all-features --codecov --output-path codecov.json - name: Upload coverage to Codecov - uses: codecov/codecov-action@v4.3.0 + uses: codecov/codecov-action@v4.3.1 with: files: codecov.json fail_ci_if_error: true From bb65628de5b01bd0a5fa9552b80b72729340a628 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 6 May 2024 03:28:35 +0100 Subject: [PATCH 080/151] build(deps): bump taiki-e/install-action from 2.33.12 to 2.33.16 (#3355) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/ci-post-merge.yml | 6 +++--- .github/workflows/ci.yml | 2 +- .github/workflows/coverage.yml | 2 +- .github/workflows/lint.yml | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci-post-merge.yml b/.github/workflows/ci-post-merge.yml index 10670ab3..9da5de5f 100644 --- a/.github/workflows/ci-post-merge.yml +++ b/.github/workflows/ci-post-merge.yml @@ -45,7 +45,7 @@ jobs: toolchain: ${{ matrix.version.version }} - name: Install cargo-hack and cargo-ci-cache-clean - uses: taiki-e/install-action@v2.33.12 + uses: taiki-e/install-action@v2.33.16 with: tool: cargo-hack,cargo-ci-cache-clean @@ -88,7 +88,7 @@ jobs: uses: actions-rust-lang/setup-rust-toolchain@v1.8.0 - name: Install cargo-hack - uses: taiki-e/install-action@v2.33.12 + uses: taiki-e/install-action@v2.33.16 with: tool: cargo-hack @@ -109,7 +109,7 @@ jobs: uses: actions-rust-lang/setup-rust-toolchain@v1.8.0 - name: Install nextest - uses: taiki-e/install-action@v2.33.12 + uses: taiki-e/install-action@v2.33.16 with: tool: nextest diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b052cebd..85854bdf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -50,7 +50,7 @@ jobs: toolchain: ${{ matrix.version.version }} - name: Install cargo-hack and cargo-ci-cache-clean - uses: taiki-e/install-action@v2.33.12 + uses: taiki-e/install-action@v2.33.16 with: tool: cargo-hack,cargo-ci-cache-clean diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 5c228c97..9ec33ee5 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -23,7 +23,7 @@ jobs: components: llvm-tools-preview - name: Install cargo-llvm-cov - uses: taiki-e/install-action@v2.33.12 + uses: taiki-e/install-action@v2.33.16 with: tool: cargo-llvm-cov diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index fd0b96c7..9c684682 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -82,7 +82,7 @@ jobs: toolchain: nightly-2024-04-26 - name: Install cargo-public-api - uses: taiki-e/install-action@v2.33.12 + uses: taiki-e/install-action@v2.33.16 with: tool: cargo-public-api From c1a638861445cf1aee36d5fd7130ea01b16e3eca Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Mon, 6 May 2024 06:03:44 +0100 Subject: [PATCH 081/151] refactor: address clippy warnings --- actix-http/src/h1/dispatcher.rs | 2 +- actix-http/src/h2/dispatcher.rs | 2 +- actix-multipart/src/form/mod.rs | 3 ++- actix-router/src/path.rs | 8 ++------ actix-web/src/config.rs | 2 +- actix-web/src/resource.rs | 2 +- 6 files changed, 8 insertions(+), 11 deletions(-) diff --git a/actix-http/src/h1/dispatcher.rs b/actix-http/src/h1/dispatcher.rs index a24a6bb0..00b51360 100644 --- a/actix-http/src/h1/dispatcher.rs +++ b/actix-http/src/h1/dispatcher.rs @@ -706,7 +706,7 @@ where req.head_mut().peer_addr = *this.peer_addr; - req.conn_data = this.conn_data.clone(); + req.conn_data.clone_from(this.conn_data); match this.codec.message_type() { // request has no payload diff --git a/actix-http/src/h2/dispatcher.rs b/actix-http/src/h2/dispatcher.rs index 97ceb51e..400476c8 100644 --- a/actix-http/src/h2/dispatcher.rs +++ b/actix-http/src/h2/dispatcher.rs @@ -126,7 +126,7 @@ where head.headers = parts.headers.into(); head.peer_addr = this.peer_addr; - req.conn_data = this.conn_data.clone(); + req.conn_data.clone_from(&this.conn_data); let fut = this.flow.service.call(req); let config = this.config.clone(); diff --git a/actix-multipart/src/form/mod.rs b/actix-multipart/src/form/mod.rs index 67adfd4b..451b103f 100644 --- a/actix-multipart/src/form/mod.rs +++ b/actix-multipart/src/form/mod.rs @@ -313,7 +313,8 @@ where let entry = field_limits .entry(field.name().to_owned()) .or_insert_with(|| T::limit(field.name())); - limits.field_limit_remaining = entry.to_owned(); + + limits.field_limit_remaining.clone_from(entry); T::handle_field(&req, field, &mut limits, &mut state).await?; diff --git a/actix-router/src/path.rs b/actix-router/src/path.rs index 467420cd..9031ab76 100644 --- a/actix-router/src/path.rs +++ b/actix-router/src/path.rs @@ -154,15 +154,11 @@ impl Path { None } - /// Get matched parameter by name. + /// Returns matched parameter by name. /// /// If keyed parameter is not available empty string is used as default value. pub fn query(&self, key: &str) -> &str { - if let Some(s) = self.get(key) { - s - } else { - "" - } + self.get(key).unwrap_or_default() } /// Return iterator to items in parameter container. diff --git a/actix-web/src/config.rs b/actix-web/src/config.rs index fba0c271..5e8b056f 100644 --- a/actix-web/src/config.rs +++ b/actix-web/src/config.rs @@ -148,7 +148,7 @@ impl AppConfig { #[cfg(test)] pub(crate) fn set_host(&mut self, host: &str) { - self.host = host.to_owned(); + host.clone_into(&mut self.host); } } diff --git a/actix-web/src/resource.rs b/actix-web/src/resource.rs index 291d6746..00555b7b 100644 --- a/actix-web/src/resource.rs +++ b/actix-web/src/resource.rs @@ -771,7 +771,7 @@ mod tests { data3: web::Data| { assert_eq!(**data1, 10); assert_eq!(**data2, '*'); - let error = std::f64::EPSILON; + let error = f64::EPSILON; assert!((**data3 - 1.0).abs() < error); HttpResponse::Ok() }, From 44f502e0503f15f7f03ec3c1e14668bbd9b60b93 Mon Sep 17 00:00:00 2001 From: asonix Date: Mon, 13 May 2024 23:57:58 -0500 Subject: [PATCH 082/151] awc: gate TlsConnectorService behind any feature that uses it (#3350) --- awc/CHANGES.md | 1 + awc/src/client/connector.rs | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/awc/CHANGES.md b/awc/CHANGES.md index 507c8a08..46939a7c 100644 --- a/awc/CHANGES.md +++ b/awc/CHANGES.md @@ -3,6 +3,7 @@ ## Unreleased - Minimum supported Rust version (MSRV) is now 1.72. +- Fix warning on 1.78 due to unused TlsConnectorService struct ## 3.4.0 diff --git a/awc/src/client/connector.rs b/awc/src/client/connector.rs index 94629b95..b66e13ec 100644 --- a/awc/src/client/connector.rs +++ b/awc/src/client/connector.rs @@ -649,6 +649,14 @@ where /// service for establish tcp connection and do client tls handshake. /// operation is canceled when timeout limit reached. +#[cfg(any( + feature = "dangerous-h2c", + feature = "openssl", + feature = "rustls-0_20", + feature = "rustls-0_21", + feature = "rustls-0_22-webpki-roots", + feature = "rustls-0_22-native-roots", +))] struct TlsConnectorService { /// TCP connection is canceled on `TcpConnectorInnerService`'s timeout setting. tcp_service: Tcp, @@ -659,6 +667,14 @@ struct TlsConnectorService { timeout: Duration, } +#[cfg(any( + feature = "dangerous-h2c", + feature = "openssl", + feature = "rustls-0_20", + feature = "rustls-0_21", + feature = "rustls-0_22-webpki-roots", + feature = "rustls-0_22-native-roots", +))] impl Service for TlsConnectorService where Tcp: From 3c9a930bd172eba69366c2bf1e5035395c6ebc49 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Tue, 14 May 2024 06:30:58 +0100 Subject: [PATCH 083/151] ci: rely more on justfiles (#3365) --- .cargo/config.toml | 4 --- .github/workflows/ci-post-merge.yml | 36 ++------------------ .github/workflows/ci.yml | 38 ++++++++++----------- Cargo.toml | 2 ++ actix-multipart-derive/Cargo.toml | 9 ++--- actix-web-codegen/Cargo.toml | 9 ++--- justfile | 51 ++++++++++++++++++++++++++--- 7 files changed, 79 insertions(+), 70 deletions(-) diff --git a/.cargo/config.toml b/.cargo/config.toml index 350a924d..6d5a8b81 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -8,7 +8,3 @@ ci-check-default = "hack --workspace check" ci-check-default-tests = "check --workspace --tests" ci-check-all-feature-powerset="hack --workspace --feature-powerset --skip=__compress,experimental-io-uring check" ci-check-all-feature-powerset-linux="hack --workspace --feature-powerset --skip=__compress check" - -# testing -ci-doctest-default = "test --workspace --doc --no-fail-fast -- --nocapture" -ci-doctest = "test --workspace --all-features --doc --no-fail-fast -- --nocapture" diff --git a/.github/workflows/ci-post-merge.yml b/.github/workflows/ci-post-merge.yml index 9da5de5f..d5cb6e62 100644 --- a/.github/workflows/ci-post-merge.yml +++ b/.github/workflows/ci-post-merge.yml @@ -44,10 +44,10 @@ jobs: with: toolchain: ${{ matrix.version.version }} - - name: Install cargo-hack and cargo-ci-cache-clean + - name: Install just, cargo-hack, cargo-nextest, cargo-ci-cache-clean uses: taiki-e/install-action@v2.33.16 with: - tool: cargo-hack,cargo-ci-cache-clean + tool: just,cargo-hack,cargo-nextest,cargo-ci-cache-clean - name: check minimal run: cargo ci-check-min @@ -57,19 +57,7 @@ jobs: - name: tests timeout-minutes: 60 - shell: bash - run: | - set -e - cargo test --lib --tests -p=actix-router --all-features - cargo test --lib --tests -p=actix-http --all-features - cargo test --lib --tests -p=actix-web --features=rustls-0_20,rustls-0_21,rustls-0_22,openssl -- --skip=test_reading_deflate_encoding_large_random_rustls - cargo test --lib --tests -p=actix-web-codegen --all-features - cargo test --lib --tests -p=awc --all-features - cargo test --lib --tests -p=actix-http-test --all-features - cargo test --lib --tests -p=actix-test --all-features - cargo test --lib --tests -p=actix-files - cargo test --lib --tests -p=actix-multipart --all-features - cargo test --lib --tests -p=actix-web-actors --all-features + run: just test - name: CI cache clean run: cargo-ci-cache-clean @@ -97,21 +85,3 @@ jobs: - name: check feature combinations run: cargo ci-check-all-feature-powerset-linux - - nextest: - name: nextest - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - - name: Install Rust - uses: actions-rust-lang/setup-rust-toolchain@v1.8.0 - - - name: Install nextest - uses: taiki-e/install-action@v2.33.16 - with: - tool: nextest - - - name: Test with cargo-nextest - run: cargo nextest run diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 85854bdf..d7db0be4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,7 +16,13 @@ concurrency: cancel-in-progress: true jobs: + read_msrv: + name: Read MSRV + uses: actions-rust-lang/msrv/.github/workflows/msrv.yml@main + build_and_test: + needs: read_msrv + strategy: fail-fast: false matrix: @@ -26,7 +32,7 @@ jobs: - { name: macOS, os: macos-latest, triple: x86_64-apple-darwin } - { name: Windows, os: windows-latest, triple: x86_64-pc-windows-msvc } version: - - { name: msrv, version: 1.72.0 } + - { name: msrv, version: "${{ needs.read_msrv.outputs.msrv }}" } - { name: stable, version: stable } name: ${{ matrix.target.name }} / ${{ matrix.version.name }} @@ -49,15 +55,14 @@ jobs: with: toolchain: ${{ matrix.version.version }} - - name: Install cargo-hack and cargo-ci-cache-clean + - name: Install just, cargo-hack, cargo-nextest, cargo-ci-cache-clean uses: taiki-e/install-action@v2.33.16 with: - tool: cargo-hack,cargo-ci-cache-clean + tool: just,cargo-hack,cargo-nextest,cargo-ci-cache-clean - name: workaround MSRV issues if: matrix.version.name == 'msrv' - run: | - cargo update -p=clap --precise=4.4.18 + run: just downgrade-for-msrv - name: check minimal run: cargo ci-check-min @@ -67,20 +72,7 @@ jobs: - name: tests timeout-minutes: 60 - shell: bash - run: | - set -e - cargo test --lib --tests -p=actix-router --no-default-features - cargo test --lib --tests -p=actix-router --all-features - cargo test --lib --tests -p=actix-http --all-features - cargo test --lib --tests -p=actix-web --features=rustls-0_20,rustls-0_21,rustls-0_22,openssl -- --skip=test_reading_deflate_encoding_large_random_rustls - cargo test --lib --tests -p=actix-web-codegen --all-features - cargo test --lib --tests -p=awc --all-features - cargo test --lib --tests -p=actix-http-test --all-features - cargo test --lib --tests -p=actix-test --all-features - cargo test --lib --tests -p=actix-files - cargo test --lib --tests -p=actix-multipart --all-features - cargo test --lib --tests -p=actix-web-actors --all-features + run: just test - name: CI cache clean run: cargo-ci-cache-clean @@ -112,6 +104,10 @@ jobs: with: toolchain: nightly + - name: Install just + uses: taiki-e/install-action@v2.33.16 + with: + tool: just + - name: doc tests - run: cargo ci-doctest - timeout-minutes: 60 + run: just test-docs diff --git a/Cargo.toml b/Cargo.toml index 9efeda4d..19d5dd11 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,6 +15,8 @@ members = [ ] [workspace.package] +homepage = "https://actix.rs" +repository = "https://github.com/actix/actix-web" license = "MIT OR Apache-2.0" edition = "2021" rust-version = "1.72" diff --git a/actix-multipart-derive/Cargo.toml b/actix-multipart-derive/Cargo.toml index 2f049a3f..e978864a 100644 --- a/actix-multipart-derive/Cargo.toml +++ b/actix-multipart-derive/Cargo.toml @@ -4,10 +4,11 @@ version = "0.6.1" authors = ["Jacob Halsey "] description = "Multipart form derive macro for Actix Web" keywords = ["http", "web", "framework", "async", "futures"] -homepage = "https://actix.rs" -repository = "https://github.com/actix/actix-web" -license = "MIT OR Apache-2.0" -edition = "2021" +homepage.workspace = true +repository.workspace = true +license.workspace = true +edition.workspace = true +rust-version.workspace = true [package.metadata.docs.rs] rustdoc-args = ["--cfg", "docsrs"] diff --git a/actix-web-codegen/Cargo.toml b/actix-web-codegen/Cargo.toml index 7039ea7d..4a45d4fe 100644 --- a/actix-web-codegen/Cargo.toml +++ b/actix-web-codegen/Cargo.toml @@ -2,14 +2,15 @@ name = "actix-web-codegen" version = "4.2.2" description = "Routing and runtime macros for Actix Web" -homepage = "https://actix.rs" -repository = "https://github.com/actix/actix-web" authors = [ "Nikolay Kim ", "Rob Ede ", ] -license = "MIT OR Apache-2.0" -edition = "2021" +homepage.workspace = true +repository.workspace = true +license.workspace = true +edition.workspace = true +rust-version.workspace = true [lib] proc-macro = true diff --git a/justfile b/justfile index 42979f18..d92f4bd3 100644 --- a/justfile +++ b/justfile @@ -6,14 +6,57 @@ fmt: cargo +nightly fmt npx -y prettier --write $(fd --type=file --hidden --extension=md --extension=yml) +# Downgrade dev-dependencies necessary to run MSRV checks/tests. +[private] +downgrade-for-msrv: + cargo update -p=clap --precise=4.4.18 + +msrv := ``` + cargo metadata --format-version=1 \ + | jq -r 'first(.packages[] | select(.source == null and .rust_version)) | .rust_version' \ + | sed -E 's/^1\.([0-9]{2})$/1\.\1\.0/' +``` +msrv_rustup := "+" + msrv + +non_linux_all_features_list := ``` + cargo metadata --format-version=1 \ + | jq '.packages[] | select(.source == null) | .features | keys' \ + | jq -r --slurp \ + --arg exclusions "tokio-uring,io-uring,experimental-io-uring" \ + 'add | unique | . - ($exclusions | split(",")) | join(",")' +``` + +all_crate_features := if os() == "linux" { + "--all-features" +} else { + "--features='" + non_linux_all_features_list + "'" +} + +# Test workspace using MSRV. +test-msrv: downgrade-for-msrv (test msrv_rustup) + +# Test workspace code. +test toolchain="": + cargo {{ toolchain }} test --lib --tests -p=actix-web-codegen --all-features + cargo {{ toolchain }} test --lib --tests -p=actix-multipart-derive --all-features + cargo {{ toolchain }} nextest run -p=actix-router --no-default-features + cargo {{ toolchain }} nextest run --workspace --exclude=actix-web-codegen --exclude=actix-multipart-derive {{ all_crate_features }} --filter-expr="not test(test_reading_deflate_encoding_large_random_rustls)" + +# Test workspace docs. +test-docs toolchain="": && doc + cargo {{ toolchain }} test --doc --workspace {{ all_crate_features }} --no-fail-fast -- --nocapture + +# Test workspace. +test-all toolchain="": (test toolchain) (test-docs toolchain) + # Document crates in workspace. -doc: - RUSTDOCFLAGS="--cfg=docsrs" cargo +nightly doc --no-deps --workspace --features=rustls,openssl +doc *args: + RUSTDOCFLAGS="--cfg=docsrs -Dwarnings" cargo +nightly doc --no-deps --workspace {{ all_crate_features }} {{ args }} # Document crates in workspace and watch for changes. doc-watch: - RUSTDOCFLAGS="--cfg=docsrs" cargo +nightly doc --no-deps --workspace --features=rustls,openssl --open - cargo watch -- RUSTDOCFLAGS="--cfg=docsrs" cargo +nightly doc --no-deps --workspace --features=rustls,openssl + @just doc --open + cargo watch -- just doc # Update READMEs from crate root documentation. update-readmes: && fmt From 33c47c0ba918e87b35de6ba566ef98341672e21a Mon Sep 17 00:00:00 2001 From: asonix Date: Tue, 14 May 2024 00:45:35 -0500 Subject: [PATCH 084/151] Fix type confusion in some scenarios (#3348) * Fix type confusion in some scenarios When the feature for rustls 0.22 is enabled, and rustls 0.23 is also present in a project, there suddently exist multiple paths for errors when building middleware chains due to the use of two consecutive `?` operators without specifying the intermediate error type. This commit addresses the issue by removing the first `?`, so that the first error type will always be known, and the second `?` always has a well defined implementation. * Add CHANGES entry about type confusion --------- Co-authored-by: Rob Ede --- actix-web/CHANGES.md | 1 + actix-web/src/app_service.rs | 5 +++-- actix-web/src/scope.rs | 5 +++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/actix-web/CHANGES.md b/actix-web/CHANGES.md index c6454ed6..3300a6ff 100644 --- a/actix-web/CHANGES.md +++ b/actix-web/CHANGES.md @@ -9,6 +9,7 @@ ### Changed - Minimum supported Rust version (MSRV) is now 1.72. +- Avoid type confusion in rare circumstances ## 4.5.1 diff --git a/actix-web/src/app_service.rs b/actix-web/src/app_service.rs index f2dca954..65a6ed87 100644 --- a/actix-web/src/app_service.rs +++ b/actix-web/src/app_service.rs @@ -263,8 +263,9 @@ impl ServiceFactory for AppRoutingFactory { let guards = guards.borrow_mut().take().unwrap_or_default(); let factory_fut = factory.new_service(()); async move { - let service = factory_fut.await?; - Ok((path, guards, service)) + factory_fut + .await + .map(move |service| (path, guards, service)) } })); diff --git a/actix-web/src/scope.rs b/actix-web/src/scope.rs index 27a2827a..adc9f75d 100644 --- a/actix-web/src/scope.rs +++ b/actix-web/src/scope.rs @@ -470,8 +470,9 @@ impl ServiceFactory for ScopeFactory { let guards = guards.borrow_mut().take().unwrap_or_default(); let factory_fut = factory.new_service(()); async move { - let service = factory_fut.await?; - Ok((path, guards, service)) + factory_fut + .await + .map(move |service| (path, guards, service)) } })); From c20603fc83ff8d706d9ef3381400e65c17db52e6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 14 May 2024 05:50:32 +0000 Subject: [PATCH 085/151] build(deps): bump taiki-e/install-action from 2.33.16 to 2.33.22 (#3364) Bumps [taiki-e/install-action](https://github.com/taiki-e/install-action) from 2.33.16 to 2.33.22. - [Release notes](https://github.com/taiki-e/install-action/releases) - [Changelog](https://github.com/taiki-e/install-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/taiki-e/install-action/compare/v2.33.16...v2.33.22) --- updated-dependencies: - dependency-name: taiki-e/install-action dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/ci-post-merge.yml | 4 ++-- .github/workflows/ci.yml | 4 ++-- .github/workflows/coverage.yml | 2 +- .github/workflows/lint.yml | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci-post-merge.yml b/.github/workflows/ci-post-merge.yml index d5cb6e62..40829d8e 100644 --- a/.github/workflows/ci-post-merge.yml +++ b/.github/workflows/ci-post-merge.yml @@ -45,7 +45,7 @@ jobs: toolchain: ${{ matrix.version.version }} - name: Install just, cargo-hack, cargo-nextest, cargo-ci-cache-clean - uses: taiki-e/install-action@v2.33.16 + uses: taiki-e/install-action@v2.33.22 with: tool: just,cargo-hack,cargo-nextest,cargo-ci-cache-clean @@ -76,7 +76,7 @@ jobs: uses: actions-rust-lang/setup-rust-toolchain@v1.8.0 - name: Install cargo-hack - uses: taiki-e/install-action@v2.33.16 + uses: taiki-e/install-action@v2.33.22 with: tool: cargo-hack diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d7db0be4..c1d959fb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -56,7 +56,7 @@ jobs: toolchain: ${{ matrix.version.version }} - name: Install just, cargo-hack, cargo-nextest, cargo-ci-cache-clean - uses: taiki-e/install-action@v2.33.16 + uses: taiki-e/install-action@v2.33.22 with: tool: just,cargo-hack,cargo-nextest,cargo-ci-cache-clean @@ -105,7 +105,7 @@ jobs: toolchain: nightly - name: Install just - uses: taiki-e/install-action@v2.33.16 + uses: taiki-e/install-action@v2.33.22 with: tool: just diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 9ec33ee5..943f6322 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -23,7 +23,7 @@ jobs: components: llvm-tools-preview - name: Install cargo-llvm-cov - uses: taiki-e/install-action@v2.33.16 + uses: taiki-e/install-action@v2.33.22 with: tool: cargo-llvm-cov diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 9c684682..03b25ecd 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -82,7 +82,7 @@ jobs: toolchain: nightly-2024-04-26 - name: Install cargo-public-api - uses: taiki-e/install-action@v2.33.16 + uses: taiki-e/install-action@v2.33.22 with: tool: cargo-public-api From fff45b28f4219b3c11f40a839649d60ee4e8750e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 14 May 2024 08:58:05 +0000 Subject: [PATCH 086/151] build(deps): update brotli requirement from 3.3.3 to 6.0.0 (#3353) * build(deps): update brotli requirement from 3.3.3 to 6.0.0 Updates the requirements on [brotli](https://github.com/dropbox/rust-brotli) to permit the latest version. - [Release notes](https://github.com/dropbox/rust-brotli/releases) - [Commits](https://github.com/dropbox/rust-brotli/compare/3.3.3...6.0.0) --- updated-dependencies: - dependency-name: brotli dependency-type: direct:production ... Signed-off-by: dependabot[bot] * docs: update changelogs --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Rob Ede --- actix-http/CHANGES.md | 1 + actix-http/Cargo.toml | 2 +- actix-web/CHANGES.md | 6 +++++- actix-web/Cargo.toml | 2 +- awc/CHANGES.md | 2 +- awc/Cargo.toml | 2 +- 6 files changed, 10 insertions(+), 5 deletions(-) diff --git a/actix-http/CHANGES.md b/actix-http/CHANGES.md index fddd1c2c..69957506 100644 --- a/actix-http/CHANGES.md +++ b/actix-http/CHANGES.md @@ -4,6 +4,7 @@ ### Changed +- Update `brotli` dependency to `6`. - Minimum supported Rust version (MSRV) is now 1.72. ## 3.6.0 diff --git a/actix-http/Cargo.toml b/actix-http/Cargo.toml index 38969e90..05de2cb8 100644 --- a/actix-http/Cargo.toml +++ b/actix-http/Cargo.toml @@ -114,7 +114,7 @@ sha1 = { version = "0.10", optional = true } actix-tls = { version = "3.3", default-features = false, optional = true } # compress-* -brotli = { version = "3.3.3", optional = true } +brotli = { version = "6", optional = true } flate2 = { version = "1.0.13", optional = true } zstd = { version = "0.13", optional = true } diff --git a/actix-web/CHANGES.md b/actix-web/CHANGES.md index 3300a6ff..ea996769 100644 --- a/actix-web/CHANGES.md +++ b/actix-web/CHANGES.md @@ -8,8 +8,12 @@ ### Changed +- Update `brotli` dependency to `6`. - Minimum supported Rust version (MSRV) is now 1.72. -- Avoid type confusion in rare circumstances + +### Fixed + +- Avoid type confusion with `rustls` in some circumstances. ## 4.5.1 diff --git a/actix-web/Cargo.toml b/actix-web/Cargo.toml index aea8856b..b4c71381 100644 --- a/actix-web/Cargo.toml +++ b/actix-web/Cargo.toml @@ -125,7 +125,7 @@ actix-files = "0.6" actix-test = { version = "0.1", features = ["openssl", "rustls-0_22"] } awc = { version = "3", features = ["openssl"] } -brotli = "3.3.3" +brotli = "6" const-str = "0.5" criterion = { version = "0.5", features = ["html_reports"] } env_logger = "0.11" diff --git a/awc/CHANGES.md b/awc/CHANGES.md index 46939a7c..9bb787ab 100644 --- a/awc/CHANGES.md +++ b/awc/CHANGES.md @@ -2,8 +2,8 @@ ## Unreleased +- Update `brotli` dependency to `6`. - Minimum supported Rust version (MSRV) is now 1.72. -- Fix warning on 1.78 due to unused TlsConnectorService struct ## 3.4.0 diff --git a/awc/Cargo.toml b/awc/Cargo.toml index da9e78ae..aa77b024 100644 --- a/awc/Cargo.toml +++ b/awc/Cargo.toml @@ -116,7 +116,7 @@ actix-tls = { version = "3.3", features = ["openssl", "rustls-0_22"] } actix-utils = "3" actix-web = { version = "4", features = ["openssl"] } -brotli = "3.3.3" +brotli = "6" const-str = "0.5" env_logger = "0.11" flate2 = "1.0.13" From 2d035c066ea60e9113ce9a710728a59ad03a0066 Mon Sep 17 00:00:00 2001 From: asonix Date: Sat, 18 May 2024 13:22:53 -0500 Subject: [PATCH 087/151] actix-http: Add rustls 0.23 (#3361) Co-authored-by: Rob Ede --- .github/workflows/ci-post-merge.yml | 4 ++ .github/workflows/ci.yml | 4 ++ actix-http/CHANGES.md | 5 ++ actix-http/Cargo.toml | 12 ++-- actix-http/examples/tls_rustls.rs | 5 +- actix-http/examples/ws.rs | 4 +- actix-http/src/h1/service.rs | 61 ++++++++++++++++++ actix-http/src/h2/service.rs | 51 +++++++++++++++ actix-http/src/lib.rs | 8 ++- actix-http/src/service.rs | 98 +++++++++++++++++++++++++++++ actix-http/tests/test_rustls.rs | 44 ++++++------- 11 files changed, 263 insertions(+), 33 deletions(-) diff --git a/.github/workflows/ci-post-merge.yml b/.github/workflows/ci-post-merge.yml index 40829d8e..8d509d69 100644 --- a/.github/workflows/ci-post-merge.yml +++ b/.github/workflows/ci-post-merge.yml @@ -30,6 +30,10 @@ jobs: steps: - uses: actions/checkout@v4 + - name: Install nasm + if: matrix.target.os == 'windows-latest' + uses: ilammy/setup-nasm@v1.5.1 + - name: Install OpenSSL if: matrix.target.os == 'windows-latest' shell: bash diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c1d959fb..56333e18 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,6 +41,10 @@ jobs: steps: - uses: actions/checkout@v4 + - name: Install nasm + if: matrix.target.os == 'windows-latest' + uses: ilammy/setup-nasm@v1.5.1 + - name: Install OpenSSL if: matrix.target.os == 'windows-latest' shell: bash diff --git a/actix-http/CHANGES.md b/actix-http/CHANGES.md index 69957506..f7b20dd6 100644 --- a/actix-http/CHANGES.md +++ b/actix-http/CHANGES.md @@ -2,6 +2,11 @@ ## Unreleased +### Added + +- Add `rustls-0_23` crate feature +- Add `{h1::H1Service, h2::H2Service, HttpService}::rustls_0_23()` and `HttpService::rustls_0_23_with_config()` service constructors. + ### Changed - Update `brotli` dependency to `6`. diff --git a/actix-http/Cargo.toml b/actix-http/Cargo.toml index 05de2cb8..efd20905 100644 --- a/actix-http/Cargo.toml +++ b/actix-http/Cargo.toml @@ -28,6 +28,7 @@ features = [ "rustls-0_20", "rustls-0_21", "rustls-0_22", + "rustls-0_23", "compress-brotli", "compress-gzip", "compress-zstd", @@ -66,6 +67,9 @@ rustls-0_21 = ["actix-tls/accept", "actix-tls/rustls-0_21"] # TLS via Rustls v0.22 rustls-0_22 = ["actix-tls/accept", "actix-tls/rustls-0_22"] +# TLS via Rustls v0.23 +rustls-0_23 = ["actix-tls/accept", "actix-tls/rustls-0_23"] + # Compression codecs compress-brotli = ["__compress", "brotli"] compress-gzip = ["__compress", "flate2"] @@ -121,7 +125,7 @@ zstd = { version = "0.13", optional = true } [dev-dependencies] actix-http-test = { version = "3", features = ["openssl"] } actix-server = "2" -actix-tls = { version = "3.3", features = ["openssl", "rustls-0_22-webpki-roots"] } +actix-tls = { version = "3.4", features = ["openssl", "rustls-0_23-webpki-roots"] } actix-web = "4" async-stream = "0.3" @@ -139,16 +143,16 @@ serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" static_assertions = "1" tls-openssl = { package = "openssl", version = "0.10.55" } -tls-rustls_022 = { package = "rustls", version = "0.22" } +tls-rustls_023 = { package = "rustls", version = "0.23" } tokio = { version = "1.24.2", features = ["net", "rt", "macros"] } [[example]] name = "ws" -required-features = ["ws", "rustls-0_22"] +required-features = ["ws", "rustls-0_23"] [[example]] name = "tls_rustls" -required-features = ["http2", "rustls-0_22"] +required-features = ["http2", "rustls-0_23"] [[bench]] name = "response-body-compression" diff --git a/actix-http/examples/tls_rustls.rs b/actix-http/examples/tls_rustls.rs index 47ff061c..ebb7b8b3 100644 --- a/actix-http/examples/tls_rustls.rs +++ b/actix-http/examples/tls_rustls.rs @@ -12,12 +12,11 @@ //! Protocol: HTTP/1.1 //! ``` -extern crate tls_rustls_022 as rustls; - use std::io; use actix_http::{Error, HttpService, Request, Response}; use actix_utils::future::ok; +use tls_rustls_023 as rustls; #[actix_rt::main] async fn main() -> io::Result<()> { @@ -36,7 +35,7 @@ async fn main() -> io::Result<()> { ); ok::<_, Error>(Response::ok().set_body(body)) }) - .rustls_0_22(rustls_config()) + .rustls_0_23(rustls_config()) })? .run() .await diff --git a/actix-http/examples/ws.rs b/actix-http/examples/ws.rs index 55085fd7..fac6b136 100644 --- a/actix-http/examples/ws.rs +++ b/actix-http/examples/ws.rs @@ -1,7 +1,7 @@ //! Sets up a WebSocket server over TCP and TLS. //! Sends a heartbeat message every 4 seconds but does not respond to any incoming frames. -extern crate tls_rustls_022 as rustls; +extern crate tls_rustls_023 as rustls; use std::{ io, @@ -30,7 +30,7 @@ async fn main() -> io::Result<()> { .bind("tls", ("127.0.0.1", 8443), || { HttpService::build() .finish(handler) - .rustls_0_22(tls_config()) + .rustls_0_23(tls_config()) })? .run() .await diff --git a/actix-http/src/h1/service.rs b/actix-http/src/h1/service.rs index 64eb39c8..f2f8a0e4 100644 --- a/actix-http/src/h1/service.rs +++ b/actix-http/src/h1/service.rs @@ -335,6 +335,67 @@ mod rustls_0_22 { } } +#[cfg(feature = "rustls-0_23")] +mod rustls_0_23 { + use std::io; + + use actix_service::ServiceFactoryExt as _; + use actix_tls::accept::{ + rustls_0_23::{reexports::ServerConfig, Acceptor, TlsStream}, + TlsError, + }; + + use super::*; + + impl H1Service, S, B, X, U> + where + S: ServiceFactory, + S::Future: 'static, + S::Error: Into>, + S::InitError: fmt::Debug, + S::Response: Into>, + + B: MessageBody, + + X: ServiceFactory, + X::Future: 'static, + X::Error: Into>, + X::InitError: fmt::Debug, + + U: ServiceFactory< + (Request, Framed, Codec>), + Config = (), + Response = (), + >, + U::Future: 'static, + U::Error: fmt::Display + Into>, + U::InitError: fmt::Debug, + { + /// Create Rustls v0.23 based service. + pub fn rustls_0_23( + self, + config: ServerConfig, + ) -> impl ServiceFactory< + TcpStream, + Config = (), + Response = (), + Error = TlsError, + InitError = (), + > { + Acceptor::new(config) + .map_init_err(|_| { + unreachable!("TLS acceptor service factory does not error on init") + }) + .map_err(TlsError::into_service_error) + .map(|io: TlsStream| { + let peer_addr = io.get_ref().0.peer_addr().ok(); + (io, peer_addr) + }) + .and_then(self.map_err(TlsError::Service)) + } + } +} + impl H1Service where S: ServiceFactory, diff --git a/actix-http/src/h2/service.rs b/actix-http/src/h2/service.rs index d50ffc4e..636ac316 100644 --- a/actix-http/src/h2/service.rs +++ b/actix-http/src/h2/service.rs @@ -293,6 +293,57 @@ mod rustls_0_22 { } } +#[cfg(feature = "rustls-0_23")] +mod rustls_0_23 { + use std::io; + + use actix_service::ServiceFactoryExt as _; + use actix_tls::accept::{ + rustls_0_23::{reexports::ServerConfig, Acceptor, TlsStream}, + TlsError, + }; + + use super::*; + + impl H2Service, S, B> + where + S: ServiceFactory, + S::Future: 'static, + S::Error: Into> + 'static, + S::Response: Into> + 'static, + >::Future: 'static, + + B: MessageBody + 'static, + { + /// Create Rustls v0.23 based service. + pub fn rustls_0_23( + self, + mut config: ServerConfig, + ) -> impl ServiceFactory< + TcpStream, + Config = (), + Response = (), + Error = TlsError, + InitError = S::InitError, + > { + let mut protos = vec![b"h2".to_vec()]; + protos.extend_from_slice(&config.alpn_protocols); + config.alpn_protocols = protos; + + Acceptor::new(config) + .map_init_err(|_| { + unreachable!("TLS acceptor service factory does not error on init") + }) + .map_err(TlsError::into_service_error) + .map(|io: TlsStream| { + let peer_addr = io.get_ref().0.peer_addr().ok(); + (io, peer_addr) + }) + .and_then(self.map_err(TlsError::Service)) + } + } +} + impl ServiceFactory<(T, Option)> for H2Service where T: AsyncRead + AsyncWrite + Unpin + 'static, diff --git a/actix-http/src/lib.rs b/actix-http/src/lib.rs index cb82ced0..f9697c4d 100644 --- a/actix-http/src/lib.rs +++ b/actix-http/src/lib.rs @@ -6,7 +6,10 @@ //! | ------------------- | ------------------------------------------- | //! | `http2` | HTTP/2 support via [h2]. | //! | `openssl` | TLS support via [OpenSSL]. | -//! | `rustls` | TLS support via [rustls]. | +//! | `rustls` | TLS support via [rustls] 0.20. | +//! | `rustls-0_21` | TLS support via [rustls] 0.21. | +//! | `rustls-0_22` | TLS support via [rustls] 0.22. | +//! | `rustls-0_23` | TLS support via [rustls] 0.23. | //! | `compress-brotli` | Payload compression support: Brotli. | //! | `compress-gzip` | Payload compression support: Deflate, Gzip. | //! | `compress-zstd` | Payload compression support: Zstd. | @@ -28,7 +31,7 @@ #![doc(html_favicon_url = "https://actix.rs/favicon.ico")] #![cfg_attr(docsrs, feature(doc_auto_cfg))] -pub use ::http::{uri, uri::Uri, Method, StatusCode, Version}; +pub use http::{uri, uri::Uri, Method, StatusCode, Version}; pub mod body; mod builder; @@ -63,6 +66,7 @@ pub use self::payload::PayloadStream; feature = "rustls-0_20", feature = "rustls-0_21", feature = "rustls-0_22", + feature = "rustls-0_23", ))] pub use self::service::TlsAcceptorConfig; pub use self::{ diff --git a/actix-http/src/service.rs b/actix-http/src/service.rs index e2438718..a58be93c 100644 --- a/actix-http/src/service.rs +++ b/actix-http/src/service.rs @@ -246,6 +246,7 @@ where feature = "rustls-0_20", feature = "rustls-0_21", feature = "rustls-0_22", + feature = "rustls-0_23", ))] #[derive(Debug, Default)] pub struct TlsAcceptorConfig { @@ -257,6 +258,7 @@ pub struct TlsAcceptorConfig { feature = "rustls-0_20", feature = "rustls-0_21", feature = "rustls-0_22", + feature = "rustls-0_23", ))] impl TlsAcceptorConfig { /// Set TLS handshake timeout duration. @@ -650,6 +652,102 @@ mod rustls_0_22 { } } +#[cfg(feature = "rustls-0_23")] +mod rustls_0_23 { + use std::io; + + use actix_service::ServiceFactoryExt as _; + use actix_tls::accept::{ + rustls_0_23::{reexports::ServerConfig, Acceptor, TlsStream}, + TlsError, + }; + + use super::*; + + impl HttpService, S, B, X, U> + where + S: ServiceFactory, + S::Future: 'static, + S::Error: Into> + 'static, + S::InitError: fmt::Debug, + S::Response: Into> + 'static, + >::Future: 'static, + + B: MessageBody + 'static, + + X: ServiceFactory, + X::Future: 'static, + X::Error: Into>, + X::InitError: fmt::Debug, + + U: ServiceFactory< + (Request, Framed, h1::Codec>), + Config = (), + Response = (), + >, + U::Future: 'static, + U::Error: fmt::Display + Into>, + U::InitError: fmt::Debug, + { + /// Create Rustls v0.23 based service. + pub fn rustls_0_23( + self, + config: ServerConfig, + ) -> impl ServiceFactory< + TcpStream, + Config = (), + Response = (), + Error = TlsError, + InitError = (), + > { + self.rustls_0_23_with_config(config, TlsAcceptorConfig::default()) + } + + /// Create Rustls v0.23 based service with custom TLS acceptor configuration. + pub fn rustls_0_23_with_config( + self, + mut config: ServerConfig, + tls_acceptor_config: TlsAcceptorConfig, + ) -> impl ServiceFactory< + TcpStream, + Config = (), + Response = (), + Error = TlsError, + InitError = (), + > { + let mut protos = vec![b"h2".to_vec(), b"http/1.1".to_vec()]; + protos.extend_from_slice(&config.alpn_protocols); + config.alpn_protocols = protos; + + let mut acceptor = Acceptor::new(config); + + if let Some(handshake_timeout) = tls_acceptor_config.handshake_timeout { + acceptor.set_handshake_timeout(handshake_timeout); + } + + acceptor + .map_init_err(|_| { + unreachable!("TLS acceptor service factory does not error on init") + }) + .map_err(TlsError::into_service_error) + .and_then(|io: TlsStream| async { + let proto = if let Some(protos) = io.get_ref().1.alpn_protocol() { + if protos.windows(2).any(|window| window == b"h2") { + Protocol::Http2 + } else { + Protocol::Http1 + } + } else { + Protocol::Http1 + }; + let peer_addr = io.get_ref().0.peer_addr().ok(); + Ok((io, proto, peer_addr)) + }) + .and_then(self.map_err(TlsError::Service)) + } + } +} + impl ServiceFactory<(T, Protocol, Option)> for HttpService where diff --git a/actix-http/tests/test_rustls.rs b/actix-http/tests/test_rustls.rs index 08b3a249..fd2064d5 100644 --- a/actix-http/tests/test_rustls.rs +++ b/actix-http/tests/test_rustls.rs @@ -1,6 +1,6 @@ -#![cfg(feature = "rustls-0_22")] +#![cfg(feature = "rustls-0_23")] -extern crate tls_rustls_022 as rustls; +extern crate tls_rustls_023 as rustls; use std::{ convert::Infallible, @@ -20,7 +20,7 @@ use actix_http::{ use actix_http_test::test_server; use actix_rt::pin; use actix_service::{fn_factory_with_config, fn_service}; -use actix_tls::connect::rustls_0_22::webpki_roots_cert_store; +use actix_tls::connect::rustls_0_23::webpki_roots_cert_store; use actix_utils::future::{err, ok, poll_fn}; use bytes::{Bytes, BytesMut}; use derive_more::{Display, Error}; @@ -108,7 +108,7 @@ async fn h1() -> io::Result<()> { let srv = test_server(move || { HttpService::build() .h1(|_| ok::<_, Error>(Response::ok())) - .rustls_0_22(tls_config()) + .rustls_0_23(tls_config()) }) .await; @@ -122,7 +122,7 @@ async fn h2() -> io::Result<()> { let srv = test_server(move || { HttpService::build() .h2(|_| ok::<_, Error>(Response::ok())) - .rustls_0_22(tls_config()) + .rustls_0_23(tls_config()) }) .await; @@ -140,7 +140,7 @@ async fn h1_1() -> io::Result<()> { assert_eq!(req.version(), Version::HTTP_11); ok::<_, Error>(Response::ok()) }) - .rustls_0_22(tls_config()) + .rustls_0_23(tls_config()) }) .await; @@ -158,7 +158,7 @@ async fn h2_1() -> io::Result<()> { assert_eq!(req.version(), Version::HTTP_2); ok::<_, Error>(Response::ok()) }) - .rustls_0_22_with_config( + .rustls_0_23_with_config( tls_config(), TlsAcceptorConfig::default().handshake_timeout(Duration::from_secs(5)), ) @@ -179,7 +179,7 @@ async fn h2_body1() -> io::Result<()> { let body = load_body(req.take_payload()).await?; Ok::<_, Error>(Response::ok().set_body(body)) }) - .rustls_0_22(tls_config()) + .rustls_0_23(tls_config()) }) .await; @@ -205,7 +205,7 @@ async fn h2_content_length() { ]; ok::<_, Infallible>(Response::new(statuses[indx])) }) - .rustls_0_22(tls_config()) + .rustls_0_23(tls_config()) }) .await; @@ -277,7 +277,7 @@ async fn h2_headers() { } ok::<_, Infallible>(config.body(data.clone())) }) - .rustls_0_22(tls_config()) + .rustls_0_23(tls_config()) }) .await; @@ -316,7 +316,7 @@ async fn h2_body2() { let mut srv = test_server(move || { HttpService::build() .h2(|_| ok::<_, Infallible>(Response::ok().set_body(STR))) - .rustls_0_22(tls_config()) + .rustls_0_23(tls_config()) }) .await; @@ -333,7 +333,7 @@ async fn h2_head_empty() { let mut srv = test_server(move || { HttpService::build() .finish(|_| ok::<_, Infallible>(Response::ok().set_body(STR))) - .rustls_0_22(tls_config()) + .rustls_0_23(tls_config()) }) .await; @@ -359,7 +359,7 @@ async fn h2_head_binary() { let mut srv = test_server(move || { HttpService::build() .h2(|_| ok::<_, Infallible>(Response::ok().set_body(STR))) - .rustls_0_22(tls_config()) + .rustls_0_23(tls_config()) }) .await; @@ -384,7 +384,7 @@ async fn h2_head_binary2() { let srv = test_server(move || { HttpService::build() .h2(|_| ok::<_, Infallible>(Response::ok().set_body(STR))) - .rustls_0_22(tls_config()) + .rustls_0_23(tls_config()) }) .await; @@ -410,7 +410,7 @@ async fn h2_body_length() { Response::ok().set_body(SizedStream::new(STR.len() as u64, body)), ) }) - .rustls_0_22(tls_config()) + .rustls_0_23(tls_config()) }) .await; @@ -434,7 +434,7 @@ async fn h2_body_chunked_explicit() { .body(BodyStream::new(body)), ) }) - .rustls_0_22(tls_config()) + .rustls_0_23(tls_config()) }) .await; @@ -463,7 +463,7 @@ async fn h2_response_http_error_handling() { ) })) })) - .rustls_0_22(tls_config()) + .rustls_0_23(tls_config()) }) .await; @@ -493,7 +493,7 @@ async fn h2_service_error() { let mut srv = test_server(move || { HttpService::build() .h2(|_| err::, _>(BadRequest)) - .rustls_0_22(tls_config()) + .rustls_0_23(tls_config()) }) .await; @@ -510,7 +510,7 @@ async fn h1_service_error() { let mut srv = test_server(move || { HttpService::build() .h1(|_| err::, _>(BadRequest)) - .rustls_0_22(tls_config()) + .rustls_0_23(tls_config()) }) .await; @@ -533,7 +533,7 @@ async fn alpn_h1() -> io::Result<()> { config.alpn_protocols.push(CUSTOM_ALPN_PROTOCOL.to_vec()); HttpService::build() .h1(|_| ok::<_, Error>(Response::ok())) - .rustls_0_22(config) + .rustls_0_23(config) }) .await; @@ -555,7 +555,7 @@ async fn alpn_h2() -> io::Result<()> { config.alpn_protocols.push(CUSTOM_ALPN_PROTOCOL.to_vec()); HttpService::build() .h2(|_| ok::<_, Error>(Response::ok())) - .rustls_0_22(config) + .rustls_0_23(config) }) .await; @@ -581,7 +581,7 @@ async fn alpn_h2_1() -> io::Result<()> { config.alpn_protocols.push(CUSTOM_ALPN_PROTOCOL.to_vec()); HttpService::build() .finish(|_| ok::<_, Error>(Response::ok())) - .rustls_0_22(config) + .rustls_0_23(config) }) .await; From 0a2788d6627ed26d3fec560474b1c7f9febd78db Mon Sep 17 00:00:00 2001 From: Matt Palmer Date: Sun, 19 May 2024 04:57:35 +1000 Subject: [PATCH 088/151] actix-test: re-export types from awc (#3349) This allows us to pass these types around in functions, without having to add `awc` as a direct (dev-)dependency. Co-authored-by: Rob Ede --- actix-test/CHANGES.md | 1 + actix-test/src/lib.rs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/actix-test/CHANGES.md b/actix-test/CHANGES.md index 08252044..f465720f 100644 --- a/actix-test/CHANGES.md +++ b/actix-test/CHANGES.md @@ -3,6 +3,7 @@ ## Unreleased - Minimum supported Rust version (MSRV) is now 1.72. +- Various types from `awc`, such as `ClientRequest` and `ClientResponse`, are now re-exported. ## 0.1.3 diff --git a/actix-test/src/lib.rs b/actix-test/src/lib.rs index b7aeddad..b90db638 100644 --- a/actix-test/src/lib.rs +++ b/actix-test/src/lib.rs @@ -52,7 +52,7 @@ use actix_web::{ rt::{self, System}, web, Error, }; -use awc::{error::PayloadError, Client, ClientRequest, ClientResponse, Connector}; +pub use awc::{error::PayloadError, Client, ClientRequest, ClientResponse, Connector}; use futures_core::Stream; use tokio::sync::mpsc; From 48d7adb7bfee8e373e31e9fe6c78a7da4cec5bec Mon Sep 17 00:00:00 2001 From: Raphael C Date: Sat, 18 May 2024 21:02:00 +0200 Subject: [PATCH 089/151] Documentation for actix multipart (#3344) example for actix-multipart readme & crate docs Co-authored-by: Rob Ede --- actix-multipart/README.md | 62 ++++++++++++++++++++++++++++++++++++++ actix-multipart/src/lib.rs | 35 +++++++++++++++++++++ 2 files changed, 97 insertions(+) diff --git a/actix-multipart/README.md b/actix-multipart/README.md index 56723bd6..83947b0c 100644 --- a/actix-multipart/README.md +++ b/actix-multipart/README.md @@ -14,3 +14,65 @@ [![Chat on Discord](https://img.shields.io/discord/771444961383153695?label=chat&logo=discord)](https://discord.gg/NWpN5mmg3x) + + +## Example + +Dependencies: + +```toml +[dependencies] +actix-multipart = "0.6" +actix-web = "4.5" +serde = { version = "1.0", features = ["derive"] } +``` + +Code: + +```rust +use actix_web::{post, App, HttpServer, Responder}; + +use actix_multipart::form::{json::Json as MPJson, tempfile::TempFile, MultipartForm}; +use serde::Deserialize; + +#[derive(Debug, Deserialize)] +struct Metadata { + name: String, +} + +#[derive(Debug, MultipartForm)] +struct UploadForm { + #[multipart(limit = "100MB")] + file: TempFile, + json: MPJson, +} + +#[post("/videos")] +pub async fn post_video(MultipartForm(form): MultipartForm) -> impl Responder { + format!( + "Uploaded file {}, with size: {}", + form.json.name, form.file.size + ) +} + +#[actix_web::main] +async fn main() -> std::io::Result<()> { + HttpServer::new(move || App::new().service(post_video)) + .bind(("127.0.0.1", 8080))? + .run() + .await +} +``` + +Curl request : +```bash +curl -v --request POST \ + --url http://localhost:8080/videos \ + -F 'json={"name": "Cargo.lock"};type=application/json' \ + -F file=@./Cargo.lock +``` + + +### Examples + +https://github.com/actix/examples/tree/master/forms/multipart \ No newline at end of file diff --git a/actix-multipart/src/lib.rs b/actix-multipart/src/lib.rs index c06a00ca..d19e951e 100644 --- a/actix-multipart/src/lib.rs +++ b/actix-multipart/src/lib.rs @@ -1,4 +1,39 @@ //! Multipart form support for Actix Web. +//! # Examples +//! ```no_run +//! use actix_web::{post, App, HttpServer, Responder}; +//! +//! use actix_multipart::form::{json::Json as MPJson, tempfile::TempFile, MultipartForm}; +//! use serde::Deserialize; +//! +//! #[derive(Debug, Deserialize)] +//! struct Metadata { +//! name: String, +//! } +//! +//! #[derive(Debug, MultipartForm)] +//! struct UploadForm { +//! #[multipart(limit = "100MB")] +//! file: TempFile, +//! json: MPJson, +//! } +//! +//! #[post("/videos")] +//! pub async fn post_video(MultipartForm(form): MultipartForm) -> impl Responder { +//! format!( +//! "Uploaded file {}, with size: {}", +//! form.json.name, form.file.size +//! ) +//! } +//! +//! #[actix_web::main] +//! async fn main() -> std::io::Result<()> { +//! HttpServer::new(move || App::new().service(post_video)) +//! .bind(("127.0.0.1", 8080))? +//! .run() +//! .await +//! } +//! ``` #![deny(rust_2018_idioms, nonstandard_style)] #![warn(future_incompatible)] From 2e63ff5928abc0704cadf330bcbf630162a37fa8 Mon Sep 17 00:00:00 2001 From: asonix Date: Sat, 18 May 2024 14:05:58 -0500 Subject: [PATCH 090/151] actix-web: Add rustls 0.23 (#3363) * Fix type confusion in some scenarios When the feature for rustls 0.22 is enabled, and rustls 0.23 is also present in a project, there suddently exist multiple paths for errors when building middleware chains due to the use of two consecutive `?` operators without specifying the intermediate error type. This commit addresses the issue by removing the first `?`, so that the first error type will always be known, and the second `?` always has a well defined implementation. * Add CHANGES entry about type confusion * actix-http: add rustls 0.23 support * actix-http: update ws example, tests for rustls 0.23 * actix-http: add rustls 0.23 to changelog * Update comments to mention 0.23 instead of 0.22 * awc: add rustls 0.23 support This also fixes certificate lookup when native-roots is enabled for rustls 0.22. * awc: update changelog for rustls 0.23 * awc: Add base rustls-0_23 feature without roots to better enable custom config * actix-test: add rustls-0.23 * actix-test: add rustls 0.23 to changelog * awc: update changelog with rustls 0.23 tweaks * actix-web: add rustls 0.23 * Add rustls-0_23 to CI * Update tls_rustls.rs * review nits * review nits part 2 * fix doc test --------- Co-authored-by: Rob Ede --- actix-http/examples/tls_rustls.rs | 3 +- actix-test/CHANGES.md | 1 + actix-test/Cargo.toml | 3 + actix-test/src/lib.rs | 53 ++++++++++++++++ actix-web/CHANGES.md | 3 + actix-web/Cargo.toml | 7 +- actix-web/src/lib.rs | 5 +- actix-web/src/server.rs | 102 +++++++++++++++++++++++++++++- actix-web/tests/test_server.rs | 6 +- awc/CHANGES.md | 3 + awc/Cargo.toml | 15 ++++- awc/src/builder.rs | 6 ++ awc/src/client/connector.rs | 97 ++++++++++++++++++++++++++-- awc/tests/test_rustls_client.rs | 12 ++-- 14 files changed, 292 insertions(+), 24 deletions(-) diff --git a/actix-http/examples/tls_rustls.rs b/actix-http/examples/tls_rustls.rs index ebb7b8b3..3e273d79 100644 --- a/actix-http/examples/tls_rustls.rs +++ b/actix-http/examples/tls_rustls.rs @@ -12,11 +12,12 @@ //! Protocol: HTTP/1.1 //! ``` +extern crate tls_rustls_023 as rustls; + use std::io; use actix_http::{Error, HttpService, Request, Response}; use actix_utils::future::ok; -use tls_rustls_023 as rustls; #[actix_rt::main] async fn main() -> io::Result<()> { diff --git a/actix-test/CHANGES.md b/actix-test/CHANGES.md index f465720f..b55a8305 100644 --- a/actix-test/CHANGES.md +++ b/actix-test/CHANGES.md @@ -2,6 +2,7 @@ ## Unreleased +- Add `TestServerConfig::rustls_0_23()` method for Rustls v0.23 support behind new `rustls-0_23` crate feature. - Minimum supported Rust version (MSRV) is now 1.72. - Various types from `awc`, such as `ClientRequest` and `ClientResponse`, are now re-exported. diff --git a/actix-test/Cargo.toml b/actix-test/Cargo.toml index 7f48fc2c..69ce080a 100644 --- a/actix-test/Cargo.toml +++ b/actix-test/Cargo.toml @@ -29,6 +29,8 @@ rustls-0_20 = ["tls-rustls-0_20", "actix-http/rustls-0_20", "awc/rustls-0_20"] rustls-0_21 = ["tls-rustls-0_21", "actix-http/rustls-0_21", "awc/rustls-0_21"] # TLS via Rustls v0.22 rustls-0_22 = ["tls-rustls-0_22", "actix-http/rustls-0_22", "awc/rustls-0_22-webpki-roots"] +# TLS via Rustls v0.23 +rustls-0_23 = ["tls-rustls-0_23", "actix-http/rustls-0_23", "awc/rustls-0_23-webpki-roots"] # TLS via OpenSSL openssl = ["tls-openssl", "actix-http/openssl", "awc/openssl"] @@ -53,4 +55,5 @@ tls-openssl = { package = "openssl", version = "0.10.55", optional = true } tls-rustls-0_20 = { package = "rustls", version = "0.20", optional = true } tls-rustls-0_21 = { package = "rustls", version = "0.21", optional = true } tls-rustls-0_22 = { package = "rustls", version = "0.22", optional = true } +tls-rustls-0_23 = { package = "rustls", version = "0.23", default-features = false, optional = true } tokio = { version = "1.24.2", features = ["sync"] } diff --git a/actix-test/src/lib.rs b/actix-test/src/lib.rs index b90db638..1c3d8ff1 100644 --- a/actix-test/src/lib.rs +++ b/actix-test/src/lib.rs @@ -145,6 +145,8 @@ where StreamType::Rustls021(_) => true, #[cfg(feature = "rustls-0_22")] StreamType::Rustls022(_) => true, + #[cfg(feature = "rustls-0_23")] + StreamType::Rustls023(_) => true, }; // run server in separate orphaned thread @@ -371,6 +373,48 @@ where .rustls_0_22(config.clone()) }), }, + #[cfg(feature = "rustls-0_23")] + StreamType::Rustls023(config) => match cfg.tp { + HttpVer::Http1 => builder.listen("test", tcp, move || { + let app_cfg = + AppConfig::__priv_test_new(false, local_addr.to_string(), local_addr); + + let fac = factory() + .into_factory() + .map_err(|err| err.into().error_response()); + + HttpService::build() + .client_request_timeout(timeout) + .h1(map_config(fac, move |_| app_cfg.clone())) + .rustls_0_23(config.clone()) + }), + HttpVer::Http2 => builder.listen("test", tcp, move || { + let app_cfg = + AppConfig::__priv_test_new(false, local_addr.to_string(), local_addr); + + let fac = factory() + .into_factory() + .map_err(|err| err.into().error_response()); + + HttpService::build() + .client_request_timeout(timeout) + .h2(map_config(fac, move |_| app_cfg.clone())) + .rustls_0_23(config.clone()) + }), + HttpVer::Both => builder.listen("test", tcp, move || { + let app_cfg = + AppConfig::__priv_test_new(false, local_addr.to_string(), local_addr); + + let fac = factory() + .into_factory() + .map_err(|err| err.into().error_response()); + + HttpService::build() + .client_request_timeout(timeout) + .finish(map_config(fac, move |_| app_cfg.clone())) + .rustls_0_23(config.clone()) + }), + }, } .expect("test server could not be created"); @@ -447,6 +491,8 @@ enum StreamType { Rustls021(tls_rustls_0_21::ServerConfig), #[cfg(feature = "rustls-0_22")] Rustls022(tls_rustls_0_22::ServerConfig), + #[cfg(feature = "rustls-0_23")] + Rustls023(tls_rustls_0_23::ServerConfig), } /// Create default test server config. @@ -537,6 +583,13 @@ impl TestServerConfig { self } + /// Accepts secure connections via Rustls v0.23. + #[cfg(feature = "rustls-0_23")] + pub fn rustls_0_23(mut self, config: tls_rustls_0_23::ServerConfig) -> Self { + self.stream = StreamType::Rustls023(config); + self + } + /// Sets client timeout for first request. pub fn client_request_timeout(mut self, dur: Duration) -> Self { self.client_request_timeout = dur; diff --git a/actix-web/CHANGES.md b/actix-web/CHANGES.md index ea996769..5b43a51d 100644 --- a/actix-web/CHANGES.md +++ b/actix-web/CHANGES.md @@ -5,6 +5,9 @@ ### Added - Add `unicode` crate feature (on-by-default) to switch between `regex` and `regex-lite` as a trade-off between full unicode support and binary size. +- Add `rustls-0_23` crate feature. +- Add `HttpServer::{bind_rustls_0_23, listen_rustls_0_23}()` builder methods. +- Add `HttpServer::tls_handshake_timeout()` builder method for `rustls-0_22` and `rustls-0_23`. ### Changed diff --git a/actix-web/Cargo.toml b/actix-web/Cargo.toml index b4c71381..cd09c305 100644 --- a/actix-web/Cargo.toml +++ b/actix-web/Cargo.toml @@ -27,6 +27,7 @@ features = [ "rustls-0_20", "rustls-0_21", "rustls-0_22", + "rustls-0_23", "compress-brotli", "compress-gzip", "compress-zstd", @@ -71,6 +72,8 @@ rustls-0_20 = ["http2", "actix-http/rustls-0_20", "actix-tls/accept", "actix-tls rustls-0_21 = ["http2", "actix-http/rustls-0_21", "actix-tls/accept", "actix-tls/rustls-0_21"] # TLS via Rustls v0.22 rustls-0_22 = ["http2", "actix-http/rustls-0_22", "actix-tls/accept", "actix-tls/rustls-0_22"] +# TLS via Rustls v0.23 +rustls-0_23 = ["http2", "actix-http/rustls-0_23", "actix-tls/accept", "actix-tls/rustls-0_23"] # Full unicode support unicode = ["dep:regex", "actix-router/unicode"] @@ -122,7 +125,7 @@ url = "2.1" [dev-dependencies] actix-files = "0.6" -actix-test = { version = "0.1", features = ["openssl", "rustls-0_22"] } +actix-test = { version = "0.1", features = ["openssl", "rustls-0_23"] } awc = { version = "3", features = ["openssl"] } brotli = "6" @@ -137,7 +140,7 @@ rustls-pemfile = "2" serde = { version = "1.0", features = ["derive"] } static_assertions = "1" tls-openssl = { package = "openssl", version = "0.10.55" } -tls-rustls = { package = "rustls", version = "0.22" } +tls-rustls = { package = "rustls", version = "0.23" } tokio = { version = "1.24.2", features = ["rt-multi-thread", "macros"] } zstd = "0.13" diff --git a/actix-web/src/lib.rs b/actix-web/src/lib.rs index 88f0ae9b..f86a7440 100644 --- a/actix-web/src/lib.rs +++ b/actix-web/src/lib.rs @@ -64,7 +64,10 @@ //! - `compress-gzip` - gzip and deflate content encoding compression support (enabled by default) //! - `compress-zstd` - zstd content encoding compression support (enabled by default) //! - `openssl` - HTTPS support via `openssl` crate, supports `HTTP/2` -//! - `rustls` - HTTPS support via `rustls` crate, supports `HTTP/2` +//! - `rustls` - HTTPS support via `rustls` 0.20 crate, supports `HTTP/2` +//! - `rustls-0_21` - HTTPS support via `rustls` 0.21 crate, supports `HTTP/2` +//! - `rustls-0_22` - HTTPS support via `rustls` 0.22 crate, supports `HTTP/2` +//! - `rustls-0_23` - HTTPS support via `rustls` 0.23 crate, supports `HTTP/2` //! - `secure-cookies` - secure cookies support #![deny(rust_2018_idioms, nonstandard_style)] diff --git a/actix-web/src/server.rs b/actix-web/src/server.rs index 6592079b..33b1e189 100644 --- a/actix-web/src/server.rs +++ b/actix-web/src/server.rs @@ -12,6 +12,7 @@ use std::{ feature = "rustls-0_20", feature = "rustls-0_21", feature = "rustls-0_22", + feature = "rustls-0_23", ))] use actix_http::TlsAcceptorConfig; use actix_http::{body::MessageBody, Extensions, HttpService, KeepAlive, Request, Response}; @@ -242,7 +243,13 @@ where /// time, the connection is closed. /// /// By default, the handshake timeout is 3 seconds. - #[cfg(any(feature = "openssl", feature = "rustls-0_20", feature = "rustls-0_21"))] + #[cfg(any( + feature = "openssl", + feature = "rustls-0_20", + feature = "rustls-0_21", + feature = "rustls-0_22", + feature = "rustls-0_23", + ))] pub fn tls_handshake_timeout(self, dur: Duration) -> Self { self.config .lock() @@ -270,6 +277,10 @@ where /// Rustls v0.20. /// - `actix_tls::accept::rustls_0_21::TlsStream` when using /// Rustls v0.21. + /// - `actix_tls::accept::rustls_0_22::TlsStream` when using + /// Rustls v0.22. + /// - `actix_tls::accept::rustls_0_23::TlsStream` when using + /// Rustls v0.23. /// - `actix_web::rt::net::TcpStream` when no encryption is used. /// /// See the `on_connect` example for additional details. @@ -466,6 +477,25 @@ where Ok(self) } + /// Resolves socket address(es) and binds server to created listener(s) for TLS connections + /// using Rustls v0.23. + /// + /// See [`bind()`](Self::bind()) for more details on `addrs` argument. + /// + /// ALPN protocols "h2" and "http/1.1" are added to any configured ones. + #[cfg(feature = "rustls-0_23")] + pub fn bind_rustls_0_23( + mut self, + addrs: A, + config: actix_tls::accept::rustls_0_23::reexports::ServerConfig, + ) -> io::Result { + let sockets = bind_addrs(addrs, self.backlog)?; + for lst in sockets { + self = self.listen_rustls_0_23_inner(lst, config.clone())?; + } + Ok(self) + } + /// Resolves socket address(es) and binds server to created listener(s) for TLS connections /// using OpenSSL. /// @@ -595,7 +625,7 @@ where /// Binds to existing listener for accepting incoming TLS connection requests using Rustls /// v0.21. /// - /// See [`listen()`](Self::listen) for more details on the `lst` argument. + /// See [`listen()`](Self::listen()) for more details on the `lst` argument. /// /// ALPN protocols "h2" and "http/1.1" are added to any configured ones. #[cfg(feature = "rustls-0_21")] @@ -712,7 +742,7 @@ where /// Binds to existing listener for accepting incoming TLS connection requests using Rustls /// v0.22. /// - /// See [`listen()`](Self::listen) for more details on the `lst` argument. + /// See [`listen()`](Self::listen()) for more details on the `lst` argument. /// /// ALPN protocols "h2" and "http/1.1" are added to any configured ones. #[cfg(feature = "rustls-0_22")] @@ -775,6 +805,72 @@ where Ok(self) } + /// Binds to existing listener for accepting incoming TLS connection requests using Rustls + /// v0.23. + /// + /// See [`listen()`](Self::listen()) for more details on the `lst` argument. + /// + /// ALPN protocols "h2" and "http/1.1" are added to any configured ones. + #[cfg(feature = "rustls-0_23")] + pub fn listen_rustls_0_23( + self, + lst: net::TcpListener, + config: actix_tls::accept::rustls_0_23::reexports::ServerConfig, + ) -> io::Result { + self.listen_rustls_0_23_inner(lst, config) + } + + #[cfg(feature = "rustls-0_23")] + fn listen_rustls_0_23_inner( + mut self, + lst: net::TcpListener, + config: actix_tls::accept::rustls_0_23::reexports::ServerConfig, + ) -> io::Result { + let factory = self.factory.clone(); + let cfg = self.config.clone(); + let addr = lst.local_addr().unwrap(); + self.sockets.push(Socket { + addr, + scheme: "https", + }); + + let on_connect_fn = self.on_connect_fn.clone(); + + self.builder = + self.builder + .listen(format!("actix-web-service-{}", addr), lst, move || { + let c = cfg.lock().unwrap(); + let host = c.host.clone().unwrap_or_else(|| format!("{}", addr)); + + let svc = HttpService::build() + .keep_alive(c.keep_alive) + .client_request_timeout(c.client_request_timeout) + .client_disconnect_timeout(c.client_disconnect_timeout); + + let svc = if let Some(handler) = on_connect_fn.clone() { + svc.on_connect_ext(move |io: &_, ext: _| (handler)(io as &dyn Any, ext)) + } else { + svc + }; + + let fac = factory() + .into_factory() + .map_err(|err| err.into().error_response()); + + let acceptor_config = match c.tls_handshake_timeout { + Some(dur) => TlsAcceptorConfig::default().handshake_timeout(dur), + None => TlsAcceptorConfig::default(), + }; + + svc.finish(map_config(fac, move |_| { + AppConfig::new(true, host.clone(), addr) + })) + .rustls_0_23_with_config(config.clone(), acceptor_config) + })?; + + Ok(self) + } + /// Binds to existing listener for accepting incoming TLS connection requests using OpenSSL. /// /// See [`listen()`](Self::listen) for more details on the `lst` argument. diff --git a/actix-web/tests/test_server.rs b/actix-web/tests/test_server.rs index 8fb80216..60d28235 100644 --- a/actix-web/tests/test_server.rs +++ b/actix-web/tests/test_server.rs @@ -1,6 +1,6 @@ #[cfg(feature = "openssl")] extern crate tls_openssl as openssl; -#[cfg(feature = "rustls-0_22")] +#[cfg(feature = "rustls-0_23")] extern crate tls_rustls as rustls; use std::{ @@ -704,7 +704,7 @@ async fn test_brotli_encoding_large_openssl() { srv.stop().await; } -#[cfg(feature = "rustls-0_22")] +#[cfg(feature = "rustls-0_23")] mod plus_rustls { use std::io::BufReader; @@ -740,7 +740,7 @@ mod plus_rustls { .map(char::from) .collect::(); - let srv = actix_test::start_with(actix_test::config().rustls_0_22(tls_config()), || { + let srv = actix_test::start_with(actix_test::config().rustls_0_23(tls_config()), || { App::new().service(web::resource("/").route(web::to(|bytes: Bytes| async { // echo decompressed request body back in response HttpResponse::Ok() diff --git a/awc/CHANGES.md b/awc/CHANGES.md index 9bb787ab..4031d2bd 100644 --- a/awc/CHANGES.md +++ b/awc/CHANGES.md @@ -2,6 +2,9 @@ ## Unreleased +- Add `rustls-0_23`, `rustls-0_23-webpki-roots`, and `rustls-0_23-native-roots` crate features. +- Add `awc::Connector::rustls_0_23()` constructor. +- Fix `rustls-0_22-native-roots` root store lookup - Update `brotli` dependency to `6`. - Minimum supported Rust version (MSRV) is now 1.72. diff --git a/awc/Cargo.toml b/awc/Cargo.toml index aa77b024..2ba8ada3 100644 --- a/awc/Cargo.toml +++ b/awc/Cargo.toml @@ -27,6 +27,7 @@ features = [ "rustls-0_20", "rustls-0_21", "rustls-0_22-webpki-roots", + "rustls-0_23-webpki-roots", "compress-brotli", "compress-gzip", "compress-zstd", @@ -48,6 +49,12 @@ rustls-0_21 = ["tls-rustls-0_21", "actix-tls/rustls-0_21"] rustls-0_22-webpki-roots = ["tls-rustls-0_22", "actix-tls/rustls-0_22-webpki-roots"] # TLS via Rustls v0.22 (Native roots) rustls-0_22-native-roots = ["tls-rustls-0_22", "actix-tls/rustls-0_22-native-roots"] +# TLS via Rustls v0.23 +rustls-0_23 = ["tls-rustls-0_23", "actix-tls/rustls-0_23"] +# TLS via Rustls v0.23 (WebPKI roots) +rustls-0_23-webpki-roots = ["rustls-0_23", "actix-tls/rustls-0_23-webpki-roots"] +# TLS via Rustls v0.23 (Native roots) +rustls-0_23-native-roots = ["rustls-0_23", "actix-tls/rustls-0_23-native-roots"] # Brotli algorithm content-encoding support compress-brotli = ["actix-http/compress-brotli", "__compress"] @@ -104,6 +111,7 @@ tls-openssl = { package = "openssl", version = "0.10.55", optional = true } tls-rustls-0_20 = { package = "rustls", version = "0.20", optional = true, features = ["dangerous_configuration"] } tls-rustls-0_21 = { package = "rustls", version = "0.21", optional = true, features = ["dangerous_configuration"] } tls-rustls-0_22 = { package = "rustls", version = "0.22", optional = true } +tls-rustls-0_23 = { package = "rustls", version = "0.23", optional = true, default-features = false } trust-dns-resolver = { version = "0.23", optional = true } @@ -111,8 +119,8 @@ trust-dns-resolver = { version = "0.23", optional = true } actix-http = { version = "3.6", features = ["openssl"] } actix-http-test = { version = "3", features = ["openssl"] } actix-server = "2" -actix-test = { version = "0.1", features = ["openssl", "rustls-0_22"] } -actix-tls = { version = "3.3", features = ["openssl", "rustls-0_22"] } +actix-test = { version = "0.1", features = ["openssl", "rustls-0_23"] } +actix-tls = { version = "3.3", features = ["openssl", "rustls-0_23"] } actix-utils = "3" actix-web = { version = "4", features = ["openssl"] } @@ -126,7 +134,8 @@ rcgen = "0.12" rustls-pemfile = "2" tokio = { version = "1.24.2", features = ["rt-multi-thread", "macros"] } zstd = "0.13" +tls-rustls-0_23 = { package = "rustls", version = "0.23" } # add rustls 0.23 with default features to make aws_lc_rs work in tests [[example]] name = "client" -required-features = ["rustls-0_22-webpki-roots"] +required-features = ["rustls-0_23-webpki-roots"] diff --git a/awc/src/builder.rs b/awc/src/builder.rs index a5496038..5aae394f 100644 --- a/awc/src/builder.rs +++ b/awc/src/builder.rs @@ -37,6 +37,12 @@ pub struct ClientBuilder { } impl ClientBuilder { + /// Create a new ClientBuilder with default settings + /// + /// Note: If the `rustls-0_23` feature is enabled and neither `rustls-0_23-native-roots` nor + /// `rustls-0_23-webpki-roots` are enabled, this ClientBuilder will build without TLS. In order + /// to enable TLS in this scenario, a custom `Connector` _must_ be added to the builder before + /// finishing construction. #[allow(clippy::new_ret_no_self)] pub fn new() -> ClientBuilder< impl Service< diff --git a/awc/src/client/connector.rs b/awc/src/client/connector.rs index b66e13ec..fbe50b65 100644 --- a/awc/src/client/connector.rs +++ b/awc/src/client/connector.rs @@ -57,6 +57,10 @@ enum OurTlsConnector { ))] #[allow(dead_code)] // false positive; used in build_tls Rustls022(std::sync::Arc), + + #[cfg(feature = "rustls-0_23")] + #[allow(dead_code)] // false positive; used in build_tls + Rustls023(std::sync::Arc), } /// Manages HTTP client network connectivity. @@ -80,6 +84,14 @@ pub struct Connector { } impl Connector<()> { + /// Create a new connector with default TLS settings + /// + /// # Panics + /// + /// - When the `rustls-0_23-webpki-roots` or `rustls-0_23-native-roots` features are enabled + /// and no default crypto provider has been loaded, this method will panic. + /// - When the `rustls-0_23-native-roots` or `rustls-0_22-native-roots` features are enabled + /// and the runtime system has no native root certificates, this method will panic. #[allow(clippy::new_ret_no_self, clippy::let_unit_value)] pub fn new() -> Connector< impl Service< @@ -96,10 +108,32 @@ impl Connector<()> { } cfg_if::cfg_if! { - if #[cfg(any(feature = "rustls-0_22-webpki-roots", feature = "rustls-0_22-webpki-roots"))] { - /// Build TLS connector with Rustls v0.22, based on supplied ALPN protocols. + if #[cfg(any(feature = "rustls-0_23-webpki-roots", feature = "rustls-0_23-native-roots"))] { + /// Build TLS connector with Rustls v0.23, based on supplied ALPN protocols. /// - /// Note that if other TLS crate features are enabled, Rustls v0.22 will be used. + /// Note that if other TLS crate features are enabled, Rustls v0.23 will be used. + fn build_tls(protocols: Vec>) -> OurTlsConnector { + use actix_tls::connect::rustls_0_23::{self, reexports::ClientConfig}; + + cfg_if::cfg_if! { + if #[cfg(feature = "rustls-0_23-webpki-roots")] { + let certs = rustls_0_23::webpki_roots_cert_store(); + } else if #[cfg(feature = "rustls-0_23-native-roots")] { + let certs = rustls_0_23::native_roots_cert_store().expect("Failed to find native root certificates"); + } + } + + let mut config = ClientConfig::builder() + .with_root_certificates(certs) + .with_no_client_auth(); + + config.alpn_protocols = protocols; + + OurTlsConnector::Rustls023(std::sync::Arc::new(config)) + } + + } else if #[cfg(any(feature = "rustls-0_22-webpki-roots", feature = "rustls-0_22-native-roots"))] { + /// Build TLS connector with Rustls v0.22, based on supplied ALPN protocols. fn build_tls(protocols: Vec>) -> OurTlsConnector { use actix_tls::connect::rustls_0_22::{self, reexports::ClientConfig}; @@ -107,7 +141,7 @@ impl Connector<()> { if #[cfg(feature = "rustls-0_22-webpki-roots")] { let certs = rustls_0_22::webpki_roots_cert_store(); } else if #[cfg(feature = "rustls-0_22-native-roots")] { - let certs = rustls_0_22::native_roots_cert_store(); + let certs = rustls_0_22::native_roots_cert_store().expect("Failed to find native root certificates"); } } @@ -167,7 +201,8 @@ impl Connector<()> { OurTlsConnector::OpensslBuilder(ssl) } } else { - /// Provides an empty TLS connector when no TLS feature is enabled. + /// Provides an empty TLS connector when no TLS feature is enabled, or when only the + /// `rustls-0_23` crate feature is enabled. fn build_tls(_: Vec>) -> OurTlsConnector { OurTlsConnector::None } @@ -278,6 +313,24 @@ where self } + /// Sets custom Rustls v0.23 `ClientConfig` instance. + /// + /// In order to enable ALPN, set the `.alpn_protocols` field on the ClientConfig to the + /// following: + /// + /// ```no_run + /// vec![b"h2".to_vec(), b"http/1.1".to_vec()] + /// # ; + /// ``` + #[cfg(feature = "rustls-0_23")] + pub fn rustls_0_23( + mut self, + connector: std::sync::Arc, + ) -> Self { + self.tls = OurTlsConnector::Rustls023(connector); + self + } + /// Sets maximum supported HTTP major version. /// /// Supported versions are HTTP/1.1 and HTTP/2. @@ -588,6 +641,40 @@ where Some(actix_service::boxed::rc_service(tls_service)) } + + #[cfg(feature = "rustls-0_23")] + OurTlsConnector::Rustls023(tls) => { + const H2: &[u8] = b"h2"; + + use actix_tls::connect::rustls_0_23::{reexports::AsyncTlsStream, TlsConnector}; + + #[allow(non_local_definitions)] + impl IntoConnectionIo for TcpConnection> { + fn into_connection_io(self) -> (Box, Protocol) { + let sock = self.into_parts().0; + let h2 = sock + .get_ref() + .1 + .alpn_protocol() + .map_or(false, |protos| protos.windows(2).any(|w| w == H2)); + if h2 { + (Box::new(sock), Protocol::Http2) + } else { + (Box::new(sock), Protocol::Http1) + } + } + } + + let handshake_timeout = self.config.handshake_timeout; + + let tls_service = TlsConnectorService { + tcp_service: tcp_service_inner, + tls_service: TlsConnector::service(tls), + timeout: handshake_timeout, + }; + + Some(actix_service::boxed::rc_service(tls_service)) + } }; let tcp_config = self.config.no_disconnect_timeout(); diff --git a/awc/tests/test_rustls_client.rs b/awc/tests/test_rustls_client.rs index 1cc3e8c4..719d2511 100644 --- a/awc/tests/test_rustls_client.rs +++ b/awc/tests/test_rustls_client.rs @@ -1,6 +1,6 @@ -#![cfg(feature = "rustls-0_22-webpki-roots")] +#![cfg(feature = "rustls-0_23-webpki-roots")] -extern crate tls_rustls_0_22 as rustls; +extern crate tls_rustls_0_23 as rustls; use std::{ io::BufReader, @@ -13,7 +13,7 @@ use std::{ use actix_http::HttpService; use actix_http_test::test_server; use actix_service::{fn_service, map_config, ServiceFactoryExt}; -use actix_tls::connect::rustls_0_22::webpki_roots_cert_store; +use actix_tls::connect::rustls_0_23::webpki_roots_cert_store; use actix_utils::future::ok; use actix_web::{dev::AppConfig, http::Version, web, App, HttpResponse}; use rustls::{ @@ -83,7 +83,7 @@ mod danger { } fn supported_verify_schemes(&self) -> Vec { - rustls::crypto::ring::default_provider() + rustls::crypto::aws_lc_rs::default_provider() .signature_verification_algorithms .supported_schemes() } @@ -107,7 +107,7 @@ async fn test_connection_reuse_h2() { App::new().service(web::resource("/").route(web::to(HttpResponse::Ok))), |_| AppConfig::default(), )) - .rustls_0_22(tls_config()) + .rustls_0_23(tls_config()) .map_err(|_| ()), ) }) @@ -126,7 +126,7 @@ async fn test_connection_reuse_h2() { .set_certificate_verifier(Arc::new(danger::NoCertificateVerification)); let client = awc::Client::builder() - .connector(awc::Connector::new().rustls_0_22(Arc::new(config))) + .connector(awc::Connector::new().rustls_0_23(Arc::new(config))) .finish(); // req 1 From 18e02b83d5e160d3fe7e051104eea700f8eaa3af Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Sat, 18 May 2024 20:35:12 +0100 Subject: [PATCH 091/151] docs: fix middleware docs warning --- actix-web/src/middleware/mod.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/actix-web/src/middleware/mod.rs b/actix-web/src/middleware/mod.rs index ed61556a..e924de26 100644 --- a/actix-web/src/middleware/mod.rs +++ b/actix-web/src/middleware/mod.rs @@ -33,13 +33,13 @@ //! //! # fn main() { //! # // These aren't snake_case, because they are supposed to be unit structs. -//! # let MiddlewareA = middleware::Compress::default(); -//! # let MiddlewareB = middleware::Compress::default(); -//! # let MiddlewareC = middleware::Compress::default(); +//! # type MiddlewareA = middleware::Compress; +//! # type MiddlewareB = middleware::Compress; +//! # type MiddlewareC = middleware::Compress; //! let app = App::new() -//! .wrap(MiddlewareA) -//! .wrap(MiddlewareB) -//! .wrap(MiddlewareC) +//! .wrap(MiddlewareA::default()) +//! .wrap(MiddlewareB::default()) +//! .wrap(MiddlewareC::default()) //! .service(service); //! # } //! ``` From e8262da1381c24a265747ac604e45aee635e00b8 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Sun, 19 May 2024 10:12:32 +0100 Subject: [PATCH 092/151] chore: update rcgen to 0.13 --- actix-http/Cargo.toml | 2 +- actix-http/examples/tls_rustls.rs | 7 ++++--- actix-http/examples/ws.rs | 7 ++++--- actix-http/tests/test_openssl.rs | 8 +++++--- actix-http/tests/test_rustls.rs | 7 ++++--- actix-web/Cargo.toml | 2 +- actix-web/tests/test_httpserver.rs | 8 +++++--- actix-web/tests/test_server.rs | 15 +++++++++------ awc/Cargo.toml | 2 +- awc/tests/test_connector.rs | 8 +++++--- awc/tests/test_rustls_client.rs | 7 ++++--- awc/tests/test_ssl_client.rs | 8 +++++--- 12 files changed, 48 insertions(+), 33 deletions(-) diff --git a/actix-http/Cargo.toml b/actix-http/Cargo.toml index efd20905..c00c2ee0 100644 --- a/actix-http/Cargo.toml +++ b/actix-http/Cargo.toml @@ -135,7 +135,7 @@ env_logger = "0.11" futures-util = { version = "0.3.17", default-features = false, features = ["alloc"] } memchr = "2.4" once_cell = "1.9" -rcgen = "0.12" +rcgen = "0.13" regex = "1.3" rustversion = "1" rustls-pemfile = "2" diff --git a/actix-http/examples/tls_rustls.rs b/actix-http/examples/tls_rustls.rs index 3e273d79..17303c55 100644 --- a/actix-http/examples/tls_rustls.rs +++ b/actix-http/examples/tls_rustls.rs @@ -43,9 +43,10 @@ async fn main() -> io::Result<()> { } fn rustls_config() -> rustls::ServerConfig { - let cert = rcgen::generate_simple_self_signed(vec!["localhost".to_owned()]).unwrap(); - let cert_file = cert.serialize_pem().unwrap(); - let key_file = cert.serialize_private_key_pem(); + let rcgen::CertifiedKey { cert, key_pair } = + rcgen::generate_simple_self_signed(["localhost".to_owned()]).unwrap(); + let cert_file = cert.pem(); + let key_file = key_pair.serialize_pem(); let cert_file = &mut io::BufReader::new(cert_file.as_bytes()); let key_file = &mut io::BufReader::new(key_file.as_bytes()); diff --git a/actix-http/examples/ws.rs b/actix-http/examples/ws.rs index fac6b136..fb86bc5e 100644 --- a/actix-http/examples/ws.rs +++ b/actix-http/examples/ws.rs @@ -87,9 +87,10 @@ fn tls_config() -> rustls::ServerConfig { use rustls_pemfile::{certs, pkcs8_private_keys}; - let cert = rcgen::generate_simple_self_signed(vec!["localhost".to_owned()]).unwrap(); - let cert_file = cert.serialize_pem().unwrap(); - let key_file = cert.serialize_private_key_pem(); + let rcgen::CertifiedKey { cert, key_pair } = + rcgen::generate_simple_self_signed(["localhost".to_owned()]).unwrap(); + let cert_file = cert.pem(); + let key_file = key_pair.serialize_pem(); let cert_file = &mut BufReader::new(cert_file.as_bytes()); let key_file = &mut BufReader::new(key_file.as_bytes()); diff --git a/actix-http/tests/test_openssl.rs b/actix-http/tests/test_openssl.rs index cb16a4fe..4dd22b58 100644 --- a/actix-http/tests/test_openssl.rs +++ b/actix-http/tests/test_openssl.rs @@ -42,9 +42,11 @@ where } fn tls_config() -> SslAcceptor { - let cert = rcgen::generate_simple_self_signed(vec!["localhost".to_owned()]).unwrap(); - let cert_file = cert.serialize_pem().unwrap(); - let key_file = cert.serialize_private_key_pem(); + let rcgen::CertifiedKey { cert, key_pair } = + rcgen::generate_simple_self_signed(["localhost".to_owned()]).unwrap(); + let cert_file = cert.pem(); + let key_file = key_pair.serialize_pem(); + let cert = X509::from_pem(cert_file.as_bytes()).unwrap(); let key = PKey::private_key_from_pem(key_file.as_bytes()).unwrap(); diff --git a/actix-http/tests/test_rustls.rs b/actix-http/tests/test_rustls.rs index fd2064d5..3ca0d94c 100644 --- a/actix-http/tests/test_rustls.rs +++ b/actix-http/tests/test_rustls.rs @@ -52,9 +52,10 @@ where } fn tls_config() -> RustlsServerConfig { - let cert = rcgen::generate_simple_self_signed(vec!["localhost".to_owned()]).unwrap(); - let cert_file = cert.serialize_pem().unwrap(); - let key_file = cert.serialize_private_key_pem(); + let rcgen::CertifiedKey { cert, key_pair } = + rcgen::generate_simple_self_signed(["localhost".to_owned()]).unwrap(); + let cert_file = cert.pem(); + let key_file = key_pair.serialize_pem(); let cert_file = &mut BufReader::new(cert_file.as_bytes()); let key_file = &mut BufReader::new(key_file.as_bytes()); diff --git a/actix-web/Cargo.toml b/actix-web/Cargo.toml index cd09c305..bd24ea35 100644 --- a/actix-web/Cargo.toml +++ b/actix-web/Cargo.toml @@ -135,7 +135,7 @@ env_logger = "0.11" flate2 = "1.0.13" futures-util = { version = "0.3.17", default-features = false, features = ["std"] } rand = "0.8" -rcgen = "0.12" +rcgen = "0.13" rustls-pemfile = "2" serde = { version = "1.0", features = ["derive"] } static_assertions = "1" diff --git a/actix-web/tests/test_httpserver.rs b/actix-web/tests/test_httpserver.rs index 86e0575f..039c0ffb 100644 --- a/actix-web/tests/test_httpserver.rs +++ b/actix-web/tests/test_httpserver.rs @@ -64,9 +64,11 @@ fn ssl_acceptor() -> openssl::ssl::SslAcceptorBuilder { x509::X509, }; - let cert = rcgen::generate_simple_self_signed(vec!["localhost".to_owned()]).unwrap(); - let cert_file = cert.serialize_pem().unwrap(); - let key_file = cert.serialize_private_key_pem(); + let rcgen::CertifiedKey { cert, key_pair } = + rcgen::generate_simple_self_signed(["localhost".to_owned()]).unwrap(); + let cert_file = cert.pem(); + let key_file = key_pair.serialize_pem(); + let cert = X509::from_pem(cert_file.as_bytes()).unwrap(); let key = PKey::private_key_from_pem(key_file.as_bytes()).unwrap(); diff --git a/actix-web/tests/test_server.rs b/actix-web/tests/test_server.rs index 60d28235..960cf1e2 100644 --- a/actix-web/tests/test_server.rs +++ b/actix-web/tests/test_server.rs @@ -34,9 +34,11 @@ const STR: &str = const_str::repeat!(S, 100); #[cfg(feature = "openssl")] fn openssl_config() -> SslAcceptor { - let cert = rcgen::generate_simple_self_signed(vec!["localhost".to_owned()]).unwrap(); - let cert_file = cert.serialize_pem().unwrap(); - let key_file = cert.serialize_private_key_pem(); + let rcgen::CertifiedKey { cert, key_pair } = + rcgen::generate_simple_self_signed(["localhost".to_owned()]).unwrap(); + let cert_file = cert.pem(); + let key_file = key_pair.serialize_pem(); + let cert = X509::from_pem(cert_file.as_bytes()).unwrap(); let key = PKey::private_key_from_pem(key_file.as_bytes()).unwrap(); @@ -714,9 +716,10 @@ mod plus_rustls { use super::*; fn tls_config() -> RustlsServerConfig { - let cert = rcgen::generate_simple_self_signed(vec!["localhost".to_owned()]).unwrap(); - let cert_file = cert.serialize_pem().unwrap(); - let key_file = cert.serialize_private_key_pem(); + let rcgen::CertifiedKey { cert, key_pair } = + rcgen::generate_simple_self_signed(["localhost".to_owned()]).unwrap(); + let cert_file = cert.pem(); + let key_file = key_pair.serialize_pem(); let cert_file = &mut BufReader::new(cert_file.as_bytes()); let key_file = &mut BufReader::new(key_file.as_bytes()); diff --git a/awc/Cargo.toml b/awc/Cargo.toml index 2ba8ada3..b1ee6236 100644 --- a/awc/Cargo.toml +++ b/awc/Cargo.toml @@ -130,7 +130,7 @@ env_logger = "0.11" flate2 = "1.0.13" futures-util = { version = "0.3.17", default-features = false } static_assertions = "1.1" -rcgen = "0.12" +rcgen = "0.13" rustls-pemfile = "2" tokio = { version = "1.24.2", features = ["rt-multi-thread", "macros"] } zstd = "0.13" diff --git a/awc/tests/test_connector.rs b/awc/tests/test_connector.rs index b3eb9736..a8b7e98c 100644 --- a/awc/tests/test_connector.rs +++ b/awc/tests/test_connector.rs @@ -13,9 +13,11 @@ use openssl::{ }; fn tls_config() -> SslAcceptor { - let cert = rcgen::generate_simple_self_signed(vec!["localhost".to_owned()]).unwrap(); - let cert_file = cert.serialize_pem().unwrap(); - let key_file = cert.serialize_private_key_pem(); + let rcgen::CertifiedKey { cert, key_pair } = + rcgen::generate_simple_self_signed(["localhost".to_owned()]).unwrap(); + let cert_file = cert.pem(); + let key_file = key_pair.serialize_pem(); + let cert = X509::from_pem(cert_file.as_bytes()).unwrap(); let key = PKey::private_key_from_pem(key_file.as_bytes()).unwrap(); diff --git a/awc/tests/test_rustls_client.rs b/awc/tests/test_rustls_client.rs index 719d2511..7e832f67 100644 --- a/awc/tests/test_rustls_client.rs +++ b/awc/tests/test_rustls_client.rs @@ -23,9 +23,10 @@ use rustls::{ use rustls_pemfile::{certs, pkcs8_private_keys}; fn tls_config() -> ServerConfig { - let cert = rcgen::generate_simple_self_signed(vec!["localhost".to_owned()]).unwrap(); - let cert_file = cert.serialize_pem().unwrap(); - let key_file = cert.serialize_private_key_pem(); + let rcgen::CertifiedKey { cert, key_pair } = + rcgen::generate_simple_self_signed(["localhost".to_owned()]).unwrap(); + let cert_file = cert.pem(); + let key_file = key_pair.serialize_pem(); let cert_file = &mut BufReader::new(cert_file.as_bytes()); let key_file = &mut BufReader::new(key_file.as_bytes()); diff --git a/awc/tests/test_ssl_client.rs b/awc/tests/test_ssl_client.rs index 5273c3ff..95d4c15f 100644 --- a/awc/tests/test_ssl_client.rs +++ b/awc/tests/test_ssl_client.rs @@ -19,9 +19,11 @@ use openssl::{ }; fn tls_config() -> SslAcceptor { - let cert = rcgen::generate_simple_self_signed(vec!["localhost".to_owned()]).unwrap(); - let cert_file = cert.serialize_pem().unwrap(); - let key_file = cert.serialize_private_key_pem(); + let rcgen::CertifiedKey { cert, key_pair } = + rcgen::generate_simple_self_signed(["localhost".to_owned()]).unwrap(); + let cert_file = cert.pem(); + let key_file = key_pair.serialize_pem(); + let cert = X509::from_pem(cert_file.as_bytes()).unwrap(); let key = PKey::private_key_from_pem(key_file.as_bytes()).unwrap(); From fe7268487aa89fe92fac92a547c9fd23dd37508e Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Sun, 19 May 2024 10:14:30 +0100 Subject: [PATCH 093/151] chore(actix-http): prepare release 3.7.0 --- actix-http/CHANGES.md | 2 ++ actix-http/Cargo.toml | 2 +- actix-http/README.md | 4 ++-- actix-test/Cargo.toml | 2 +- actix-web/Cargo.toml | 2 +- awc/Cargo.toml | 4 ++-- 6 files changed, 9 insertions(+), 7 deletions(-) diff --git a/actix-http/CHANGES.md b/actix-http/CHANGES.md index f7b20dd6..61eeb4be 100644 --- a/actix-http/CHANGES.md +++ b/actix-http/CHANGES.md @@ -2,6 +2,8 @@ ## Unreleased +## 3.7.0 + ### Added - Add `rustls-0_23` crate feature diff --git a/actix-http/Cargo.toml b/actix-http/Cargo.toml index c00c2ee0..57509def 100644 --- a/actix-http/Cargo.toml +++ b/actix-http/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "actix-http" -version = "3.6.0" +version = "3.7.0" authors = [ "Nikolay Kim ", "Rob Ede ", diff --git a/actix-http/README.md b/actix-http/README.md index 3881b805..0ba3fdca 100644 --- a/actix-http/README.md +++ b/actix-http/README.md @@ -5,11 +5,11 @@ [![crates.io](https://img.shields.io/crates/v/actix-http?label=latest)](https://crates.io/crates/actix-http) -[![Documentation](https://docs.rs/actix-http/badge.svg?version=3.6.0)](https://docs.rs/actix-http/3.6.0) +[![Documentation](https://docs.rs/actix-http/badge.svg?version=3.7.0)](https://docs.rs/actix-http/3.7.0) ![Version](https://img.shields.io/badge/rustc-1.72+-ab6000.svg) ![MIT or Apache 2.0 licensed](https://img.shields.io/crates/l/actix-http.svg)
-[![dependency status](https://deps.rs/crate/actix-http/3.6.0/status.svg)](https://deps.rs/crate/actix-http/3.6.0) +[![dependency status](https://deps.rs/crate/actix-http/3.7.0/status.svg)](https://deps.rs/crate/actix-http/3.7.0) [![Download](https://img.shields.io/crates/d/actix-http.svg)](https://crates.io/crates/actix-http) [![Chat on Discord](https://img.shields.io/discord/771444961383153695?label=chat&logo=discord)](https://discord.gg/NWpN5mmg3x) diff --git a/actix-test/Cargo.toml b/actix-test/Cargo.toml index 69ce080a..23dde9cf 100644 --- a/actix-test/Cargo.toml +++ b/actix-test/Cargo.toml @@ -37,7 +37,7 @@ openssl = ["tls-openssl", "actix-http/openssl", "awc/openssl"] [dependencies] actix-codec = "0.5" -actix-http = "3.6" +actix-http = "3.7" actix-http-test = "3" actix-rt = "2.1" actix-service = "2" diff --git a/actix-web/Cargo.toml b/actix-web/Cargo.toml index bd24ea35..1faee7a4 100644 --- a/actix-web/Cargo.toml +++ b/actix-web/Cargo.toml @@ -94,7 +94,7 @@ actix-service = "2" actix-utils = "3" actix-tls = { version = "3.3", default-features = false, optional = true } -actix-http = { version = "3.6", features = ["ws"] } +actix-http = { version = "3.7", features = ["ws"] } actix-router = { version = "0.5", default-features = false, features = ["http"] } actix-web-codegen = { version = "4.2", optional = true } diff --git a/awc/Cargo.toml b/awc/Cargo.toml index b1ee6236..f844db21 100644 --- a/awc/Cargo.toml +++ b/awc/Cargo.toml @@ -81,7 +81,7 @@ dangerous-h2c = [] [dependencies] actix-codec = "0.5" actix-service = "2" -actix-http = { version = "3.6", features = ["http2", "ws"] } +actix-http = { version = "3.7", features = ["http2", "ws"] } actix-rt = { version = "2.1", default-features = false } actix-tls = { version = "3.3", features = ["connect", "uri"] } actix-utils = "3" @@ -116,7 +116,7 @@ tls-rustls-0_23 = { package = "rustls", version = "0.23", optional = true, defau trust-dns-resolver = { version = "0.23", optional = true } [dev-dependencies] -actix-http = { version = "3.6", features = ["openssl"] } +actix-http = { version = "3.7", features = ["openssl"] } actix-http-test = { version = "3", features = ["openssl"] } actix-server = "2" actix-test = { version = "0.1", features = ["openssl", "rustls-0_23"] } From 59115bca49bbbb539c6774d613165f424df29a49 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Sun, 19 May 2024 10:15:48 +0100 Subject: [PATCH 094/151] chore(actix-web): prepare release 4.6.0 --- actix-test/Cargo.toml | 2 +- actix-web/CHANGES.md | 2 ++ actix-web/Cargo.toml | 2 +- actix-web/README.md | 4 ++-- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/actix-test/Cargo.toml b/actix-test/Cargo.toml index 23dde9cf..3e96f06e 100644 --- a/actix-test/Cargo.toml +++ b/actix-test/Cargo.toml @@ -42,7 +42,7 @@ actix-http-test = "3" actix-rt = "2.1" actix-service = "2" actix-utils = "3" -actix-web = { version = "4.5", default-features = false, features = ["cookies"] } +actix-web = { version = "4.6", default-features = false, features = ["cookies"] } awc = { version = "3.4", default-features = false, features = ["cookies"] } futures-core = { version = "0.3.17", default-features = false, features = ["std"] } diff --git a/actix-web/CHANGES.md b/actix-web/CHANGES.md index 5b43a51d..993c7c59 100644 --- a/actix-web/CHANGES.md +++ b/actix-web/CHANGES.md @@ -2,6 +2,8 @@ ## Unreleased +## 4.6.0 + ### Added - Add `unicode` crate feature (on-by-default) to switch between `regex` and `regex-lite` as a trade-off between full unicode support and binary size. diff --git a/actix-web/Cargo.toml b/actix-web/Cargo.toml index 1faee7a4..cf4da74f 100644 --- a/actix-web/Cargo.toml +++ b/actix-web/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "actix-web" -version = "4.5.1" +version = "4.6.0" description = "Actix Web is a powerful, pragmatic, and extremely fast web framework for Rust" authors = [ "Nikolay Kim ", diff --git a/actix-web/README.md b/actix-web/README.md index 35e07fc0..4e7e785a 100644 --- a/actix-web/README.md +++ b/actix-web/README.md @@ -8,10 +8,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=4.5.1)](https://docs.rs/actix-web/4.5.1) +[![Documentation](https://docs.rs/actix-web/badge.svg?version=4.6.0)](https://docs.rs/actix-web/4.6.0) ![MSRV](https://img.shields.io/badge/rustc-1.72+-ab6000.svg) ![MIT or Apache 2.0 licensed](https://img.shields.io/crates/l/actix-web.svg) -[![Dependency Status](https://deps.rs/crate/actix-web/4.5.1/status.svg)](https://deps.rs/crate/actix-web/4.5.1) +[![Dependency Status](https://deps.rs/crate/actix-web/4.6.0/status.svg)](https://deps.rs/crate/actix-web/4.6.0)
[![CI](https://github.com/actix/actix-web/actions/workflows/ci.yml/badge.svg)](https://github.com/actix/actix-web/actions/workflows/ci.yml) [![codecov](https://codecov.io/gh/actix/actix-web/branch/master/graph/badge.svg)](https://codecov.io/gh/actix/actix-web) From 9a437fe8357a74d4ab04e6df1c431d499a334413 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Sun, 19 May 2024 10:16:16 +0100 Subject: [PATCH 095/151] chore(awc): prepare release 3.5.0 --- actix-test/Cargo.toml | 2 +- awc/CHANGES.md | 2 ++ awc/Cargo.toml | 2 +- awc/README.md | 4 ++-- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/actix-test/Cargo.toml b/actix-test/Cargo.toml index 3e96f06e..dddcabec 100644 --- a/actix-test/Cargo.toml +++ b/actix-test/Cargo.toml @@ -43,7 +43,7 @@ actix-rt = "2.1" actix-service = "2" actix-utils = "3" actix-web = { version = "4.6", default-features = false, features = ["cookies"] } -awc = { version = "3.4", default-features = false, features = ["cookies"] } +awc = { version = "3.5", default-features = false, features = ["cookies"] } futures-core = { version = "0.3.17", default-features = false, features = ["std"] } futures-util = { version = "0.3.17", default-features = false, features = [] } diff --git a/awc/CHANGES.md b/awc/CHANGES.md index 4031d2bd..54c5e986 100644 --- a/awc/CHANGES.md +++ b/awc/CHANGES.md @@ -2,6 +2,8 @@ ## Unreleased +## 3.5.0 + - Add `rustls-0_23`, `rustls-0_23-webpki-roots`, and `rustls-0_23-native-roots` crate features. - Add `awc::Connector::rustls_0_23()` constructor. - Fix `rustls-0_22-native-roots` root store lookup diff --git a/awc/Cargo.toml b/awc/Cargo.toml index f844db21..58986f3e 100644 --- a/awc/Cargo.toml +++ b/awc/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "awc" -version = "3.4.0" +version = "3.5.0" authors = ["Nikolay Kim "] description = "Async HTTP and WebSocket client library" keywords = ["actix", "http", "framework", "async", "web"] diff --git a/awc/README.md b/awc/README.md index 19236b85..8e7b4281 100644 --- a/awc/README.md +++ b/awc/README.md @@ -5,9 +5,9 @@ [![crates.io](https://img.shields.io/crates/v/awc?label=latest)](https://crates.io/crates/awc) -[![Documentation](https://docs.rs/awc/badge.svg?version=3.4.0)](https://docs.rs/awc/3.4.0) +[![Documentation](https://docs.rs/awc/badge.svg?version=3.5.0)](https://docs.rs/awc/3.5.0) ![MIT or Apache 2.0 licensed](https://img.shields.io/crates/l/awc) -[![Dependency Status](https://deps.rs/crate/awc/3.4.0/status.svg)](https://deps.rs/crate/awc/3.4.0) +[![Dependency Status](https://deps.rs/crate/awc/3.5.0/status.svg)](https://deps.rs/crate/awc/3.5.0) [![Chat on Discord](https://img.shields.io/discord/771444961383153695?label=chat&logo=discord)](https://discord.gg/NWpN5mmg3x) From acb740584c759499000cc19d322d4f0293389631 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Sun, 19 May 2024 11:55:12 +0100 Subject: [PATCH 096/151] fix: correct aws rustls v0.23 feature gating --- actix-http/Cargo.toml | 2 +- actix-web/Cargo.toml | 2 +- awc/Cargo.toml | 4 ++-- awc/src/client/connector.rs | 5 ++++- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/actix-http/Cargo.toml b/actix-http/Cargo.toml index 57509def..a999e73c 100644 --- a/actix-http/Cargo.toml +++ b/actix-http/Cargo.toml @@ -115,7 +115,7 @@ rand = { version = "0.8", optional = true } sha1 = { version = "0.10", optional = true } # openssl/rustls -actix-tls = { version = "3.3", default-features = false, optional = true } +actix-tls = { version = "3.4", default-features = false, optional = true } # compress-* brotli = { version = "6", optional = true } diff --git a/actix-web/Cargo.toml b/actix-web/Cargo.toml index cf4da74f..32fcc060 100644 --- a/actix-web/Cargo.toml +++ b/actix-web/Cargo.toml @@ -92,7 +92,7 @@ actix-rt = { version = "2.6", default-features = false } actix-server = "2" actix-service = "2" actix-utils = "3" -actix-tls = { version = "3.3", default-features = false, optional = true } +actix-tls = { version = "3.4", default-features = false, optional = true } actix-http = { version = "3.7", features = ["ws"] } actix-router = { version = "0.5", default-features = false, features = ["http"] } diff --git a/awc/Cargo.toml b/awc/Cargo.toml index 58986f3e..f51b3904 100644 --- a/awc/Cargo.toml +++ b/awc/Cargo.toml @@ -83,7 +83,7 @@ actix-codec = "0.5" actix-service = "2" actix-http = { version = "3.7", features = ["http2", "ws"] } actix-rt = { version = "2.1", default-features = false } -actix-tls = { version = "3.3", features = ["connect", "uri"] } +actix-tls = { version = "3.4", features = ["connect", "uri"] } actix-utils = "3" base64 = "0.22" @@ -120,7 +120,7 @@ actix-http = { version = "3.7", features = ["openssl"] } actix-http-test = { version = "3", features = ["openssl"] } actix-server = "2" actix-test = { version = "0.1", features = ["openssl", "rustls-0_23"] } -actix-tls = { version = "3.3", features = ["openssl", "rustls-0_23"] } +actix-tls = { version = "3.4", features = ["openssl", "rustls-0_23"] } actix-utils = "3" actix-web = { version = "4", features = ["openssl"] } diff --git a/awc/src/client/connector.rs b/awc/src/client/connector.rs index fbe50b65..5d0b655a 100644 --- a/awc/src/client/connector.rs +++ b/awc/src/client/connector.rs @@ -131,7 +131,6 @@ impl Connector<()> { OurTlsConnector::Rustls023(std::sync::Arc::new(config)) } - } else if #[cfg(any(feature = "rustls-0_22-webpki-roots", feature = "rustls-0_22-native-roots"))] { /// Build TLS connector with Rustls v0.22, based on supplied ALPN protocols. fn build_tls(protocols: Vec>) -> OurTlsConnector { @@ -743,6 +742,9 @@ where feature = "rustls-0_21", feature = "rustls-0_22-webpki-roots", feature = "rustls-0_22-native-roots", + feature = "rustls-0_23", + feature = "rustls-0_23-webpki-roots", + feature = "rustls-0_23-native-roots" ))] struct TlsConnectorService { /// TCP connection is canceled on `TcpConnectorInnerService`'s timeout setting. @@ -761,6 +763,7 @@ struct TlsConnectorService { feature = "rustls-0_21", feature = "rustls-0_22-webpki-roots", feature = "rustls-0_22-native-roots", + feature = "rustls-0_23", ))] impl Service for TlsConnectorService where From 804a3445658cc946e52632457b2807cac660f2d5 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Sun, 19 May 2024 12:06:20 +0100 Subject: [PATCH 097/151] ci: limit cargo hack concurrency --- .cargo/config.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.cargo/config.toml b/.cargo/config.toml index 6d5a8b81..a2345e18 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -6,5 +6,5 @@ lint-all = "clippy --workspace --all-features --all-targets -- -Dclippy::todo" ci-check-min = "hack --workspace check --no-default-features" ci-check-default = "hack --workspace check" ci-check-default-tests = "check --workspace --tests" -ci-check-all-feature-powerset="hack --workspace --feature-powerset --skip=__compress,experimental-io-uring check" -ci-check-all-feature-powerset-linux="hack --workspace --feature-powerset --skip=__compress check" +ci-check-all-feature-powerset="hack --workspace --feature-powerset --depth=4 --skip=__compress,experimental-io-uring check" +ci-check-all-feature-powerset-linux="hack --workspace --feature-powerset --depth=4 --skip=__compress check" From b342b8fc82317365dd9e43659601345d86ba065d Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Sun, 19 May 2024 12:09:46 +0100 Subject: [PATCH 098/151] chore(actix-router): prepare release 0.5.3 --- actix-router/CHANGES.md | 2 ++ actix-router/Cargo.toml | 2 +- actix-router/README.md | 4 ++-- actix-web/Cargo.toml | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/actix-router/CHANGES.md b/actix-router/CHANGES.md index 8aa3c863..6305b45c 100644 --- a/actix-router/CHANGES.md +++ b/actix-router/CHANGES.md @@ -2,6 +2,8 @@ ## Unreleased +## 0.5.3 + - Add `unicode` crate feature (on-by-default) to switch between `regex` and `regex-lite` as a trade-off between full unicode support and binary size. - Minimum supported Rust version (MSRV) is now 1.72. diff --git a/actix-router/Cargo.toml b/actix-router/Cargo.toml index 0b02e84b..56e4bed2 100644 --- a/actix-router/Cargo.toml +++ b/actix-router/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "actix-router" -version = "0.5.2" +version = "0.5.3" authors = [ "Nikolay Kim ", "Ali MJ Al-Nasrawy ", diff --git a/actix-router/README.md b/actix-router/README.md index 751c307b..12d1b014 100644 --- a/actix-router/README.md +++ b/actix-router/README.md @@ -3,11 +3,11 @@ [![crates.io](https://img.shields.io/crates/v/actix-router?label=latest)](https://crates.io/crates/actix-router) -[![Documentation](https://docs.rs/actix-router/badge.svg?version=0.5.2)](https://docs.rs/actix-router/0.5.2) +[![Documentation](https://docs.rs/actix-router/badge.svg?version=0.5.3)](https://docs.rs/actix-router/0.5.3) ![Version](https://img.shields.io/badge/rustc-1.72+-ab6000.svg) ![MIT or Apache 2.0 licensed](https://img.shields.io/crates/l/actix-router.svg)
-[![dependency status](https://deps.rs/crate/actix-router/0.5.2/status.svg)](https://deps.rs/crate/actix-router/0.5.2) +[![dependency status](https://deps.rs/crate/actix-router/0.5.3/status.svg)](https://deps.rs/crate/actix-router/0.5.3) [![Download](https://img.shields.io/crates/d/actix-router.svg)](https://crates.io/crates/actix-router) [![Chat on Discord](https://img.shields.io/discord/771444961383153695?label=chat&logo=discord)](https://discord.gg/NWpN5mmg3x) diff --git a/actix-web/Cargo.toml b/actix-web/Cargo.toml index 32fcc060..9f3ab6e5 100644 --- a/actix-web/Cargo.toml +++ b/actix-web/Cargo.toml @@ -95,7 +95,7 @@ actix-utils = "3" actix-tls = { version = "3.4", default-features = false, optional = true } actix-http = { version = "3.7", features = ["ws"] } -actix-router = { version = "0.5", default-features = false, features = ["http"] } +actix-router = { version = "0.5.3", default-features = false, features = ["http"] } actix-web-codegen = { version = "4.2", optional = true } ahash = "0.8" From fdff3775a8625588d7a55a8ec0ad471308f4ae6f Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Sun, 19 May 2024 20:24:33 +0100 Subject: [PATCH 099/151] ci: use mold linker (#3370) --- .github/workflows/ci.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 56333e18..a81f0e8e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -54,6 +54,10 @@ jobs: echo 'OPENSSL_DIR=C:\Program Files\OpenSSL' >> $GITHUB_ENV echo "RUSTFLAGS=-C target-feature=+crt-static" >> $GITHUB_ENV + - name: Setup mold linker + if: matrix.target.os == 'ubuntu-latest' + uses: rui314/setup-mold@v1 + - name: Install Rust (${{ matrix.version.name }}) uses: actions-rust-lang/setup-rust-toolchain@v1.8.0 with: From 4f7b334d8054041296b94cdcedd162017e2869dc Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 20 May 2024 10:27:44 +0100 Subject: [PATCH 100/151] build(deps): bump taiki-e/install-action from 2.33.22 to 2.33.26 (#3376) Bumps [taiki-e/install-action](https://github.com/taiki-e/install-action) from 2.33.22 to 2.33.26. - [Release notes](https://github.com/taiki-e/install-action/releases) - [Changelog](https://github.com/taiki-e/install-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/taiki-e/install-action/compare/v2.33.22...v2.33.26) --- updated-dependencies: - dependency-name: taiki-e/install-action dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/ci-post-merge.yml | 4 ++-- .github/workflows/ci.yml | 4 ++-- .github/workflows/coverage.yml | 2 +- .github/workflows/lint.yml | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci-post-merge.yml b/.github/workflows/ci-post-merge.yml index 8d509d69..dfb0ca56 100644 --- a/.github/workflows/ci-post-merge.yml +++ b/.github/workflows/ci-post-merge.yml @@ -49,7 +49,7 @@ jobs: toolchain: ${{ matrix.version.version }} - name: Install just, cargo-hack, cargo-nextest, cargo-ci-cache-clean - uses: taiki-e/install-action@v2.33.22 + uses: taiki-e/install-action@v2.33.26 with: tool: just,cargo-hack,cargo-nextest,cargo-ci-cache-clean @@ -80,7 +80,7 @@ jobs: uses: actions-rust-lang/setup-rust-toolchain@v1.8.0 - name: Install cargo-hack - uses: taiki-e/install-action@v2.33.22 + uses: taiki-e/install-action@v2.33.26 with: tool: cargo-hack diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a81f0e8e..153ab78f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -64,7 +64,7 @@ jobs: toolchain: ${{ matrix.version.version }} - name: Install just, cargo-hack, cargo-nextest, cargo-ci-cache-clean - uses: taiki-e/install-action@v2.33.22 + uses: taiki-e/install-action@v2.33.26 with: tool: just,cargo-hack,cargo-nextest,cargo-ci-cache-clean @@ -113,7 +113,7 @@ jobs: toolchain: nightly - name: Install just - uses: taiki-e/install-action@v2.33.22 + uses: taiki-e/install-action@v2.33.26 with: tool: just diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 943f6322..5eaaae8b 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -23,7 +23,7 @@ jobs: components: llvm-tools-preview - name: Install cargo-llvm-cov - uses: taiki-e/install-action@v2.33.22 + uses: taiki-e/install-action@v2.33.26 with: tool: cargo-llvm-cov diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 03b25ecd..39392fab 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -82,7 +82,7 @@ jobs: toolchain: nightly-2024-04-26 - name: Install cargo-public-api - uses: taiki-e/install-action@v2.33.22 + uses: taiki-e/install-action@v2.33.26 with: tool: cargo-public-api From d4bcdf28f24728edadaa584dfc31eabcb8ca1bdf Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 20 May 2024 10:30:27 +0100 Subject: [PATCH 101/151] build(deps): bump JamesIves/github-pages-deploy-action from 4.6.0 to 4.6.1 (#3375) build(deps): bump JamesIves/github-pages-deploy-action Bumps [JamesIves/github-pages-deploy-action](https://github.com/jamesives/github-pages-deploy-action) from 4.6.0 to 4.6.1. - [Release notes](https://github.com/jamesives/github-pages-deploy-action/releases) - [Commits](https://github.com/jamesives/github-pages-deploy-action/compare/v4.6.0...v4.6.1) --- updated-dependencies: - dependency-name: JamesIves/github-pages-deploy-action dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/upload-doc.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/upload-doc.yml b/.github/workflows/upload-doc.yml index 6352e44d..b38a80e5 100644 --- a/.github/workflows/upload-doc.yml +++ b/.github/workflows/upload-doc.yml @@ -35,7 +35,7 @@ jobs: run: echo '' > target/doc/index.html - name: Deploy to GitHub Pages - uses: JamesIves/github-pages-deploy-action@v4.6.0 + uses: JamesIves/github-pages-deploy-action@v4.6.1 with: folder: target/doc single-commit: true From 1b214bc5f5160f8754f1e3fc77039156d7347793 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 20 May 2024 10:30:48 +0100 Subject: [PATCH 102/151] build(deps): bump codecov/codecov-action from 4.3.1 to 4.4.0 (#3374) Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 4.3.1 to 4.4.0. - [Release notes](https://github.com/codecov/codecov-action/releases) - [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/codecov/codecov-action/compare/v4.3.1...v4.4.0) --- updated-dependencies: - dependency-name: codecov/codecov-action dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/coverage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 5eaaae8b..ce370b10 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -31,7 +31,7 @@ jobs: run: cargo llvm-cov --workspace --all-features --codecov --output-path codecov.json - name: Upload coverage to Codecov - uses: codecov/codecov-action@v4.3.1 + uses: codecov/codecov-action@v4.4.0 with: files: codecov.json fail_ci_if_error: true From cc06fd6a5e6881885961156fc112e31f1ddcb5f4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 27 May 2024 00:57:59 +0000 Subject: [PATCH 103/151] build(deps): bump codecov/codecov-action from 4.4.0 to 4.4.1 (#3381) Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 4.4.0 to 4.4.1. - [Release notes](https://github.com/codecov/codecov-action/releases) - [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/codecov/codecov-action/compare/v4.4.0...v4.4.1) --- updated-dependencies: - dependency-name: codecov/codecov-action dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/coverage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index ce370b10..8d9494e3 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -31,7 +31,7 @@ jobs: run: cargo llvm-cov --workspace --all-features --codecov --output-path codecov.json - name: Upload coverage to Codecov - uses: codecov/codecov-action@v4.4.0 + uses: codecov/codecov-action@v4.4.1 with: files: codecov.json fail_ci_if_error: true From 26efa64278ccb0ec2a0d49f0364c9d7930bb57f5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 27 May 2024 00:58:18 +0000 Subject: [PATCH 104/151] build(deps): bump taiki-e/install-action from 2.33.26 to 2.33.34 (#3380) Bumps [taiki-e/install-action](https://github.com/taiki-e/install-action) from 2.33.26 to 2.33.34. - [Release notes](https://github.com/taiki-e/install-action/releases) - [Changelog](https://github.com/taiki-e/install-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/taiki-e/install-action/compare/v2.33.26...v2.33.34) --- updated-dependencies: - dependency-name: taiki-e/install-action dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/ci-post-merge.yml | 4 ++-- .github/workflows/ci.yml | 4 ++-- .github/workflows/coverage.yml | 2 +- .github/workflows/lint.yml | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci-post-merge.yml b/.github/workflows/ci-post-merge.yml index dfb0ca56..4e4f266b 100644 --- a/.github/workflows/ci-post-merge.yml +++ b/.github/workflows/ci-post-merge.yml @@ -49,7 +49,7 @@ jobs: toolchain: ${{ matrix.version.version }} - name: Install just, cargo-hack, cargo-nextest, cargo-ci-cache-clean - uses: taiki-e/install-action@v2.33.26 + uses: taiki-e/install-action@v2.33.34 with: tool: just,cargo-hack,cargo-nextest,cargo-ci-cache-clean @@ -80,7 +80,7 @@ jobs: uses: actions-rust-lang/setup-rust-toolchain@v1.8.0 - name: Install cargo-hack - uses: taiki-e/install-action@v2.33.26 + uses: taiki-e/install-action@v2.33.34 with: tool: cargo-hack diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 153ab78f..1f7a5d81 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -64,7 +64,7 @@ jobs: toolchain: ${{ matrix.version.version }} - name: Install just, cargo-hack, cargo-nextest, cargo-ci-cache-clean - uses: taiki-e/install-action@v2.33.26 + uses: taiki-e/install-action@v2.33.34 with: tool: just,cargo-hack,cargo-nextest,cargo-ci-cache-clean @@ -113,7 +113,7 @@ jobs: toolchain: nightly - name: Install just - uses: taiki-e/install-action@v2.33.26 + uses: taiki-e/install-action@v2.33.34 with: tool: just diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 8d9494e3..ff1767fb 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -23,7 +23,7 @@ jobs: components: llvm-tools-preview - name: Install cargo-llvm-cov - uses: taiki-e/install-action@v2.33.26 + uses: taiki-e/install-action@v2.33.34 with: tool: cargo-llvm-cov diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 39392fab..630f0604 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -82,7 +82,7 @@ jobs: toolchain: nightly-2024-04-26 - name: Install cargo-public-api - uses: taiki-e/install-action@v2.33.26 + uses: taiki-e/install-action@v2.33.34 with: tool: cargo-public-api From 3ce97effa22e4e9ad4dc719d7791b665abf2c9eb Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Tue, 28 May 2024 01:21:23 +0100 Subject: [PATCH 105/151] ci: delete upload doc workflow --- .github/workflows/coverage.yml | 4 ++-- .github/workflows/upload-doc.yml | 41 -------------------------------- 2 files changed, 2 insertions(+), 43 deletions(-) delete mode 100644 .github/workflows/upload-doc.yml diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index ff1767fb..d3467c69 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -22,10 +22,10 @@ jobs: with: components: llvm-tools-preview - - name: Install cargo-llvm-cov + - name: Install just,cargo-llvm-cov uses: taiki-e/install-action@v2.33.34 with: - tool: cargo-llvm-cov + tool: just,cargo-llvm-cov - name: Generate code coverage run: cargo llvm-cov --workspace --all-features --codecov --output-path codecov.json diff --git a/.github/workflows/upload-doc.yml b/.github/workflows/upload-doc.yml deleted file mode 100644 index b38a80e5..00000000 --- a/.github/workflows/upload-doc.yml +++ /dev/null @@ -1,41 +0,0 @@ -name: Upload Documentation - -on: - push: - branches: [master] - -permissions: - contents: read - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -jobs: - build: - permissions: - contents: write - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - - name: Install Rust - uses: actions-rust-lang/setup-rust-toolchain@v1.8.0 - with: - toolchain: nightly - - - name: Build Docs - run: cargo +nightly doc --no-deps --workspace --all-features - env: - RUSTDOCFLAGS: --cfg=docsrs - - - name: Tweak HTML - run: echo '' > target/doc/index.html - - - name: Deploy to GitHub Pages - uses: JamesIves/github-pages-deploy-action@v4.6.1 - with: - folder: target/doc - single-commit: true From dd84bcb6095aba3b95939a30b7209390ce90f9db Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 3 Jun 2024 02:24:09 +0100 Subject: [PATCH 106/151] build(deps): bump taiki-e/install-action from 2.33.34 to 2.34.0 (#3386) Bumps [taiki-e/install-action](https://github.com/taiki-e/install-action) from 2.33.34 to 2.34.0. - [Release notes](https://github.com/taiki-e/install-action/releases) - [Changelog](https://github.com/taiki-e/install-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/taiki-e/install-action/compare/v2.33.34...v2.34.0) --- updated-dependencies: - dependency-name: taiki-e/install-action dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/ci-post-merge.yml | 4 ++-- .github/workflows/ci.yml | 4 ++-- .github/workflows/coverage.yml | 2 +- .github/workflows/lint.yml | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci-post-merge.yml b/.github/workflows/ci-post-merge.yml index 4e4f266b..4231b4dc 100644 --- a/.github/workflows/ci-post-merge.yml +++ b/.github/workflows/ci-post-merge.yml @@ -49,7 +49,7 @@ jobs: toolchain: ${{ matrix.version.version }} - name: Install just, cargo-hack, cargo-nextest, cargo-ci-cache-clean - uses: taiki-e/install-action@v2.33.34 + uses: taiki-e/install-action@v2.34.0 with: tool: just,cargo-hack,cargo-nextest,cargo-ci-cache-clean @@ -80,7 +80,7 @@ jobs: uses: actions-rust-lang/setup-rust-toolchain@v1.8.0 - name: Install cargo-hack - uses: taiki-e/install-action@v2.33.34 + uses: taiki-e/install-action@v2.34.0 with: tool: cargo-hack diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1f7a5d81..ed2930bc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -64,7 +64,7 @@ jobs: toolchain: ${{ matrix.version.version }} - name: Install just, cargo-hack, cargo-nextest, cargo-ci-cache-clean - uses: taiki-e/install-action@v2.33.34 + uses: taiki-e/install-action@v2.34.0 with: tool: just,cargo-hack,cargo-nextest,cargo-ci-cache-clean @@ -113,7 +113,7 @@ jobs: toolchain: nightly - name: Install just - uses: taiki-e/install-action@v2.33.34 + uses: taiki-e/install-action@v2.34.0 with: tool: just diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index d3467c69..da892bd7 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -23,7 +23,7 @@ jobs: components: llvm-tools-preview - name: Install just,cargo-llvm-cov - uses: taiki-e/install-action@v2.33.34 + uses: taiki-e/install-action@v2.34.0 with: tool: just,cargo-llvm-cov diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 630f0604..62939698 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -82,7 +82,7 @@ jobs: toolchain: nightly-2024-04-26 - name: Install cargo-public-api - uses: taiki-e/install-action@v2.33.34 + uses: taiki-e/install-action@v2.34.0 with: tool: cargo-public-api From 5c18569b7896f0816b72efa172600a898e596281 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Fri, 7 Jun 2024 14:17:10 +0100 Subject: [PATCH 107/151] docs: align App:app_data arg name --- actix-web/src/app.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/actix-web/src/app.rs b/actix-web/src/app.rs index 1a3b7908..3d86d1f9 100644 --- a/actix-web/src/app.rs +++ b/actix-web/src/app.rs @@ -112,8 +112,8 @@ where /// }) /// ``` #[doc(alias = "manage")] - pub fn app_data(mut self, ext: U) -> Self { - self.extensions.insert(ext); + pub fn app_data(mut self, data: U) -> Self { + self.extensions.insert(data); self } From ebd8bb266d07828d3556ee10ee8a4c3d9bd0d98e Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Fri, 7 Jun 2024 14:31:17 +0100 Subject: [PATCH 108/151] ci: fix cargo-public-api --- .github/workflows/lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 62939698..d7a16ccb 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -79,7 +79,7 @@ jobs: - name: Install Rust uses: actions-rust-lang/setup-rust-toolchain@v1.8.0 with: - toolchain: nightly-2024-04-26 + toolchain: nightly-2024-06-07 - name: Install cargo-public-api uses: taiki-e/install-action@v2.34.0 From 85655f731d9d23f9b472b0a2ace817031c8c5e8d Mon Sep 17 00:00:00 2001 From: Abedi Date: Fri, 7 Jun 2024 17:25:29 +0330 Subject: [PATCH 109/151] From Boxed ResponseError impl added (#3388) * From Boxed ResponseError impl added * docs: update changelog --------- Co-authored-by: Rob Ede --- actix-web/CHANGES.md | 4 ++++ actix-web/src/error/error.rs | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/actix-web/CHANGES.md b/actix-web/CHANGES.md index 993c7c59..e0390563 100644 --- a/actix-web/CHANGES.md +++ b/actix-web/CHANGES.md @@ -2,6 +2,10 @@ ## Unreleased +### Added + +- Implement `From>` for `Error`. + ## 4.6.0 ### Added diff --git a/actix-web/src/error/error.rs b/actix-web/src/error/error.rs index 3a5a128f..670a58a0 100644 --- a/actix-web/src/error/error.rs +++ b/actix-web/src/error/error.rs @@ -60,6 +60,12 @@ impl From for Error { } } +impl From> for Error { + fn from(value: Box) -> Self { + Error { cause: value } + } +} + impl From for Response { fn from(err: Error) -> Response { err.error_response().into() From b2d0196f342f0f90a9e9e32584f0826bebed4891 Mon Sep 17 00:00:00 2001 From: Dylan Anthony <43723790+dbanty@users.noreply.github.com> Date: Fri, 7 Jun 2024 08:08:13 -0600 Subject: [PATCH 110/151] Do not require actix-router default features from actix-web-codegen (#3372) * fix: Do not require actix-router default features from actix-web-codegen * docs: update changelog * test: update trybuild stderr --------- Co-authored-by: Dylan Anthony Co-authored-by: Rob Ede --- actix-web-codegen/CHANGES.md | 1 + actix-web-codegen/Cargo.toml | 2 +- .../tests/trybuild/route-malformed-path-fail.stderr | 5 +---- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/actix-web-codegen/CHANGES.md b/actix-web-codegen/CHANGES.md index a5acdd21..875c4021 100644 --- a/actix-web-codegen/CHANGES.md +++ b/actix-web-codegen/CHANGES.md @@ -2,6 +2,7 @@ ## Unreleased +- Prevent inclusion of default `actix-router` features. - Minimum supported Rust version (MSRV) is now 1.72. ## 4.2.2 diff --git a/actix-web-codegen/Cargo.toml b/actix-web-codegen/Cargo.toml index 4a45d4fe..31c47069 100644 --- a/actix-web-codegen/Cargo.toml +++ b/actix-web-codegen/Cargo.toml @@ -16,7 +16,7 @@ rust-version.workspace = true proc-macro = true [dependencies] -actix-router = "0.5" +actix-router = { version = "0.5", default-features = false } proc-macro2 = "1" quote = "1" syn = { version = "2", features = ["full", "extra-traits"] } diff --git a/actix-web-codegen/tests/trybuild/route-malformed-path-fail.stderr b/actix-web-codegen/tests/trybuild/route-malformed-path-fail.stderr index 93c51010..c1100c78 100644 --- a/actix-web-codegen/tests/trybuild/route-malformed-path-fail.stderr +++ b/actix-web-codegen/tests/trybuild/route-malformed-path-fail.stderr @@ -20,10 +20,7 @@ error: custom attribute panicked 13 | #[get("/{}")] | ^^^^^^^^^^^^^ | - = help: message: Wrong path pattern: "/{}" regex parse error: - ((?s-m)^/(?P<>[^/]+))$ - ^ - error: empty capture group name + = help: message: Wrong path pattern: "/{}" empty capture group names are not allowed error: custom attribute panicked --> $DIR/route-malformed-path-fail.rs:23:1 From 8fdf35895478b2ed5f08651e123922c012ae2937 Mon Sep 17 00:00:00 2001 From: Raphael C Date: Fri, 7 Jun 2024 16:31:53 +0200 Subject: [PATCH 111/151] Add app_data method to GuardContext (#3341) * changes: guard * fix(guard): docs link to app_data * docs: fix changelog --------- Co-authored-by: Rob Ede --- actix-web/CHANGES.md | 1 + actix-web/src/guard/mod.rs | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/actix-web/CHANGES.md b/actix-web/CHANGES.md index e0390563..757fdce6 100644 --- a/actix-web/CHANGES.md +++ b/actix-web/CHANGES.md @@ -4,6 +4,7 @@ ### Added +- Add `guard::GuardContext::app_data()` method. - Implement `From>` for `Error`. ## 4.6.0 diff --git a/actix-web/src/guard/mod.rs b/actix-web/src/guard/mod.rs index 9451a60f..41609953 100644 --- a/actix-web/src/guard/mod.rs +++ b/actix-web/src/guard/mod.rs @@ -110,6 +110,12 @@ impl<'a> GuardContext<'a> { pub fn header(&self) -> Option { H::parse(self.req).ok() } + + /// Counterpart to [HttpRequest::app_data](crate::HttpRequest::app_data). + #[inline] + pub fn app_data(&self) -> Option<&T> { + self.req.app_data() + } } /// Interface for routing guards. @@ -512,4 +518,18 @@ mod tests { .to_srv_request(); assert!(guard.check(&req.guard_ctx())); } + + #[test] + fn app_data() { + const TEST_VALUE: u32 = 42; + let guard = fn_guard(|ctx| dbg!(ctx.app_data::()) == Some(&TEST_VALUE)); + + let req = TestRequest::default().app_data(TEST_VALUE).to_srv_request(); + assert!(guard.check(&req.guard_ctx())); + + let req = TestRequest::default() + .app_data(TEST_VALUE * 2) + .to_srv_request(); + assert!(!guard.check(&req.guard_ctx())); + } } From 8b4d23a69a0cdf5ac9a32d59ab2b3cbb21b71ffa Mon Sep 17 00:00:00 2001 From: Matt Palmer Date: Sat, 8 Jun 2024 00:40:55 +1000 Subject: [PATCH 112/151] Allow disabling redirect following in actix-test (#3356) If you're testing that redirects are being properly generated, then it's useful to not have the client go off on a wild goose chase of its own. Co-authored-by: Rob Ede --- actix-test/CHANGES.md | 3 ++- actix-test/src/lib.rs | 21 ++++++++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/actix-test/CHANGES.md b/actix-test/CHANGES.md index b55a8305..940b595c 100644 --- a/actix-test/CHANGES.md +++ b/actix-test/CHANGES.md @@ -3,8 +3,9 @@ ## Unreleased - Add `TestServerConfig::rustls_0_23()` method for Rustls v0.23 support behind new `rustls-0_23` crate feature. -- Minimum supported Rust version (MSRV) is now 1.72. +- Add `TestServerConfig::disable_redirects()` method. - Various types from `awc`, such as `ClientRequest` and `ClientResponse`, are now re-exported. +- Minimum supported Rust version (MSRV) is now 1.72. ## 0.1.3 diff --git a/actix-test/src/lib.rs b/actix-test/src/lib.rs index 1c3d8ff1..433f1457 100644 --- a/actix-test/src/lib.rs +++ b/actix-test/src/lib.rs @@ -149,6 +149,8 @@ where StreamType::Rustls023(_) => true, }; + let client_cfg = cfg.clone(); + // run server in separate orphaned thread thread::spawn(move || { rt::System::new().block_on(async move { @@ -460,7 +462,13 @@ where } }; - Client::builder().connector(connector).finish() + let mut client_builder = Client::builder().connector(connector); + + if client_cfg.disable_redirects { + client_builder = client_builder.disable_redirects(); + } + + client_builder.finish() }; TestServer { @@ -507,6 +515,7 @@ pub struct TestServerConfig { client_request_timeout: Duration, port: u16, workers: usize, + disable_redirects: bool, } impl Default for TestServerConfig { @@ -524,6 +533,7 @@ impl TestServerConfig { client_request_timeout: Duration::from_secs(5), port: 0, workers: 1, + disable_redirects: false, } } @@ -611,6 +621,15 @@ impl TestServerConfig { self.workers = workers; self } + + /// Instruct the client to not follow redirects. + /// + /// By default, the client will follow up to 10 consecutive redirects + /// before giving up. + pub fn disable_redirects(mut self) -> Self { + self.disable_redirects = true; + self + } } /// A basic HTTP server controller that simplifies the process of writing integration tests for From 4493aa35d006c8a479db2b1410802461655eba25 Mon Sep 17 00:00:00 2001 From: asonix Date: Fri, 7 Jun 2024 09:41:32 -0500 Subject: [PATCH 113/151] actix-http::ws: Remove redundant + 4 byte reservation when masked (#3371) * actix-http::ws: Remove redundant + 4 byte reservation when masked * actix-http: Update CHANGES wrt byte fix * docs: remove changelog entry --------- Co-authored-by: Rob Ede --- actix-http/src/ws/frame.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/actix-http/src/ws/frame.rs b/actix-http/src/ws/frame.rs index c9fb0cde..35b3f8e6 100644 --- a/actix-http/src/ws/frame.rs +++ b/actix-http/src/ws/frame.rs @@ -178,14 +178,14 @@ impl Parser { }; if payload_len < 126 { - dst.reserve(p_len + 2 + if mask { 4 } else { 0 }); + dst.reserve(p_len + 2); dst.put_slice(&[one, two | payload_len as u8]); } else if payload_len <= 65_535 { - dst.reserve(p_len + 4 + if mask { 4 } else { 0 }); + dst.reserve(p_len + 4); dst.put_slice(&[one, two | 126]); dst.put_u16(payload_len as u16); } else { - dst.reserve(p_len + 10 + if mask { 4 } else { 0 }); + dst.reserve(p_len + 10); dst.put_slice(&[one, two | 127]); dst.put_u64(payload_len as u64); }; From 5221c1b19452cd98fa03882374295b56fa9af327 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Fri, 7 Jun 2024 14:51:05 +0100 Subject: [PATCH 114/151] ci: pin msrv lookup job --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ed2930bc..ab611fc0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,7 +18,7 @@ concurrency: jobs: read_msrv: name: Read MSRV - uses: actions-rust-lang/msrv/.github/workflows/msrv.yml@main + uses: actions-rust-lang/msrv/.github/workflows/msrv.yml@v0.1.0 build_and_test: needs: read_msrv From b9305ff59db29f6ce20740ef2ad5db3e4b60ffe5 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Fri, 7 Jun 2024 16:04:04 +0100 Subject: [PATCH 115/151] chore: fmt --- actix-multipart/README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/actix-multipart/README.md b/actix-multipart/README.md index 83947b0c..35c7f9a1 100644 --- a/actix-multipart/README.md +++ b/actix-multipart/README.md @@ -15,7 +15,6 @@ - ## Example Dependencies: @@ -65,6 +64,7 @@ async fn main() -> std::io::Result<()> { ``` Curl request : + ```bash curl -v --request POST \ --url http://localhost:8080/videos \ @@ -72,7 +72,6 @@ curl -v --request POST \ -F file=@./Cargo.lock ``` - ### Examples -https://github.com/actix/examples/tree/master/forms/multipart \ No newline at end of file +https://github.com/actix/examples/tree/master/forms/multipart From cff958e5187b4980d8a87c2a886a284ccbd3d9b2 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Fri, 7 Jun 2024 16:10:25 +0100 Subject: [PATCH 116/151] chore: address clippy lint --- actix-test/src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/actix-test/src/lib.rs b/actix-test/src/lib.rs index 433f1457..48d5079a 100644 --- a/actix-test/src/lib.rs +++ b/actix-test/src/lib.rs @@ -488,6 +488,7 @@ enum HttpVer { Both, } +#[allow(clippy::large_enum_variant)] #[derive(Clone)] enum StreamType { Tcp, From 534cfe1fda1d65b9cea7d75a0a8c55f46439bb4e Mon Sep 17 00:00:00 2001 From: Sebastian Detert Date: Fri, 7 Jun 2024 17:22:48 +0200 Subject: [PATCH 117/151] feat: add .customize().add_cookie() (#3215) * feat: add .customize().add_cookie() * docs: added cookie hint * fix: added unwrap to test of add_cookie() * docs: added changelog entry for .customize().add_cookie() * chore: make append_header infallible * docs: update changelog --------- Co-authored-by: Rob Ede --- actix-web/CHANGES.md | 1 + actix-web/src/response/customize_responder.rs | 42 ++++++++++++++++++- 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/actix-web/CHANGES.md b/actix-web/CHANGES.md index 757fdce6..75f3631c 100644 --- a/actix-web/CHANGES.md +++ b/actix-web/CHANGES.md @@ -4,6 +4,7 @@ ### Added +- Add `CustomizeResponder::add_cookie()` method. - Add `guard::GuardContext::app_data()` method. - Implement `From>` for `Error`. diff --git a/actix-web/src/response/customize_responder.rs b/actix-web/src/response/customize_responder.rs index 4cbd96e2..6a43ac5e 100644 --- a/actix-web/src/response/customize_responder.rs +++ b/actix-web/src/response/customize_responder.rs @@ -7,7 +7,7 @@ use actix_http::{ use crate::{HttpRequest, HttpResponse, Responder}; -/// Allows overriding status code and headers for a [`Responder`]. +/// Allows overriding status code and headers (including cookies) for a [`Responder`]. /// /// Created by calling the [`customize`](Responder::customize) method on a [`Responder`] type. pub struct CustomizeResponder { @@ -137,6 +137,29 @@ impl CustomizeResponder { Some(&mut self.inner) } } + + /// Appends a `cookie` to the final response. + /// + /// # Errors + /// + /// Final response will be an error if `cookie` cannot be converted into a valid header value. + #[cfg(feature = "cookies")] + pub fn add_cookie(mut self, cookie: &crate::cookie::Cookie<'_>) -> Self { + use actix_http::header::{TryIntoHeaderValue as _, SET_COOKIE}; + + if let Some(inner) = self.inner() { + match cookie.to_string().try_into_value() { + Ok(val) => { + inner.append_headers.append(SET_COOKIE, val); + } + Err(err) => { + self.error = Some(err.into()); + } + } + } + + self + } } impl Responder for CustomizeResponder @@ -175,6 +198,7 @@ mod tests { use super::*; use crate::{ + cookie::Cookie, http::header::{HeaderValue, CONTENT_TYPE}, test::TestRequest, }; @@ -209,6 +233,22 @@ mod tests { to_bytes(res.into_body()).await.unwrap(), Bytes::from_static(b"test"), ); + + let res = "test" + .to_string() + .customize() + .add_cookie(&Cookie::new("name", "value")) + .respond_to(&req); + + assert!(res.status().is_success()); + assert_eq!( + res.cookies().collect::>>(), + vec![Cookie::new("name", "value")], + ); + assert_eq!( + to_bytes(res.into_body()).await.unwrap(), + Bytes::from_static(b"test"), + ); } #[actix_rt::test] From c366649516dcd1d780ca8b7938397dac61338c15 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Fri, 7 Jun 2024 16:57:03 +0100 Subject: [PATCH 118/151] docs: example of CPU core pinning --- actix-web/Cargo.toml | 2 +- actix-web/examples/worker-cpu-pin.rs | 41 ++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 actix-web/examples/worker-cpu-pin.rs diff --git a/actix-web/Cargo.toml b/actix-web/Cargo.toml index 9f3ab6e5..a666f14b 100644 --- a/actix-web/Cargo.toml +++ b/actix-web/Cargo.toml @@ -35,7 +35,6 @@ features = [ "secure-cookies", ] - [lib] name = "actix_web" path = "src/lib.rs" @@ -130,6 +129,7 @@ awc = { version = "3", features = ["openssl"] } brotli = "6" const-str = "0.5" +core_affinity = "0.8" criterion = { version = "0.5", features = ["html_reports"] } env_logger = "0.11" flate2 = "1.0.13" diff --git a/actix-web/examples/worker-cpu-pin.rs b/actix-web/examples/worker-cpu-pin.rs new file mode 100644 index 00000000..58e06082 --- /dev/null +++ b/actix-web/examples/worker-cpu-pin.rs @@ -0,0 +1,41 @@ +use std::{ + io, + sync::{ + atomic::{AtomicUsize, Ordering}, + Arc, + }, + thread, +}; + +use actix_web::{middleware, web, App, HttpServer}; + +async fn hello() -> &'static str { + "Hello world!" +} + +#[actix_web::main] +async fn main() -> io::Result<()> { + env_logger::init_from_env(env_logger::Env::new().default_filter_or("info")); + + let core_ids = core_affinity::get_core_ids().unwrap(); + let n_core_ids = core_ids.len(); + let next_core_id = Arc::new(AtomicUsize::new(0)); + + HttpServer::new(move || { + let pin = Arc::clone(&next_core_id).fetch_add(1, Ordering::AcqRel); + log::info!( + "setting CPU affinity for worker {}: pinning to core {}", + thread::current().name().unwrap(), + pin, + ); + core_affinity::set_for_current(core_ids[pin]); + + App::new() + .wrap(middleware::Logger::default()) + .service(web::resource("/").get(hello)) + }) + .bind(("127.0.0.1", 8080))? + .workers(n_core_ids) + .run() + .await +} From 3db7891303093d5992cfd3483405b80b495b8f8e Mon Sep 17 00:00:00 2001 From: Jonathan Lim Date: Fri, 7 Jun 2024 15:10:48 -0700 Subject: [PATCH 119/151] Scope macro (#3136) * add scope proc macro * Update scope macro code to work with current HttpServiceFactory * started some test code * add some unit tests * code formatting cleanup * add another test for combining and calling 2 scopes * format code with formatter * Update actix-web-codegen/src/lib.rs with comment documentation fix Co-authored-by: oliver <151407407+kwfn@users.noreply.github.com> * work in progress. revised procedural macro to change othe macro call * add tests again. refactor nested code. * clean up code. fix bugs with route and method attributes with parameters * clean up for rust fmt * clean up for rust fmt * fix out of date comment for scope macro * sync to master branch by adding test_wrap * needed to format code * test: split out scope tests * test: add negative tests * chore: move imports back inside (?) * docs: tweak scope docs * fix: prevent trailing slashes in scope prefixes * chore: address clippy lints --------- Co-authored-by: oliver <151407407+kwfn@users.noreply.github.com> Co-authored-by: Rob Ede --- actix-web-codegen/CHANGES.md | 1 + actix-web-codegen/src/lib.rs | 50 +++++ actix-web-codegen/src/route.rs | 20 +- actix-web-codegen/src/scope.rs | 103 +++++++++ .../tests/{test_macro.rs => routes.rs} | 0 actix-web-codegen/tests/scopes.rs | 200 ++++++++++++++++++ actix-web-codegen/tests/trybuild.rs | 5 + .../tests/trybuild/scope-invalid-args.rs | 14 ++ .../tests/trybuild/scope-invalid-args.stderr | 17 ++ .../tests/trybuild/scope-missing-args.rs | 6 + .../tests/trybuild/scope-missing-args.stderr | 7 + .../tests/trybuild/scope-on-handler.rs | 8 + .../tests/trybuild/scope-on-handler.stderr | 5 + .../tests/trybuild/scope-trailing-slash.rs | 6 + .../trybuild/scope-trailing-slash.stderr | 5 + actix-web/src/lib.rs | 1 + awc/src/client/connector.rs | 2 +- justfile | 6 +- 18 files changed, 439 insertions(+), 17 deletions(-) create mode 100644 actix-web-codegen/src/scope.rs rename actix-web-codegen/tests/{test_macro.rs => routes.rs} (100%) create mode 100644 actix-web-codegen/tests/scopes.rs create mode 100644 actix-web-codegen/tests/trybuild/scope-invalid-args.rs create mode 100644 actix-web-codegen/tests/trybuild/scope-invalid-args.stderr create mode 100644 actix-web-codegen/tests/trybuild/scope-missing-args.rs create mode 100644 actix-web-codegen/tests/trybuild/scope-missing-args.stderr create mode 100644 actix-web-codegen/tests/trybuild/scope-on-handler.rs create mode 100644 actix-web-codegen/tests/trybuild/scope-on-handler.stderr create mode 100644 actix-web-codegen/tests/trybuild/scope-trailing-slash.rs create mode 100644 actix-web-codegen/tests/trybuild/scope-trailing-slash.stderr diff --git a/actix-web-codegen/CHANGES.md b/actix-web-codegen/CHANGES.md index 875c4021..792f6aa4 100644 --- a/actix-web-codegen/CHANGES.md +++ b/actix-web-codegen/CHANGES.md @@ -2,6 +2,7 @@ ## Unreleased +- Add `#[scope]` macro. - Prevent inclusion of default `actix-router` features. - Minimum supported Rust version (MSRV) is now 1.72. diff --git a/actix-web-codegen/src/lib.rs b/actix-web-codegen/src/lib.rs index 6d6c9ab5..c518007a 100644 --- a/actix-web-codegen/src/lib.rs +++ b/actix-web-codegen/src/lib.rs @@ -83,6 +83,7 @@ use proc_macro::TokenStream; use quote::quote; mod route; +mod scope; /// Creates resource handler, allowing multiple HTTP method guards. /// @@ -197,6 +198,43 @@ method_macro!(Options, options); method_macro!(Trace, trace); method_macro!(Patch, patch); +/// Prepends a path prefix to all handlers using routing macros inside the attached module. +/// +/// # Syntax +/// +/// ``` +/// # use actix_web_codegen::scope; +/// #[scope("/prefix")] +/// mod api { +/// // ... +/// } +/// ``` +/// +/// # Arguments +/// +/// - `"/prefix"` - Raw literal string to be prefixed onto contained handlers' paths. +/// +/// # Example +/// +/// ``` +/// # use actix_web_codegen::{scope, get}; +/// # use actix_web::Responder; +/// #[scope("/api")] +/// mod api { +/// # use super::*; +/// #[get("/hello")] +/// pub async fn hello() -> impl Responder { +/// // this has path /api/hello +/// "Hello, world!" +/// } +/// } +/// # fn main() {} +/// ``` +#[proc_macro_attribute] +pub fn scope(args: TokenStream, input: TokenStream) -> TokenStream { + scope::with_scope(args, input) +} + /// Marks async main function as the Actix Web system entry-point. /// /// Note that Actix Web also works under `#[tokio::main]` since version 4.0. However, this macro is @@ -240,3 +278,15 @@ pub fn test(_: TokenStream, item: TokenStream) -> TokenStream { output.extend(item); output } + +/// Converts the error to a token stream and appends it to the original input. +/// +/// Returning the original input in addition to the error is good for IDEs which can gracefully +/// recover and show more precise errors within the macro body. +/// +/// See for more info. +fn input_and_compile_error(mut item: TokenStream, err: syn::Error) -> TokenStream { + let compile_err = TokenStream::from(err.to_compile_error()); + item.extend(compile_err); + item +} diff --git a/actix-web-codegen/src/route.rs b/actix-web-codegen/src/route.rs index 7a2dfc05..d0605fc0 100644 --- a/actix-web-codegen/src/route.rs +++ b/actix-web-codegen/src/route.rs @@ -6,10 +6,12 @@ use proc_macro2::{Span, TokenStream as TokenStream2}; use quote::{quote, ToTokens, TokenStreamExt}; use syn::{punctuated::Punctuated, Ident, LitStr, Path, Token}; +use crate::input_and_compile_error; + #[derive(Debug)] pub struct RouteArgs { - path: syn::LitStr, - options: Punctuated, + pub(crate) path: syn::LitStr, + pub(crate) options: Punctuated, } impl syn::parse::Parse for RouteArgs { @@ -78,7 +80,7 @@ macro_rules! standard_method_type { } } - fn from_path(method: &Path) -> Result { + pub(crate) fn from_path(method: &Path) -> Result { match () { $(_ if method.is_ident(stringify!($lower)) => Ok(Self::$variant),)+ _ => Err(()), @@ -542,15 +544,3 @@ pub(crate) fn with_methods(input: TokenStream) -> TokenStream { Err(err) => input_and_compile_error(input, err), } } - -/// Converts the error to a token stream and appends it to the original input. -/// -/// Returning the original input in addition to the error is good for IDEs which can gracefully -/// recover and show more precise errors within the macro body. -/// -/// See for more info. -fn input_and_compile_error(mut item: TokenStream, err: syn::Error) -> TokenStream { - let compile_err = TokenStream::from(err.to_compile_error()); - item.extend(compile_err); - item -} diff --git a/actix-web-codegen/src/scope.rs b/actix-web-codegen/src/scope.rs new file mode 100644 index 00000000..067d95a6 --- /dev/null +++ b/actix-web-codegen/src/scope.rs @@ -0,0 +1,103 @@ +use proc_macro::TokenStream; +use proc_macro2::{Span, TokenStream as TokenStream2}; +use quote::{quote, ToTokens as _}; + +use crate::{ + input_and_compile_error, + route::{MethodType, RouteArgs}, +}; + +pub fn with_scope(args: TokenStream, input: TokenStream) -> TokenStream { + match with_scope_inner(args, input.clone()) { + Ok(stream) => stream, + Err(err) => input_and_compile_error(input, err), + } +} + +fn with_scope_inner(args: TokenStream, input: TokenStream) -> syn::Result { + if args.is_empty() { + return Err(syn::Error::new( + Span::call_site(), + "missing arguments for scope macro, expected: #[scope(\"/prefix\")]", + )); + } + + let scope_prefix = syn::parse::(args.clone()).map_err(|err| { + syn::Error::new( + err.span(), + "argument to scope macro is not a string literal, expected: #[scope(\"/prefix\")]", + ) + })?; + + let scope_prefix_value = scope_prefix.value(); + + if scope_prefix_value.ends_with('/') { + // trailing slashes cause non-obvious problems + // it's better to point them out to developers rather than + + return Err(syn::Error::new( + scope_prefix.span(), + "scopes should not have trailing slashes; see https://docs.rs/actix-web/4/actix_web/struct.Scope.html#avoid-trailing-slashes", + )); + } + + let mut module = syn::parse::(input).map_err(|err| { + syn::Error::new(err.span(), "#[scope] macro must be attached to a module") + })?; + + // modify any routing macros (method or route[s]) attached to + // functions by prefixing them with this scope macro's argument + if let Some((_, items)) = &mut module.content { + for item in items { + if let syn::Item::Fn(fun) = item { + fun.attrs = fun + .attrs + .iter() + .map(|attr| modify_attribute_with_scope(attr, &scope_prefix_value)) + .collect(); + } + } + } + + Ok(module.to_token_stream().into()) +} + +/// Checks if the attribute is a method type and has a route path, then modifies it. +fn modify_attribute_with_scope(attr: &syn::Attribute, scope_path: &str) -> syn::Attribute { + match (attr.parse_args::(), attr.clone().meta) { + (Ok(route_args), syn::Meta::List(meta_list)) if has_allowed_methods_in_scope(attr) => { + let modified_path = format!("{}{}", scope_path, route_args.path.value()); + + let options_tokens: Vec = route_args + .options + .iter() + .map(|option| { + quote! { ,#option } + }) + .collect(); + + let combined_options_tokens: TokenStream2 = + options_tokens + .into_iter() + .fold(TokenStream2::new(), |mut acc, ts| { + acc.extend(std::iter::once(ts)); + acc + }); + + syn::Attribute { + meta: syn::Meta::List(syn::MetaList { + tokens: quote! { #modified_path #combined_options_tokens }, + ..meta_list.clone() + }), + ..attr.clone() + } + } + _ => attr.clone(), + } +} + +fn has_allowed_methods_in_scope(attr: &syn::Attribute) -> bool { + MethodType::from_path(attr.path()).is_ok() + || attr.path().is_ident("route") + || attr.path().is_ident("ROUTE") +} diff --git a/actix-web-codegen/tests/test_macro.rs b/actix-web-codegen/tests/routes.rs similarity index 100% rename from actix-web-codegen/tests/test_macro.rs rename to actix-web-codegen/tests/routes.rs diff --git a/actix-web-codegen/tests/scopes.rs b/actix-web-codegen/tests/scopes.rs new file mode 100644 index 00000000..6a370a2e --- /dev/null +++ b/actix-web-codegen/tests/scopes.rs @@ -0,0 +1,200 @@ +use actix_web::{guard::GuardContext, http, http::header, web, App, HttpResponse, Responder}; +use actix_web_codegen::{delete, get, post, route, routes, scope}; + +pub fn image_guard(ctx: &GuardContext) -> bool { + ctx.header::() + .map(|h| h.preference() == "image/*") + .unwrap_or(false) +} + +#[scope("/test")] +mod scope_module { + // ensure that imports can be brought into the scope + use super::*; + + #[get("/test/guard", guard = "image_guard")] + pub async fn guard() -> impl Responder { + HttpResponse::Ok() + } + + #[get("/test")] + pub async fn test() -> impl Responder { + HttpResponse::Ok().finish() + } + + #[get("/twice-test/{value}")] + pub async fn twice(value: web::Path) -> impl actix_web::Responder { + let int_value: i32 = value.parse().unwrap_or(0); + let doubled = int_value * 2; + HttpResponse::Ok().body(format!("Twice value: {}", doubled)) + } + + #[post("/test")] + pub async fn post() -> impl Responder { + HttpResponse::Ok().body("post works") + } + + #[delete("/test")] + pub async fn delete() -> impl Responder { + "delete works" + } + + #[route("/test", method = "PUT", method = "PATCH", method = "CUSTOM")] + pub async fn multiple_shared_path() -> impl Responder { + HttpResponse::Ok().finish() + } + + #[routes] + #[head("/test1")] + #[connect("/test2")] + #[options("/test3")] + #[trace("/test4")] + async fn multiple_separate_paths() -> impl Responder { + HttpResponse::Ok().finish() + } + + // test calling this from other mod scope with scope attribute... + pub fn mod_common(message: String) -> impl actix_web::Responder { + HttpResponse::Ok().body(message) + } +} + +/// Scope doc string to check in cargo expand. +#[scope("/v1")] +mod mod_scope_v1 { + use super::*; + + /// Route doc string to check in cargo expand. + #[get("/test")] + pub async fn test() -> impl Responder { + scope_module::mod_common("version1 works".to_string()) + } +} + +#[scope("/v2")] +mod mod_scope_v2 { + use super::*; + + // check to make sure non-function tokens in the scope block are preserved... + enum TestEnum { + Works, + } + + #[get("/test")] + pub async fn test() -> impl Responder { + // make sure this type still exists... + let test_enum = TestEnum::Works; + + match test_enum { + TestEnum::Works => scope_module::mod_common("version2 works".to_string()), + } + } +} + +#[actix_rt::test] +async fn scope_get_async() { + let srv = actix_test::start(|| App::new().service(scope_module::test)); + + let request = srv.request(http::Method::GET, srv.url("/test/test")); + let response = request.send().await.unwrap(); + assert!(response.status().is_success()); +} + +#[actix_rt::test] +async fn scope_get_param_async() { + let srv = actix_test::start(|| App::new().service(scope_module::twice)); + + let request = srv.request(http::Method::GET, srv.url("/test/twice-test/4")); + let mut response = request.send().await.unwrap(); + let body = response.body().await.unwrap(); + let body_str = String::from_utf8(body.to_vec()).unwrap(); + assert_eq!(body_str, "Twice value: 8"); +} + +#[actix_rt::test] +async fn scope_post_async() { + let srv = actix_test::start(|| App::new().service(scope_module::post)); + + let request = srv.request(http::Method::POST, srv.url("/test/test")); + let mut response = request.send().await.unwrap(); + let body = response.body().await.unwrap(); + let body_str = String::from_utf8(body.to_vec()).unwrap(); + assert_eq!(body_str, "post works"); +} + +#[actix_rt::test] +async fn multiple_shared_path_async() { + let srv = actix_test::start(|| App::new().service(scope_module::multiple_shared_path)); + + let request = srv.request(http::Method::PUT, srv.url("/test/test")); + let response = request.send().await.unwrap(); + assert!(response.status().is_success()); + + let request = srv.request(http::Method::PATCH, srv.url("/test/test")); + let response = request.send().await.unwrap(); + assert!(response.status().is_success()); +} + +#[actix_rt::test] +async fn multiple_multi_path_async() { + let srv = actix_test::start(|| App::new().service(scope_module::multiple_separate_paths)); + + let request = srv.request(http::Method::HEAD, srv.url("/test/test1")); + let response = request.send().await.unwrap(); + assert!(response.status().is_success()); + + let request = srv.request(http::Method::CONNECT, srv.url("/test/test2")); + let response = request.send().await.unwrap(); + assert!(response.status().is_success()); + + let request = srv.request(http::Method::OPTIONS, srv.url("/test/test3")); + let response = request.send().await.unwrap(); + assert!(response.status().is_success()); + + let request = srv.request(http::Method::TRACE, srv.url("/test/test4")); + let response = request.send().await.unwrap(); + assert!(response.status().is_success()); +} + +#[actix_rt::test] +async fn scope_delete_async() { + let srv = actix_test::start(|| App::new().service(scope_module::delete)); + + let request = srv.request(http::Method::DELETE, srv.url("/test/test")); + let mut response = request.send().await.unwrap(); + let body = response.body().await.unwrap(); + let body_str = String::from_utf8(body.to_vec()).unwrap(); + assert_eq!(body_str, "delete works"); +} + +#[actix_rt::test] +async fn scope_get_with_guard_async() { + let srv = actix_test::start(|| App::new().service(scope_module::guard)); + + let request = srv + .request(http::Method::GET, srv.url("/test/test/guard")) + .insert_header(("Accept", "image/*")); + let response = request.send().await.unwrap(); + assert!(response.status().is_success()); +} + +#[actix_rt::test] +async fn scope_v1_v2_async() { + let srv = actix_test::start(|| { + App::new() + .service(mod_scope_v1::test) + .service(mod_scope_v2::test) + }); + + let request = srv.request(http::Method::GET, srv.url("/v1/test")); + let mut response = request.send().await.unwrap(); + let body = response.body().await.unwrap(); + let body_str = String::from_utf8(body.to_vec()).unwrap(); + assert_eq!(body_str, "version1 works"); + + let request = srv.request(http::Method::GET, srv.url("/v2/test")); + let mut response = request.send().await.unwrap(); + let body = response.body().await.unwrap(); + let body_str = String::from_utf8(body.to_vec()).unwrap(); + assert_eq!(body_str, "version2 works"); +} diff --git a/actix-web-codegen/tests/trybuild.rs b/actix-web-codegen/tests/trybuild.rs index 88f77548..91073cf3 100644 --- a/actix-web-codegen/tests/trybuild.rs +++ b/actix-web-codegen/tests/trybuild.rs @@ -18,6 +18,11 @@ fn compile_macros() { t.compile_fail("tests/trybuild/routes-missing-method-fail.rs"); t.compile_fail("tests/trybuild/routes-missing-args-fail.rs"); + t.compile_fail("tests/trybuild/scope-on-handler.rs"); + t.compile_fail("tests/trybuild/scope-missing-args.rs"); + t.compile_fail("tests/trybuild/scope-invalid-args.rs"); + t.compile_fail("tests/trybuild/scope-trailing-slash.rs"); + t.pass("tests/trybuild/docstring-ok.rs"); t.pass("tests/trybuild/test-runtime.rs"); diff --git a/actix-web-codegen/tests/trybuild/scope-invalid-args.rs b/actix-web-codegen/tests/trybuild/scope-invalid-args.rs new file mode 100644 index 00000000..ec021d5e --- /dev/null +++ b/actix-web-codegen/tests/trybuild/scope-invalid-args.rs @@ -0,0 +1,14 @@ +use actix_web_codegen::scope; + +const PATH: &str = "/api"; + +#[scope(PATH)] +mod api_const {} + +#[scope(true)] +mod api_bool {} + +#[scope(123)] +mod api_num {} + +fn main() {} diff --git a/actix-web-codegen/tests/trybuild/scope-invalid-args.stderr b/actix-web-codegen/tests/trybuild/scope-invalid-args.stderr new file mode 100644 index 00000000..0ab33596 --- /dev/null +++ b/actix-web-codegen/tests/trybuild/scope-invalid-args.stderr @@ -0,0 +1,17 @@ +error: argument to scope macro is not a string literal, expected: #[scope("/prefix")] + --> tests/trybuild/scope-invalid-args.rs:5:9 + | +5 | #[scope(PATH)] + | ^^^^ + +error: argument to scope macro is not a string literal, expected: #[scope("/prefix")] + --> tests/trybuild/scope-invalid-args.rs:8:9 + | +8 | #[scope(true)] + | ^^^^ + +error: argument to scope macro is not a string literal, expected: #[scope("/prefix")] + --> tests/trybuild/scope-invalid-args.rs:11:9 + | +11 | #[scope(123)] + | ^^^ diff --git a/actix-web-codegen/tests/trybuild/scope-missing-args.rs b/actix-web-codegen/tests/trybuild/scope-missing-args.rs new file mode 100644 index 00000000..39bcb9d1 --- /dev/null +++ b/actix-web-codegen/tests/trybuild/scope-missing-args.rs @@ -0,0 +1,6 @@ +use actix_web_codegen::scope; + +#[scope] +mod api {} + +fn main() {} diff --git a/actix-web-codegen/tests/trybuild/scope-missing-args.stderr b/actix-web-codegen/tests/trybuild/scope-missing-args.stderr new file mode 100644 index 00000000..d59842e3 --- /dev/null +++ b/actix-web-codegen/tests/trybuild/scope-missing-args.stderr @@ -0,0 +1,7 @@ +error: missing arguments for scope macro, expected: #[scope("/prefix")] + --> tests/trybuild/scope-missing-args.rs:3:1 + | +3 | #[scope] + | ^^^^^^^^ + | + = note: this error originates in the attribute macro `scope` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/actix-web-codegen/tests/trybuild/scope-on-handler.rs b/actix-web-codegen/tests/trybuild/scope-on-handler.rs new file mode 100644 index 00000000..e5d47898 --- /dev/null +++ b/actix-web-codegen/tests/trybuild/scope-on-handler.rs @@ -0,0 +1,8 @@ +use actix_web_codegen::scope; + +#[scope("/api")] +async fn index() -> &'static str { + "Hello World!" +} + +fn main() {} diff --git a/actix-web-codegen/tests/trybuild/scope-on-handler.stderr b/actix-web-codegen/tests/trybuild/scope-on-handler.stderr new file mode 100644 index 00000000..4491f42d --- /dev/null +++ b/actix-web-codegen/tests/trybuild/scope-on-handler.stderr @@ -0,0 +1,5 @@ +error: #[scope] macro must be attached to a module + --> tests/trybuild/scope-on-handler.rs:4:1 + | +4 | async fn index() -> &'static str { + | ^^^^^ diff --git a/actix-web-codegen/tests/trybuild/scope-trailing-slash.rs b/actix-web-codegen/tests/trybuild/scope-trailing-slash.rs new file mode 100644 index 00000000..84632b59 --- /dev/null +++ b/actix-web-codegen/tests/trybuild/scope-trailing-slash.rs @@ -0,0 +1,6 @@ +use actix_web_codegen::scope; + +#[scope("/api/")] +mod api {} + +fn main() {} diff --git a/actix-web-codegen/tests/trybuild/scope-trailing-slash.stderr b/actix-web-codegen/tests/trybuild/scope-trailing-slash.stderr new file mode 100644 index 00000000..66933432 --- /dev/null +++ b/actix-web-codegen/tests/trybuild/scope-trailing-slash.stderr @@ -0,0 +1,5 @@ +error: scopes should not have trailing slashes; see https://docs.rs/actix-web/4/actix_web/struct.Scope.html#avoid-trailing-slashes + --> tests/trybuild/scope-trailing-slash.rs:3:9 + | +3 | #[scope("/api/")] + | ^^^^^^^ diff --git a/actix-web/src/lib.rs b/actix-web/src/lib.rs index f86a7440..20539138 100644 --- a/actix-web/src/lib.rs +++ b/actix-web/src/lib.rs @@ -145,5 +145,6 @@ codegen_reexport!(delete); codegen_reexport!(trace); codegen_reexport!(connect); codegen_reexport!(options); +codegen_reexport!(scope); pub(crate) type BoxError = Box; diff --git a/awc/src/client/connector.rs b/awc/src/client/connector.rs index 5d0b655a..f3d44307 100644 --- a/awc/src/client/connector.rs +++ b/awc/src/client/connector.rs @@ -1080,7 +1080,7 @@ mod resolver { // resolver struct is cached in thread local so new clients can reuse the existing instance thread_local! { - static TRUST_DNS_RESOLVER: RefCell> = RefCell::new(None); + static TRUST_DNS_RESOLVER: RefCell> = const { RefCell::new(None) }; } // get from thread local or construct a new trust-dns resolver. diff --git a/justfile b/justfile index d92f4bd3..4e106ef1 100644 --- a/justfile +++ b/justfile @@ -4,7 +4,7 @@ _list: # Format workspace. fmt: cargo +nightly fmt - npx -y prettier --write $(fd --type=file --hidden --extension=md --extension=yml) + fd --hidden --type=file --extension=md --extension=yml --exec-batch npx -y prettier --write # Downgrade dev-dependencies necessary to run MSRV checks/tests. [private] @@ -32,6 +32,10 @@ all_crate_features := if os() == "linux" { "--features='" + non_linux_all_features_list + "'" } +# Run Clippy over workspace. +clippy toolchain="": + cargo {{ toolchain }} clippy --workspace --all-targets {{ all_crate_features }} + # Test workspace using MSRV. test-msrv: downgrade-for-msrv (test msrv_rustup) From 7c4c26d2df5d344ae524a72f733fd3af0c13a3a2 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Sat, 8 Jun 2024 05:26:26 +0100 Subject: [PATCH 120/151] feat: expose Identity middleware (#3390) --- .github/workflows/lint.yml | 2 +- actix-web/CHANGES.md | 1 + actix-web/src/middleware/compat.rs | 13 ++---------- actix-web/src/middleware/condition.rs | 4 ++-- .../src/middleware/{noop.rs => identity.rs} | 20 +++++++++++-------- actix-web/src/middleware/mod.rs | 16 ++++++--------- 6 files changed, 24 insertions(+), 32 deletions(-) rename actix-web/src/middleware/{noop.rs => identity.rs} (57%) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index d7a16ccb..dd44d4cb 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -89,5 +89,5 @@ jobs: - name: Generate API diff run: | for f in $(find -mindepth 2 -maxdepth 2 -name Cargo.toml); do - cargo public-api --manifest-path "$f" diff ${{ github.event.pull_request.base.sha }}..${{ github.sha }} + cargo public-api --manifest-path "$f" --simplified diff ${{ github.event.pull_request.base.sha }}..${{ github.sha }} done diff --git a/actix-web/CHANGES.md b/actix-web/CHANGES.md index 75f3631c..93fbbf46 100644 --- a/actix-web/CHANGES.md +++ b/actix-web/CHANGES.md @@ -4,6 +4,7 @@ ### Added +- Add `middleware::Identity` type. - Add `CustomizeResponder::add_cookie()` method. - Add `guard::GuardContext::app_data()` method. - Implement `From>` for `Error`. diff --git a/actix-web/src/middleware/compat.rs b/actix-web/src/middleware/compat.rs index 7df510a5..963dfdab 100644 --- a/actix-web/src/middleware/compat.rs +++ b/actix-web/src/middleware/compat.rs @@ -38,15 +38,6 @@ pub struct Compat { transform: T, } -#[cfg(test)] -impl Compat { - pub(crate) fn noop() -> Self { - Self { - transform: super::Noop, - } - } -} - impl Compat { /// Wrap a middleware to give it broader compatibility. pub fn new(middleware: T) -> Self { @@ -152,7 +143,7 @@ mod tests { use crate::{ dev::ServiceRequest, http::StatusCode, - middleware::{self, Condition, Logger}, + middleware::{self, Condition, Identity, Logger}, test::{self, call_service, init_service, TestRequest}, web, App, HttpResponse, }; @@ -225,7 +216,7 @@ mod tests { async fn compat_noop_is_noop() { let srv = test::ok_service(); - let mw = Compat::noop() + let mw = Compat::new(Identity) .new_transform(srv.into_service()) .await .unwrap(); diff --git a/actix-web/src/middleware/condition.rs b/actix-web/src/middleware/condition.rs index 55c56d49..5ee4467d 100644 --- a/actix-web/src/middleware/condition.rs +++ b/actix-web/src/middleware/condition.rs @@ -141,7 +141,7 @@ mod tests { header::{HeaderValue, CONTENT_TYPE}, StatusCode, }, - middleware::{self, ErrorHandlerResponse, ErrorHandlers}, + middleware::{self, ErrorHandlerResponse, ErrorHandlers, Identity}, test::{self, TestRequest}, web::Bytes, HttpResponse, @@ -158,7 +158,7 @@ mod tests { #[test] fn compat_with_builtin_middleware() { - let _ = Condition::new(true, middleware::Compat::noop()); + let _ = Condition::new(true, middleware::Compat::new(Identity)); let _ = Condition::new(true, middleware::Logger::default()); let _ = Condition::new(true, middleware::Compress::default()); let _ = Condition::new(true, middleware::NormalizePath::trim()); diff --git a/actix-web/src/middleware/noop.rs b/actix-web/src/middleware/identity.rs similarity index 57% rename from actix-web/src/middleware/noop.rs rename to actix-web/src/middleware/identity.rs index ae7da1d8..de374a57 100644 --- a/actix-web/src/middleware/noop.rs +++ b/actix-web/src/middleware/identity.rs @@ -2,35 +2,39 @@ use actix_utils::future::{ready, Ready}; -use crate::dev::{Service, Transform}; +use crate::dev::{forward_ready, Service, Transform}; /// A no-op middleware that passes through request and response untouched. -pub(crate) struct Noop; +#[derive(Debug, Clone, Default)] +#[non_exhaustive] +pub struct Identity; -impl, Req> Transform for Noop { +impl, Req> Transform for Identity { type Response = S::Response; type Error = S::Error; - type Transform = NoopService; + type Transform = IdentityMiddleware; type InitError = (); type Future = Ready>; + #[inline] fn new_transform(&self, service: S) -> Self::Future { - ready(Ok(NoopService { service })) + ready(Ok(IdentityMiddleware { service })) } } #[doc(hidden)] -pub(crate) struct NoopService { +pub struct IdentityMiddleware { service: S, } -impl, Req> Service for NoopService { +impl, Req> Service for IdentityMiddleware { type Response = S::Response; type Error = S::Error; type Future = S::Future; - crate::dev::forward_ready!(service); + forward_ready!(service); + #[inline] fn call(&self, req: Req) -> Self::Future { self.service.call(req) } diff --git a/actix-web/src/middleware/mod.rs b/actix-web/src/middleware/mod.rs index e924de26..1c27b111 100644 --- a/actix-web/src/middleware/mod.rs +++ b/actix-web/src/middleware/mod.rs @@ -218,31 +218,27 @@ //! [lab_from_fn]: https://docs.rs/actix-web-lab/latest/actix_web_lab/middleware/fn.from_fn.html mod compat; +#[cfg(feature = "__compress")] +mod compress; mod condition; mod default_headers; mod err_handlers; +mod identity; mod logger; -#[cfg(test)] -mod noop; mod normalize; -#[cfg(test)] -pub(crate) use self::noop::Noop; +#[cfg(feature = "__compress")] +pub use self::compress::Compress; pub use self::{ compat::Compat, condition::Condition, default_headers::DefaultHeaders, err_handlers::{ErrorHandlerResponse, ErrorHandlers}, + identity::Identity, logger::Logger, normalize::{NormalizePath, TrailingSlash}, }; -#[cfg(feature = "__compress")] -mod compress; - -#[cfg(feature = "__compress")] -pub use self::compress::Compress; - #[cfg(test)] mod tests { use super::*; From ebc43dcf1b52ddf083090402b28392469ffa1997 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Sun, 9 Jun 2024 00:10:15 +0100 Subject: [PATCH 121/151] feat: forwards-compatibility for handler visibility inheritance fix (#3391) --- actix-web-codegen/CHANGES.md | 1 + actix-web-codegen/Cargo.toml | 4 ++++ actix-web-codegen/src/route.rs | 9 ++++++++- actix-web-codegen/tests/scopes.rs | 2 +- actix-web/CHANGES.md | 2 ++ actix-web/Cargo.toml | 26 ++++++++++++++++++++++---- awc/Cargo.toml | 2 +- 7 files changed, 39 insertions(+), 7 deletions(-) diff --git a/actix-web-codegen/CHANGES.md b/actix-web-codegen/CHANGES.md index 792f6aa4..0a240680 100644 --- a/actix-web-codegen/CHANGES.md +++ b/actix-web-codegen/CHANGES.md @@ -3,6 +3,7 @@ ## Unreleased - Add `#[scope]` macro. +- Add `compat-routing-macros-force-pub` crate feature which, on-by-default, which when disabled causes handlers to inherit their attached function's visibility. - Prevent inclusion of default `actix-router` features. - Minimum supported Rust version (MSRV) is now 1.72. diff --git a/actix-web-codegen/Cargo.toml b/actix-web-codegen/Cargo.toml index 31c47069..7eb99503 100644 --- a/actix-web-codegen/Cargo.toml +++ b/actix-web-codegen/Cargo.toml @@ -15,6 +15,10 @@ rust-version.workspace = true [lib] proc-macro = true +[features] +default = ["compat-routing-macros-force-pub"] +compat-routing-macros-force-pub = [] + [dependencies] actix-router = { version = "0.5", default-features = false } proc-macro2 = "1" diff --git a/actix-web-codegen/src/route.rs b/actix-web-codegen/src/route.rs index d0605fc0..e24903e3 100644 --- a/actix-web-codegen/src/route.rs +++ b/actix-web-codegen/src/route.rs @@ -413,6 +413,13 @@ impl ToTokens for Route { doc_attributes, } = self; + #[allow(unused_variables)] // used when force-pub feature is disabled + let vis = &ast.vis; + + // TODO(breaking): remove this force-pub forwards-compatibility feature + #[cfg(feature = "compat-routing-macros-force-pub")] + let vis = syn::Visibility::Public(::default()); + let registrations: TokenStream2 = args .iter() .map(|args| { @@ -460,7 +467,7 @@ impl ToTokens for Route { let stream = quote! { #(#doc_attributes)* #[allow(non_camel_case_types, missing_docs)] - pub struct #name; + #vis struct #name; impl ::actix_web::dev::HttpServiceFactory for #name { fn register(self, __config: &mut actix_web::dev::AppService) { diff --git a/actix-web-codegen/tests/scopes.rs b/actix-web-codegen/tests/scopes.rs index 6a370a2e..4ee6db16 100644 --- a/actix-web-codegen/tests/scopes.rs +++ b/actix-web-codegen/tests/scopes.rs @@ -49,7 +49,7 @@ mod scope_module { #[connect("/test2")] #[options("/test3")] #[trace("/test4")] - async fn multiple_separate_paths() -> impl Responder { + pub async fn multiple_separate_paths() -> impl Responder { HttpResponse::Ok().finish() } diff --git a/actix-web/CHANGES.md b/actix-web/CHANGES.md index 93fbbf46..97bdf29c 100644 --- a/actix-web/CHANGES.md +++ b/actix-web/CHANGES.md @@ -7,6 +7,8 @@ - Add `middleware::Identity` type. - Add `CustomizeResponder::add_cookie()` method. - Add `guard::GuardContext::app_data()` method. +- Add `compat-routing-macros-force-pub` crate feature which (on-by-default) which, when disabled, causes handlers to inherit their attached function's visibility. +- Add `compat` crate feature group (on-by-default) which, when disabled, helps with transitioning to some planned v5.0 breaking changes, starting only with `compat-routing-macros-force-pub`. - Implement `From>` for `Error`. ## 4.6.0 diff --git a/actix-web/Cargo.toml b/actix-web/Cargo.toml index a666f14b..c36f317c 100644 --- a/actix-web/Cargo.toml +++ b/actix-web/Cargo.toml @@ -40,7 +40,16 @@ name = "actix_web" path = "src/lib.rs" [features] -default = ["macros", "compress-brotli", "compress-gzip", "compress-zstd", "cookies", "http2", "unicode"] +default = [ + "macros", + "compress-brotli", + "compress-gzip", + "compress-zstd", + "cookies", + "http2", + "unicode", + "compat", +] # Brotli algorithm content-encoding support compress-brotli = ["actix-http/compress-brotli", "__compress"] @@ -50,14 +59,15 @@ compress-gzip = ["actix-http/compress-gzip", "__compress"] compress-zstd = ["actix-http/compress-zstd", "__compress"] # Routing and runtime proc macros -macros = ["actix-macros", "actix-web-codegen"] +macros = ["dep:actix-macros", "dep:actix-web-codegen"] # Cookies support -cookies = ["cookie"] +cookies = ["dep:cookie"] # Secure & signed cookies secure-cookies = ["cookies", "cookie/secure"] +# HTTP/2 support (including h2c). http2 = ["actix-http/http2"] # TLS via OpenSSL @@ -84,6 +94,14 @@ __compress = [] # io-uring feature only available for Linux OSes. experimental-io-uring = ["actix-server/io-uring"] +# Feature group which, when disabled, helps migrate code to v5.0. +compat = [ + "compat-routing-macros-force-pub", +] + +# Opt-out forwards-compatibility for handler visibility inheritance fix. +compat-routing-macros-force-pub = ["actix-web-codegen?/compat-routing-macros-force-pub"] + [dependencies] actix-codec = "0.5" actix-macros = { version = "0.2.3", optional = true } @@ -95,7 +113,7 @@ actix-tls = { version = "3.4", default-features = false, optional = true } actix-http = { version = "3.7", features = ["ws"] } actix-router = { version = "0.5.3", default-features = false, features = ["http"] } -actix-web-codegen = { version = "4.2", optional = true } +actix-web-codegen = { version = "4.2", optional = true, default-features = false } ahash = "0.8" bytes = "1" diff --git a/awc/Cargo.toml b/awc/Cargo.toml index f51b3904..09f580af 100644 --- a/awc/Cargo.toml +++ b/awc/Cargo.toml @@ -64,7 +64,7 @@ compress-gzip = ["actix-http/compress-gzip", "__compress"] compress-zstd = ["actix-http/compress-zstd", "__compress"] # Cookie parsing and cookie jar -cookies = ["cookie"] +cookies = ["dep:cookie"] # Use `trust-dns-resolver` crate as DNS resolver trust-dns = ["trust-dns-resolver"] From d6f885127d5d72096b9129085508b9af29c5cfee Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Sun, 9 Jun 2024 00:16:36 +0100 Subject: [PATCH 122/151] chore(actix-test): prepare release 0.1.4 --- actix-test/CHANGES.md | 2 ++ actix-test/Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/actix-test/CHANGES.md b/actix-test/CHANGES.md index 940b595c..8088c250 100644 --- a/actix-test/CHANGES.md +++ b/actix-test/CHANGES.md @@ -2,6 +2,8 @@ ## Unreleased +## 0.1.4 + - Add `TestServerConfig::rustls_0_23()` method for Rustls v0.23 support behind new `rustls-0_23` crate feature. - Add `TestServerConfig::disable_redirects()` method. - Various types from `awc`, such as `ClientRequest` and `ClientResponse`, are now re-exported. diff --git a/actix-test/Cargo.toml b/actix-test/Cargo.toml index dddcabec..1ae61914 100644 --- a/actix-test/Cargo.toml +++ b/actix-test/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "actix-test" -version = "0.1.3" +version = "0.1.4" authors = [ "Nikolay Kim ", "Rob Ede ", From b4faf8820cb14a3648bb03385e0ceca844de8d9d Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Sun, 9 Jun 2024 00:19:09 +0100 Subject: [PATCH 123/151] chore(actix-web-codegen): prepare release 4.3.0 --- actix-web-codegen/CHANGES.md | 2 ++ actix-web-codegen/Cargo.toml | 2 +- actix-web-codegen/README.md | 4 ++-- actix-web/Cargo.toml | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/actix-web-codegen/CHANGES.md b/actix-web-codegen/CHANGES.md index 0a240680..d143723f 100644 --- a/actix-web-codegen/CHANGES.md +++ b/actix-web-codegen/CHANGES.md @@ -2,6 +2,8 @@ ## Unreleased +## 4.3.0 + - Add `#[scope]` macro. - Add `compat-routing-macros-force-pub` crate feature which, on-by-default, which when disabled causes handlers to inherit their attached function's visibility. - Prevent inclusion of default `actix-router` features. diff --git a/actix-web-codegen/Cargo.toml b/actix-web-codegen/Cargo.toml index 7eb99503..7500807d 100644 --- a/actix-web-codegen/Cargo.toml +++ b/actix-web-codegen/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "actix-web-codegen" -version = "4.2.2" +version = "4.3.0" description = "Routing and runtime macros for Actix Web" authors = [ "Nikolay Kim ", diff --git a/actix-web-codegen/README.md b/actix-web-codegen/README.md index 9229f8f1..e61bf5c7 100644 --- a/actix-web-codegen/README.md +++ b/actix-web-codegen/README.md @@ -5,11 +5,11 @@ [![crates.io](https://img.shields.io/crates/v/actix-web-codegen?label=latest)](https://crates.io/crates/actix-web-codegen) -[![Documentation](https://docs.rs/actix-web-codegen/badge.svg?version=4.2.2)](https://docs.rs/actix-web-codegen/4.2.2) +[![Documentation](https://docs.rs/actix-web-codegen/badge.svg?version=4.3.0)](https://docs.rs/actix-web-codegen/4.3.0) ![Version](https://img.shields.io/badge/rustc-1.72+-ab6000.svg) ![License](https://img.shields.io/crates/l/actix-web-codegen.svg)
-[![dependency status](https://deps.rs/crate/actix-web-codegen/4.2.2/status.svg)](https://deps.rs/crate/actix-web-codegen/4.2.2) +[![dependency status](https://deps.rs/crate/actix-web-codegen/4.3.0/status.svg)](https://deps.rs/crate/actix-web-codegen/4.3.0) [![Download](https://img.shields.io/crates/d/actix-web-codegen.svg)](https://crates.io/crates/actix-web-codegen) [![Chat on Discord](https://img.shields.io/discord/771444961383153695?label=chat&logo=discord)](https://discord.gg/NWpN5mmg3x) diff --git a/actix-web/Cargo.toml b/actix-web/Cargo.toml index c36f317c..243b91d2 100644 --- a/actix-web/Cargo.toml +++ b/actix-web/Cargo.toml @@ -113,7 +113,7 @@ actix-tls = { version = "3.4", default-features = false, optional = true } actix-http = { version = "3.7", features = ["ws"] } actix-router = { version = "0.5.3", default-features = false, features = ["http"] } -actix-web-codegen = { version = "4.2", optional = true, default-features = false } +actix-web-codegen = { version = "4.3", optional = true, default-features = false } ahash = "0.8" bytes = "1" From 12a0521ef88d13120363edeca484e75c98af8934 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Sun, 9 Jun 2024 00:20:36 +0100 Subject: [PATCH 124/151] chore(actix-multipart): prepare release 0.6.2 --- actix-multipart/CHANGES.md | 2 ++ actix-multipart/Cargo.toml | 2 +- actix-multipart/README.md | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/actix-multipart/CHANGES.md b/actix-multipart/CHANGES.md index 196d2ca9..a91edf9c 100644 --- a/actix-multipart/CHANGES.md +++ b/actix-multipart/CHANGES.md @@ -2,6 +2,8 @@ ## Unreleased +## 0.6.2 + - Add testing utilities under new module `test`. - Minimum supported Rust version (MSRV) is now 1.72. diff --git a/actix-multipart/Cargo.toml b/actix-multipart/Cargo.toml index 6e36c339..f1289d3a 100644 --- a/actix-multipart/Cargo.toml +++ b/actix-multipart/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "actix-multipart" -version = "0.6.1" +version = "0.6.2" authors = [ "Nikolay Kim ", "Jacob Halsey ", diff --git a/actix-multipart/README.md b/actix-multipart/README.md index 35c7f9a1..c7697785 100644 --- a/actix-multipart/README.md +++ b/actix-multipart/README.md @@ -5,11 +5,11 @@ [![crates.io](https://img.shields.io/crates/v/actix-multipart?label=latest)](https://crates.io/crates/actix-multipart) -[![Documentation](https://docs.rs/actix-multipart/badge.svg?version=0.6.1)](https://docs.rs/actix-multipart/0.6.1) +[![Documentation](https://docs.rs/actix-multipart/badge.svg?version=0.6.2)](https://docs.rs/actix-multipart/0.6.2) ![Version](https://img.shields.io/badge/rustc-1.72+-ab6000.svg) ![MIT or Apache 2.0 licensed](https://img.shields.io/crates/l/actix-multipart.svg)
-[![dependency status](https://deps.rs/crate/actix-multipart/0.6.1/status.svg)](https://deps.rs/crate/actix-multipart/0.6.1) +[![dependency status](https://deps.rs/crate/actix-multipart/0.6.2/status.svg)](https://deps.rs/crate/actix-multipart/0.6.2) [![Download](https://img.shields.io/crates/d/actix-multipart.svg)](https://crates.io/crates/actix-multipart) [![Chat on Discord](https://img.shields.io/discord/771444961383153695?label=chat&logo=discord)](https://discord.gg/NWpN5mmg3x) From a5c78483f9d83d3f916d75c8a5ce46909faf32bc Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Sun, 9 Jun 2024 00:22:03 +0100 Subject: [PATCH 125/151] chore(actix-web): prepare release 4.7.0 --- actix-web/CHANGES.md | 2 ++ actix-web/Cargo.toml | 2 +- actix-web/README.md | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/actix-web/CHANGES.md b/actix-web/CHANGES.md index 97bdf29c..27259dc5 100644 --- a/actix-web/CHANGES.md +++ b/actix-web/CHANGES.md @@ -2,6 +2,8 @@ ## Unreleased +## 4.7.0 + ### Added - Add `middleware::Identity` type. diff --git a/actix-web/Cargo.toml b/actix-web/Cargo.toml index 243b91d2..10a50768 100644 --- a/actix-web/Cargo.toml +++ b/actix-web/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "actix-web" -version = "4.6.0" +version = "4.7.0" description = "Actix Web is a powerful, pragmatic, and extremely fast web framework for Rust" authors = [ "Nikolay Kim ", diff --git a/actix-web/README.md b/actix-web/README.md index 4e7e785a..8b4375bd 100644 --- a/actix-web/README.md +++ b/actix-web/README.md @@ -8,10 +8,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=4.6.0)](https://docs.rs/actix-web/4.6.0) +[![Documentation](https://docs.rs/actix-web/badge.svg?version=4.7.0)](https://docs.rs/actix-web/4.7.0) ![MSRV](https://img.shields.io/badge/rustc-1.72+-ab6000.svg) ![MIT or Apache 2.0 licensed](https://img.shields.io/crates/l/actix-web.svg) -[![Dependency Status](https://deps.rs/crate/actix-web/4.6.0/status.svg)](https://deps.rs/crate/actix-web/4.6.0) +[![Dependency Status](https://deps.rs/crate/actix-web/4.7.0/status.svg)](https://deps.rs/crate/actix-web/4.7.0)
[![CI](https://github.com/actix/actix-web/actions/workflows/ci.yml/badge.svg)](https://github.com/actix/actix-web/actions/workflows/ci.yml) [![codecov](https://codecov.io/gh/actix/actix-web/branch/master/graph/badge.svg)](https://codecov.io/gh/actix/actix-web) From 40e1034566febd583ea7669e4fa76908e9bfe3ad Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Sun, 9 Jun 2024 00:38:49 +0100 Subject: [PATCH 126/151] docs: update changelog --- actix-web/CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/actix-web/CHANGES.md b/actix-web/CHANGES.md index 27259dc5..4e74e090 100644 --- a/actix-web/CHANGES.md +++ b/actix-web/CHANGES.md @@ -6,6 +6,7 @@ ### Added +- Add `#[scope]` macro. - Add `middleware::Identity` type. - Add `CustomizeResponder::add_cookie()` method. - Add `guard::GuardContext::app_data()` method. From 266834cf7c0e7b243b671b0b2ac41a20f8100286 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Sun, 9 Jun 2024 04:51:53 +0100 Subject: [PATCH 127/151] chore: narrow h2 version --- actix-http/Cargo.toml | 2 +- awc/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/actix-http/Cargo.toml b/actix-http/Cargo.toml index a999e73c..87e2b391 100644 --- a/actix-http/Cargo.toml +++ b/actix-http/Cargo.toml @@ -106,7 +106,7 @@ tokio-util = { version = "0.7", features = ["io", "codec"] } tracing = { version = "0.1.30", default-features = false, features = ["log"] } # http2 -h2 = { version = "0.3.24", optional = true } +h2 = { version = "0.3.26", optional = true } # websockets local-channel = { version = "0.1", optional = true } diff --git a/awc/Cargo.toml b/awc/Cargo.toml index 09f580af..6ab408ea 100644 --- a/awc/Cargo.toml +++ b/awc/Cargo.toml @@ -92,7 +92,7 @@ cfg-if = "1" derive_more = "0.99.5" futures-core = { version = "0.3.17", default-features = false, features = ["alloc"] } futures-util = { version = "0.3.17", default-features = false, features = ["alloc", "sink"] } -h2 = "0.3.24" +h2 = "0.3.26" http = "0.2.7" itoa = "1" log =" 0.4" From 8018983a68742570d86bd8f5a0ba0b8ed389e75d Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Sun, 9 Jun 2024 06:08:21 +0100 Subject: [PATCH 128/151] docs: update changelog for #3393 --- actix-http/CHANGES.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/actix-http/CHANGES.md b/actix-http/CHANGES.md index 61eeb4be..85ba0310 100644 --- a/actix-http/CHANGES.md +++ b/actix-http/CHANGES.md @@ -2,6 +2,10 @@ ## Unreleased +### Added + +- Add `error::InvalidStatusCode` re-export. + ## 3.7.0 ### Added From f7646bcc485f43ff4ba987cd613891883a081a07 Mon Sep 17 00:00:00 2001 From: asonix Date: Sun, 9 Jun 2024 00:04:42 -0500 Subject: [PATCH 129/151] actix-web-actors: take the internal buffer when yielding (#3369) * actix-web-actors: take the internal buffer when yielding * actix-web-actors: Add CHANGES entry re: taking buffer --- actix-web-actors/CHANGES.md | 1 + actix-web-actors/src/ws.rs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/actix-web-actors/CHANGES.md b/actix-web-actors/CHANGES.md index 9a622d8d..3e854c0b 100644 --- a/actix-web-actors/CHANGES.md +++ b/actix-web-actors/CHANGES.md @@ -2,6 +2,7 @@ ## Unreleased +- Take the encoded buffer when yielding bytes in the response stream rather than splitting the buffer, reducing memory use - Minimum supported Rust version (MSRV) is now 1.72. ## 4.3.0 diff --git a/actix-web-actors/src/ws.rs b/actix-web-actors/src/ws.rs index 1fb90322..7f7607fa 100644 --- a/actix-web-actors/src/ws.rs +++ b/actix-web-actors/src/ws.rs @@ -710,7 +710,7 @@ where } if !this.buf.is_empty() { - Poll::Ready(Some(Ok(this.buf.split().freeze()))) + Poll::Ready(Some(Ok(std::mem::take(&mut this.buf).freeze()))) } else if this.fut.alive() && !this.closed { Poll::Pending } else { From 22593a1532be29374100de0d256b493f2557bcd3 Mon Sep 17 00:00:00 2001 From: Samuel Marks <807580+SamuelMarks@users.noreply.github.com> Date: Sun, 9 Jun 2024 01:07:56 -0400 Subject: [PATCH 130/151] Re-export `http::status::InvalidStatusCode` (#3393) * [actix-http/src/lib.rs] Expose/re-export `http::status::InvalidStatusCode` * [actix-http/src/error.rs] Re-export `http::status::InvalidStatusCode` ; [actix-http/src/lib.rs] Revert --- actix-http/src/error.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/actix-http/src/error.rs b/actix-http/src/error.rs index 69e2f14a..6f332118 100644 --- a/actix-http/src/error.rs +++ b/actix-http/src/error.rs @@ -3,7 +3,7 @@ use std::{error::Error as StdError, fmt, io, str::Utf8Error, string::FromUtf8Error}; use derive_more::{Display, Error, From}; -pub use http::Error as HttpError; +pub use http::{status::InvalidStatusCode, Error as HttpError}; use http::{uri::InvalidUri, StatusCode}; use crate::{body::BoxBody, Response}; From 8b8eb4eae1212796216a53aa9ca445108206d7fe Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 9 Jun 2024 18:37:42 +0100 Subject: [PATCH 131/151] build(deps): update tokio-uring requirement from 0.4 to 0.5 (#3385) * build(deps): update tokio-uring requirement from 0.4 to 0.5 Updates the requirements on [tokio-uring](https://github.com/tokio-rs/tokio-uring) to permit the latest version. - [Release notes](https://github.com/tokio-rs/tokio-uring/releases) - [Changelog](https://github.com/tokio-rs/tokio-uring/blob/master/CHANGELOG.md) - [Commits](https://github.com/tokio-rs/tokio-uring/compare/v0.4.0...v0.5.0) --- updated-dependencies: - dependency-name: tokio-uring dependency-type: direct:production ... Signed-off-by: dependabot[bot] * chore: narrow actix-server requirement --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Rob Ede --- actix-files/Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/actix-files/Cargo.toml b/actix-files/Cargo.toml index 3d82f8a7..a69af302 100644 --- a/actix-files/Cargo.toml +++ b/actix-files/Cargo.toml @@ -40,8 +40,8 @@ v_htmlescape = "0.15.5" # experimental-io-uring [target.'cfg(target_os = "linux")'.dependencies] -tokio-uring = { version = "0.4", optional = true, features = ["bytes"] } -actix-server = { version = "2.2", optional = true } # ensure matching tokio-uring versions +tokio-uring = { version = "0.5", optional = true, features = ["bytes"] } +actix-server = { version = "2.4", optional = true } # ensure matching tokio-uring versions [dev-dependencies] actix-rt = "2.7" From 37577dcb89c01834820e95d2361eed32732447a5 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Sun, 9 Jun 2024 19:45:14 +0100 Subject: [PATCH 132/151] chore(actix-files): prepare release 0.6.6 --- actix-files/CHANGES.md | 3 +++ actix-files/Cargo.toml | 2 +- actix-files/README.md | 4 ++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/actix-files/CHANGES.md b/actix-files/CHANGES.md index 393e7b61..e94f4390 100644 --- a/actix-files/CHANGES.md +++ b/actix-files/CHANGES.md @@ -2,6 +2,9 @@ ## Unreleased +## 0.6.6 + +- Update `tokio-uring` dependency to `0.4`. - Minimum supported Rust version (MSRV) is now 1.72. ## 0.6.5 diff --git a/actix-files/Cargo.toml b/actix-files/Cargo.toml index a69af302..7adb8eaf 100644 --- a/actix-files/Cargo.toml +++ b/actix-files/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "actix-files" -version = "0.6.5" +version = "0.6.6" authors = [ "Nikolay Kim ", "Rob Ede ", diff --git a/actix-files/README.md b/actix-files/README.md index a6b3f63c..f6d5143f 100644 --- a/actix-files/README.md +++ b/actix-files/README.md @@ -3,11 +3,11 @@ [![crates.io](https://img.shields.io/crates/v/actix-files?label=latest)](https://crates.io/crates/actix-files) -[![Documentation](https://docs.rs/actix-files/badge.svg?version=0.6.5)](https://docs.rs/actix-files/0.6.5) +[![Documentation](https://docs.rs/actix-files/badge.svg?version=0.6.6)](https://docs.rs/actix-files/0.6.6) ![Version](https://img.shields.io/badge/rustc-1.72+-ab6000.svg) ![License](https://img.shields.io/crates/l/actix-files.svg)
-[![dependency status](https://deps.rs/crate/actix-files/0.6.5/status.svg)](https://deps.rs/crate/actix-files/0.6.5) +[![dependency status](https://deps.rs/crate/actix-files/0.6.6/status.svg)](https://deps.rs/crate/actix-files/0.6.6) [![Download](https://img.shields.io/crates/d/actix-files.svg)](https://crates.io/crates/actix-files) [![Chat on Discord](https://img.shields.io/discord/771444961383153695?label=chat&logo=discord)](https://discord.gg/NWpN5mmg3x) From 758ae1dac1c5cc574698f058b30bd075bac8b681 Mon Sep 17 00:00:00 2001 From: Matt Palmer Date: Mon, 10 Jun 2024 05:07:08 +1000 Subject: [PATCH 133/151] actix-test: allow the configuration of the TestServer address (#3351) * actix-test: allow the configuration of the TestServer address This is useful if you're running (say) Selenium tests against a running TestServer, and the Selenium workers are Docker containers elsewhere in the network. Not a *particularly* common use case, perhaps, but one that I can attest happens every now and then. * Update CHANGES.md * Adjust default listen address to avoid test failures --------- Co-authored-by: Rob Ede --- actix-test/CHANGES.md | 2 ++ actix-test/src/lib.rs | 16 +++++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/actix-test/CHANGES.md b/actix-test/CHANGES.md index 8088c250..dd409c91 100644 --- a/actix-test/CHANGES.md +++ b/actix-test/CHANGES.md @@ -2,6 +2,8 @@ ## Unreleased +- Add `TestServerConfig::listen_address()` method. + ## 0.1.4 - Add `TestServerConfig::rustls_0_23()` method for Rustls v0.23 support behind new `rustls-0_23` crate feature. diff --git a/actix-test/src/lib.rs b/actix-test/src/lib.rs index 48d5079a..80332060 100644 --- a/actix-test/src/lib.rs +++ b/actix-test/src/lib.rs @@ -154,7 +154,7 @@ where // run server in separate orphaned thread thread::spawn(move || { rt::System::new().block_on(async move { - let tcp = net::TcpListener::bind(("127.0.0.1", cfg.port)).unwrap(); + let tcp = net::TcpListener::bind((cfg.listen_address.clone(), cfg.port)).unwrap(); let local_addr = tcp.local_addr().unwrap(); let factory = factory.clone(); let srv_cfg = cfg.clone(); @@ -514,6 +514,7 @@ pub struct TestServerConfig { tp: HttpVer, stream: StreamType, client_request_timeout: Duration, + listen_address: String, port: u16, workers: usize, disable_redirects: bool, @@ -532,6 +533,7 @@ impl TestServerConfig { tp: HttpVer::Both, stream: StreamType::Tcp, client_request_timeout: Duration::from_secs(5), + listen_address: "127.0.0.1".to_string(), port: 0, workers: 1, disable_redirects: false, @@ -607,6 +609,14 @@ impl TestServerConfig { self } + /// Sets the address the server will listen on. + /// + /// By default, only listens on `127.0.0.1`. + pub fn listen_address(mut self, addr: impl Into) -> Self { + self.listen_address = addr.into(); + self + } + /// Sets test server port. /// /// By default, a random free port is determined by the OS. @@ -657,9 +667,9 @@ impl TestServer { let scheme = if self.tls { "https" } else { "http" }; if uri.starts_with('/') { - format!("{}://localhost:{}{}", scheme, self.addr.port(), uri) + format!("{}://{}{}", scheme, self.addr, uri) } else { - format!("{}://localhost:{}/{}", scheme, self.addr.port(), uri) + format!("{}://{}/{}", scheme, self.addr, uri) } } From da56de45564640dba4461d5c5f8b5d1f23f25533 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Mon, 10 Jun 2024 00:01:17 +0100 Subject: [PATCH 134/151] chore(actix-test): prepare release 0.1.5 --- actix-test/CHANGES.md | 2 ++ actix-test/Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/actix-test/CHANGES.md b/actix-test/CHANGES.md index dd409c91..ec2dd677 100644 --- a/actix-test/CHANGES.md +++ b/actix-test/CHANGES.md @@ -2,6 +2,8 @@ ## Unreleased +## 0.1.5 + - Add `TestServerConfig::listen_address()` method. ## 0.1.4 diff --git a/actix-test/Cargo.toml b/actix-test/Cargo.toml index 1ae61914..41267c96 100644 --- a/actix-test/Cargo.toml +++ b/actix-test/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "actix-test" -version = "0.1.4" +version = "0.1.5" authors = [ "Nikolay Kim ", "Rob Ede ", From a2b9823d9d428b2abec75e98afb8dfd412098886 Mon Sep 17 00:00:00 2001 From: Matt Palmer Date: Mon, 10 Jun 2024 09:40:09 +1000 Subject: [PATCH 135/151] Strip non-address characters from Forwarded for= (#3343) * Strip non-address characters from Forwarded for= This is something of a followup to #2528, which asked for port information to not be included in when it was taken from the local socket. The header's element may optionally contain port information (https://datatracker.ietf.org/doc/html/rfc7239#section-6). However, as I understand it, is *supposed* to only contain an IP address, without port (per #2528). This PR corrects that discrepancy, making it easier to parse the result of this method in application code. There should not be any compatibility concerns, as anyone parsing the output of would already need to handle both port and portless cases anyway. * Update CHANGES.md --------- Co-authored-by: Rob Ede --- actix-web/CHANGES.md | 4 ++++ actix-web/src/info.rs | 28 +++++++++++++++++++++++++--- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/actix-web/CHANGES.md b/actix-web/CHANGES.md index 4e74e090..3d9176de 100644 --- a/actix-web/CHANGES.md +++ b/actix-web/CHANGES.md @@ -2,6 +2,10 @@ ## Unreleased +### Fixed + +- `ConnectionInfo::realip_remote_addr()` now handles IPv6 addresses from `Forwarded` header correctly. Previously, it sometimes returned the forwarded port as well. + ## 4.7.0 ### Added diff --git a/actix-web/src/info.rs b/actix-web/src/info.rs index c5d9638f..aee936ba 100644 --- a/actix-web/src/info.rs +++ b/actix-web/src/info.rs @@ -21,6 +21,19 @@ fn unquote(val: &str) -> &str { val.trim().trim_start_matches('"').trim_end_matches('"') } +/// Remove port and IPv6 square brackets from a peer specification. +fn bare_address(val: &str) -> &str { + if val.starts_with('[') { + val.split("]:") + .next() + .map(|s| s.trim_start_matches('[').trim_end_matches(']')) + // This shouldn't *actually* ever happen + .unwrap_or(val) + } else { + val.split(':').next().unwrap_or(val) + } +} + /// Extracts and trims first value for given header name. fn first_header_value<'a>(req: &'a RequestHead, name: &'_ HeaderName) -> Option<&'a str> { let hdr = req.headers.get(name)?.to_str().ok()?; @@ -100,7 +113,7 @@ impl ConnectionInfo { // --- https://datatracker.ietf.org/doc/html/rfc7239#section-5.2 match name.trim().to_lowercase().as_str() { - "for" => realip_remote_addr.get_or_insert_with(|| unquote(val)), + "for" => realip_remote_addr.get_or_insert_with(|| bare_address(unquote(val))), "proto" => scheme.get_or_insert_with(|| unquote(val)), "host" => host.get_or_insert_with(|| unquote(val)), "by" => { @@ -368,16 +381,25 @@ mod tests { .insert_header((header::FORWARDED, r#"for="192.0.2.60:8080""#)) .to_http_request(); let info = req.connection_info(); - assert_eq!(info.realip_remote_addr(), Some("192.0.2.60:8080")); + assert_eq!(info.realip_remote_addr(), Some("192.0.2.60")); } #[test] fn forwarded_for_ipv6() { + let req = TestRequest::default() + .insert_header((header::FORWARDED, r#"for="[2001:db8:cafe::17]""#)) + .to_http_request(); + let info = req.connection_info(); + assert_eq!(info.realip_remote_addr(), Some("2001:db8:cafe::17")); + } + + #[test] + fn forwarded_for_ipv6_with_port() { let req = TestRequest::default() .insert_header((header::FORWARDED, r#"for="[2001:db8:cafe::17]:4711""#)) .to_http_request(); let info = req.connection_info(); - assert_eq!(info.realip_remote_addr(), Some("[2001:db8:cafe::17]:4711")); + assert_eq!(info.realip_remote_addr(), Some("2001:db8:cafe::17")); } #[test] From 4908fd7dea00a361cf6b37f9d66f1ac3c4805543 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 10 Jun 2024 01:44:58 +0100 Subject: [PATCH 136/151] build(deps): bump taiki-e/install-action from 2.34.0 to 2.38.0 (#3396) Bumps [taiki-e/install-action](https://github.com/taiki-e/install-action) from 2.34.0 to 2.38.0. - [Release notes](https://github.com/taiki-e/install-action/releases) - [Changelog](https://github.com/taiki-e/install-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/taiki-e/install-action/compare/v2.34.0...v2.38.0) --- updated-dependencies: - dependency-name: taiki-e/install-action dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/ci-post-merge.yml | 4 ++-- .github/workflows/ci.yml | 4 ++-- .github/workflows/coverage.yml | 2 +- .github/workflows/lint.yml | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci-post-merge.yml b/.github/workflows/ci-post-merge.yml index 4231b4dc..d0eb3f8f 100644 --- a/.github/workflows/ci-post-merge.yml +++ b/.github/workflows/ci-post-merge.yml @@ -49,7 +49,7 @@ jobs: toolchain: ${{ matrix.version.version }} - name: Install just, cargo-hack, cargo-nextest, cargo-ci-cache-clean - uses: taiki-e/install-action@v2.34.0 + uses: taiki-e/install-action@v2.38.0 with: tool: just,cargo-hack,cargo-nextest,cargo-ci-cache-clean @@ -80,7 +80,7 @@ jobs: uses: actions-rust-lang/setup-rust-toolchain@v1.8.0 - name: Install cargo-hack - uses: taiki-e/install-action@v2.34.0 + uses: taiki-e/install-action@v2.38.0 with: tool: cargo-hack diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ab611fc0..cc51b89f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -64,7 +64,7 @@ jobs: toolchain: ${{ matrix.version.version }} - name: Install just, cargo-hack, cargo-nextest, cargo-ci-cache-clean - uses: taiki-e/install-action@v2.34.0 + uses: taiki-e/install-action@v2.38.0 with: tool: just,cargo-hack,cargo-nextest,cargo-ci-cache-clean @@ -113,7 +113,7 @@ jobs: toolchain: nightly - name: Install just - uses: taiki-e/install-action@v2.34.0 + uses: taiki-e/install-action@v2.38.0 with: tool: just diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index da892bd7..5c944bec 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -23,7 +23,7 @@ jobs: components: llvm-tools-preview - name: Install just,cargo-llvm-cov - uses: taiki-e/install-action@v2.34.0 + uses: taiki-e/install-action@v2.38.0 with: tool: just,cargo-llvm-cov diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index dd44d4cb..d5c667f9 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -82,7 +82,7 @@ jobs: toolchain: nightly-2024-06-07 - name: Install cargo-public-api - uses: taiki-e/install-action@v2.34.0 + uses: taiki-e/install-action@v2.38.0 with: tool: cargo-public-api From 7f529e35b296c8359bdf22e7480722a5844e3ce2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 10 Jun 2024 01:45:11 +0100 Subject: [PATCH 137/151] build(deps): bump actions-rust-lang/setup-rust-toolchain from 1.8.0 to 1.9.0 (#3395) build(deps): bump actions-rust-lang/setup-rust-toolchain Bumps [actions-rust-lang/setup-rust-toolchain](https://github.com/actions-rust-lang/setup-rust-toolchain) from 1.8.0 to 1.9.0. - [Release notes](https://github.com/actions-rust-lang/setup-rust-toolchain/releases) - [Changelog](https://github.com/actions-rust-lang/setup-rust-toolchain/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions-rust-lang/setup-rust-toolchain/compare/v1.8.0...v1.9.0) --- updated-dependencies: - dependency-name: actions-rust-lang/setup-rust-toolchain dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/ci-post-merge.yml | 4 ++-- .github/workflows/ci.yml | 6 +++--- .github/workflows/coverage.yml | 2 +- .github/workflows/lint.yml | 8 ++++---- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci-post-merge.yml b/.github/workflows/ci-post-merge.yml index d0eb3f8f..1729d9a0 100644 --- a/.github/workflows/ci-post-merge.yml +++ b/.github/workflows/ci-post-merge.yml @@ -44,7 +44,7 @@ jobs: echo "RUSTFLAGS=-C target-feature=+crt-static" >> $GITHUB_ENV - name: Install Rust (${{ matrix.version.name }}) - uses: actions-rust-lang/setup-rust-toolchain@v1.8.0 + uses: actions-rust-lang/setup-rust-toolchain@v1.9.0 with: toolchain: ${{ matrix.version.version }} @@ -77,7 +77,7 @@ jobs: run: ./scripts/free-disk-space.sh - name: Install Rust - uses: actions-rust-lang/setup-rust-toolchain@v1.8.0 + uses: actions-rust-lang/setup-rust-toolchain@v1.9.0 - name: Install cargo-hack uses: taiki-e/install-action@v2.38.0 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cc51b89f..1b6f7b46 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -59,7 +59,7 @@ jobs: uses: rui314/setup-mold@v1 - name: Install Rust (${{ matrix.version.name }}) - uses: actions-rust-lang/setup-rust-toolchain@v1.8.0 + uses: actions-rust-lang/setup-rust-toolchain@v1.9.0 with: toolchain: ${{ matrix.version.version }} @@ -92,7 +92,7 @@ jobs: - uses: actions/checkout@v4 - name: Install Rust - uses: actions-rust-lang/setup-rust-toolchain@v1.8.0 + uses: actions-rust-lang/setup-rust-toolchain@v1.9.0 with: toolchain: nightly @@ -108,7 +108,7 @@ jobs: - uses: actions/checkout@v4 - name: Install Rust (nightly) - uses: actions-rust-lang/setup-rust-toolchain@v1.8.0 + uses: actions-rust-lang/setup-rust-toolchain@v1.9.0 with: toolchain: nightly diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 5c944bec..de7fd703 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -18,7 +18,7 @@ jobs: - uses: actions/checkout@v4 - name: Install Rust - uses: actions-rust-lang/setup-rust-toolchain@v1.8.0 + uses: actions-rust-lang/setup-rust-toolchain@v1.9.0 with: components: llvm-tools-preview diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index d5c667f9..8fe8f59d 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -18,7 +18,7 @@ jobs: - uses: actions/checkout@v4 - name: Install Rust (nightly) - uses: actions-rust-lang/setup-rust-toolchain@v1.8.0 + uses: actions-rust-lang/setup-rust-toolchain@v1.9.0 with: toolchain: nightly components: rustfmt @@ -36,7 +36,7 @@ jobs: - uses: actions/checkout@v4 - name: Install Rust - uses: actions-rust-lang/setup-rust-toolchain@v1.8.0 + uses: actions-rust-lang/setup-rust-toolchain@v1.9.0 with: components: clippy @@ -55,7 +55,7 @@ jobs: - uses: actions/checkout@v4 - name: Install Rust (nightly) - uses: actions-rust-lang/setup-rust-toolchain@v1.8.0 + uses: actions-rust-lang/setup-rust-toolchain@v1.9.0 with: toolchain: nightly components: rust-docs @@ -77,7 +77,7 @@ jobs: uses: actions/checkout@v4 - name: Install Rust - uses: actions-rust-lang/setup-rust-toolchain@v1.8.0 + uses: actions-rust-lang/setup-rust-toolchain@v1.9.0 with: toolchain: nightly-2024-06-07 From 53086a90a679e609ae6afe43d0eb94cdb270f3c0 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Mon, 10 Jun 2024 01:58:13 +0100 Subject: [PATCH 138/151] build: add coverage recipes to justfile --- actix-web/src/info.rs | 3 ++- justfile | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/actix-web/src/info.rs b/actix-web/src/info.rs index aee936ba..1b2e554f 100644 --- a/actix-web/src/info.rs +++ b/actix-web/src/info.rs @@ -27,7 +27,8 @@ fn bare_address(val: &str) -> &str { val.split("]:") .next() .map(|s| s.trim_start_matches('[').trim_end_matches(']')) - // This shouldn't *actually* ever happen + // this indicates that the IPv6 address is malformed so shouldn't + // usually happen, but if it does, just return the original input .unwrap_or(val) } else { val.split(':').next().unwrap_or(val) diff --git a/justfile b/justfile index 4e106ef1..7f6dbb61 100644 --- a/justfile +++ b/justfile @@ -53,6 +53,14 @@ test-docs toolchain="": && doc # Test workspace. test-all toolchain="": (test toolchain) (test-docs toolchain) +# Test workspace and generate Codecov coverage file. +test-coverage-codecov toolchain="": + cargo {{ toolchain }} llvm-cov --workspace {{ all_crate_features }} --codecov --output-path codecov.json + +# Test workspace and generate LCOV coverage file. +test-coverage-lcov toolchain="": + cargo {{ toolchain }} llvm-cov --workspace {{ all_crate_features }} --lcov --output-path lcov.info + # Document crates in workspace. doc *args: RUSTDOCFLAGS="--cfg=docsrs -Dwarnings" cargo +nightly doc --no-deps --workspace {{ all_crate_features }} {{ args }} From 59e42c1446c7524f8c72a89cd8682e58f81d0376 Mon Sep 17 00:00:00 2001 From: Matt Palmer Date: Mon, 10 Jun 2024 11:19:35 +1000 Subject: [PATCH 139/151] Return 415 rather than 400 on Urlencoded Content-Type mismatch (#3334) Co-authored-by: Rob Ede --- actix-web/CHANGES.md | 1 + actix-web/src/error/mod.rs | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/actix-web/CHANGES.md b/actix-web/CHANGES.md index 3d9176de..28dd25fb 100644 --- a/actix-web/CHANGES.md +++ b/actix-web/CHANGES.md @@ -5,6 +5,7 @@ ### Fixed - `ConnectionInfo::realip_remote_addr()` now handles IPv6 addresses from `Forwarded` header correctly. Previously, it sometimes returned the forwarded port as well. +- The `UrlencodedError::ContentType` variant (relevant to the `Form` extractor) now uses the 415 (Media Type Unsupported) status code in it's `ResponseError` implementation. ## 4.7.0 diff --git a/actix-web/src/error/mod.rs b/actix-web/src/error/mod.rs index 91a6bcc3..25535332 100644 --- a/actix-web/src/error/mod.rs +++ b/actix-web/src/error/mod.rs @@ -100,6 +100,7 @@ impl ResponseError for UrlencodedError { match self { Self::Overflow { .. } => StatusCode::PAYLOAD_TOO_LARGE, Self::UnknownLength => StatusCode::LENGTH_REQUIRED, + Self::ContentType => StatusCode::UNSUPPORTED_MEDIA_TYPE, Self::Payload(err) => err.status_code(), _ => StatusCode::BAD_REQUEST, } @@ -232,7 +233,7 @@ mod tests { let resp = UrlencodedError::UnknownLength.error_response(); assert_eq!(resp.status(), StatusCode::LENGTH_REQUIRED); let resp = UrlencodedError::ContentType.error_response(); - assert_eq!(resp.status(), StatusCode::BAD_REQUEST); + assert_eq!(resp.status(), StatusCode::UNSUPPORTED_MEDIA_TYPE); } #[test] From 2ee92d778ec82b3a879967dd5bb690b8eed26f7c Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Mon, 10 Jun 2024 03:39:06 +0100 Subject: [PATCH 140/151] ci: external types checking (#3175) --- .github/workflows/lint.yml | 25 ++++++++++++++++++++++++- actix-files/Cargo.toml | 11 ++++++++--- actix-http-test/Cargo.toml | 14 +++++++++++--- actix-http/Cargo.toml | 23 ++++++++++++++++++++--- actix-multipart/Cargo.toml | 15 +++++++++++++++ actix-router/Cargo.toml | 8 +++++--- actix-test/Cargo.toml | 16 ++++++++++++++++ actix-web-actors/Cargo.toml | 12 +++++++++--- actix-web/Cargo.toml | 28 +++++++++++++++++++++++++--- awc/Cargo.toml | 27 ++++++++++++++++++++++----- justfile | 26 ++++++++++++++++++++++++++ 11 files changed, 181 insertions(+), 24 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 8fe8f59d..ca9d2bbe 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -65,6 +65,29 @@ jobs: RUSTDOCFLAGS: -D warnings run: cargo +nightly doc --no-deps --workspace --all-features + check-external-types: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Install Rust (nightly-2024-05-01) + uses: actions-rust-lang/setup-rust-toolchain@v1.9.0 + with: + toolchain: nightly-2024-05-01 + + - name: Install just + uses: taiki-e/install-action@v2.38.0 + with: + tool: just + + - name: Install cargo-check-external-types + uses: taiki-e/cache-cargo-install-action@v1.2.2 + with: + tool: cargo-check-external-types + + - name: check external types + run: just check-external-types-all +nightly-2024-05-01 + public-api-diff: runs-on: ubuntu-latest steps: @@ -76,7 +99,7 @@ jobs: - name: Checkout PR branch uses: actions/checkout@v4 - - name: Install Rust + - name: Install Rust (nightly-2024-06-07) uses: actions-rust-lang/setup-rust-toolchain@v1.9.0 with: toolchain: nightly-2024-06-07 diff --git a/actix-files/Cargo.toml b/actix-files/Cargo.toml index 7adb8eaf..57cd4e91 100644 --- a/actix-files/Cargo.toml +++ b/actix-files/Cargo.toml @@ -13,9 +13,14 @@ categories = ["asynchronous", "web-programming::http-server"] license = "MIT OR Apache-2.0" edition = "2021" -[lib] -name = "actix_files" -path = "src/lib.rs" +[package.metadata.cargo_check_external_types] +allowed_external_types = [ + "actix_http::*", + "actix_service::*", + "actix_web::*", + "http::*", + "mime::*", +] [features] experimental-io-uring = ["actix-web/experimental-io-uring", "tokio-uring"] diff --git a/actix-http-test/Cargo.toml b/actix-http-test/Cargo.toml index bfb0a353..0947579a 100644 --- a/actix-http-test/Cargo.toml +++ b/actix-http-test/Cargo.toml @@ -18,9 +18,17 @@ edition = "2021" [package.metadata.docs.rs] features = [] -[lib] -name = "actix_http_test" -path = "src/lib.rs" +[package.metadata.cargo_check_external_types] +allowed_external_types = [ + "actix_codec::*", + "actix_http::*", + "actix_server::*", + "awc::*", + "bytes::*", + "futures_core::*", + "http::*", + "tokio::*", +] [features] default = [] diff --git a/actix-http/Cargo.toml b/actix-http/Cargo.toml index 87e2b391..4dc0f0bd 100644 --- a/actix-http/Cargo.toml +++ b/actix-http/Cargo.toml @@ -34,9 +34,26 @@ features = [ "compress-zstd", ] -[lib] -name = "actix_http" -path = "src/lib.rs" +[package.metadata.cargo_check_external_types] +allowed_external_types = [ + "actix_codec::*", + "actix_service::*", + "actix_tls::*", + "actix_utils::*", + "bytes::*", + "bytestring::*", + "encoding_rs::*", + "futures_core::*", + "h2::*", + "http::*", + "httparse::*", + "language_tags::*", + "mime::*", + "openssl::*", + "rustls::*", + "tokio_util::*", + "tokio::*", +] [features] default = [] diff --git a/actix-multipart/Cargo.toml b/actix-multipart/Cargo.toml index f1289d3a..5e9b78d8 100644 --- a/actix-multipart/Cargo.toml +++ b/actix-multipart/Cargo.toml @@ -16,6 +16,21 @@ edition = "2021" rustdoc-args = ["--cfg", "docsrs"] all-features = true +[package.metadata.cargo_check_external_types] +allowed_external_types = [ + "actix_http::*", + "actix_multipart_derive::*", + "actix_utils::*", + "actix_web::*", + "bytes::*", + "futures_core::*", + "mime::*", + "serde_json::*", + "serde_plain::*", + "serde::*", + "tempfile::*", +] + [features] default = ["tempfile", "derive"] derive = ["actix-multipart-derive"] diff --git a/actix-router/Cargo.toml b/actix-router/Cargo.toml index 56e4bed2..7e7e3beb 100644 --- a/actix-router/Cargo.toml +++ b/actix-router/Cargo.toml @@ -12,9 +12,11 @@ repository = "https://github.com/actix/actix-web" license = "MIT OR Apache-2.0" edition = "2021" -[lib] -name = "actix_router" -path = "src/lib.rs" +[package.metadata.cargo_check_external_types] +allowed_external_types = [ + "http::*", + "serde::*", +] [features] default = ["http", "unicode"] diff --git a/actix-test/Cargo.toml b/actix-test/Cargo.toml index 41267c96..e810ae80 100644 --- a/actix-test/Cargo.toml +++ b/actix-test/Cargo.toml @@ -18,6 +18,22 @@ categories = [ license = "MIT OR Apache-2.0" edition = "2021" +[package.metadata.cargo_check_external_types] +allowed_external_types = [ + "actix_codec::*", + "actix_http_test::*", + "actix_http::*", + "actix_service::*", + "actix_web::*", + "awc::*", + "bytes::*", + "futures_core::*", + "http::*", + "openssl::*", + "rustls::*", + "tokio::*", +] + [features] default = [] diff --git a/actix-web-actors/Cargo.toml b/actix-web-actors/Cargo.toml index 114ec5a8..3c74a4f4 100644 --- a/actix-web-actors/Cargo.toml +++ b/actix-web-actors/Cargo.toml @@ -9,9 +9,15 @@ repository = "https://github.com/actix/actix-web" license = "MIT OR Apache-2.0" edition = "2021" -[lib] -name = "actix_web_actors" -path = "src/lib.rs" +[package.metadata.cargo_check_external_types] +allowed_external_types = [ + "actix::*", + "actix_http::*", + "actix_web::*", + "bytes::*", + "bytestring::*", + "futures_core::*", +] [dependencies] actix = { version = ">=0.12, <0.14", default-features = false } diff --git a/actix-web/Cargo.toml b/actix-web/Cargo.toml index 10a50768..3827d440 100644 --- a/actix-web/Cargo.toml +++ b/actix-web/Cargo.toml @@ -35,9 +35,31 @@ features = [ "secure-cookies", ] -[lib] -name = "actix_web" -path = "src/lib.rs" +[package.metadata.cargo_check_external_types] +allowed_external_types = [ + "actix_http::*", + "actix_router::*", + "actix_rt::*", + "actix_server::*", + "actix_service::*", + "actix_utils::*", + "actix_web_codegen::*", + "bytes::*", + "cookie::*", + "cookie", + "futures_core::*", + "http::*", + "language_tags::*", + "mime::*", + "openssl::*", + "rustls::*", + "serde_json::*", + "serde_urlencoded::*", + "serde::*", + "serde::*", + "tokio::*", + "url::*", +] [features] default = [ diff --git a/awc/Cargo.toml b/awc/Cargo.toml index 6ab408ea..4fc2057f 100644 --- a/awc/Cargo.toml +++ b/awc/Cargo.toml @@ -15,10 +15,6 @@ repository = "https://github.com/actix/actix-web" license = "MIT OR Apache-2.0" edition = "2021" -[lib] -name = "awc" -path = "src/lib.rs" - [package.metadata.docs.rs] rustdoc-args = ["--cfg", "docsrs"] features = [ @@ -33,6 +29,27 @@ features = [ "compress-zstd", ] +[package.metadata.cargo_check_external_types] +allowed_external_types = [ + "actix_codec::*", + "actix_http::*", + "actix_rt::*", + "actix_service::*", + "actix_tls::*", + "bytes::*", + "cookie::*", + "cookie", + "futures_core::*", + "h2::*", + "http::*", + "openssl::*", + "rustls::*", + "serde_json::*", + "serde_urlencoded::*", + "serde::*", + "tokio::*", +] + [features] default = ["compress-brotli", "compress-gzip", "compress-zstd", "cookies"] @@ -134,7 +151,7 @@ rcgen = "0.13" rustls-pemfile = "2" tokio = { version = "1.24.2", features = ["rt-multi-thread", "macros"] } zstd = "0.13" -tls-rustls-0_23 = { package = "rustls", version = "0.23" } # add rustls 0.23 with default features to make aws_lc_rs work in tests +tls-rustls-0_23 = { package = "rustls", version = "0.23" } # add rustls 0.23 with default features to make aws_lc_rs work in tests [[example]] name = "client" diff --git a/justfile b/justfile index 7f6dbb61..28b4dfd0 100644 --- a/justfile +++ b/justfile @@ -74,3 +74,29 @@ doc-watch: update-readmes: && fmt cd ./actix-files && cargo rdme --force cd ./actix-router && cargo rdme --force + +# Check for unintentional external type exposure on all crates in workspace. +check-external-types-all toolchain="+nightly": + #!/usr/bin/env bash + set -euo pipefail + exit=0 + for f in $(find . -mindepth 2 -maxdepth 2 -name Cargo.toml | grep -vE "\-codegen/|\-derive/|\-macros/"); do + if ! just check-external-types-manifest "$f" {{toolchain}}; then exit=1; fi + echo + echo + done + exit $exit + +# Check for unintentional external type exposure on all crates in workspace. +check-external-types-all-table toolchain="+nightly": + #!/usr/bin/env bash + set -euo pipefail + for f in $(find . -mindepth 2 -maxdepth 2 -name Cargo.toml | grep -vE "\-codegen/|\-derive/|\-macros/"); do + echo + echo "Checking for $f" + just check-external-types-manifest "$f" {{toolchain}} --output-format=markdown-table + done + +# Check for unintentional external type exposure on a crate. +check-external-types-manifest manifest_path toolchain="+nightly" *extra_args="": + cargo {{toolchain}} check-external-types --manifest-path "{{manifest_path}}" {{extra_args}} From 7a2313cc4b6a9ff613903c7684162e3129ef7b72 Mon Sep 17 00:00:00 2001 From: Timo Caktu <74780331+TimoCak@users.noreply.github.com> Date: Mon, 10 Jun 2024 04:49:50 +0200 Subject: [PATCH 141/151] web: add `HttpRequest::full_url()` (#3096) * implemented function which returns full uir * changes added into the changelog * added test funtion for full_uri method * refactor: rename to full_url --------- Co-authored-by: Rob Ede --- actix-web/CHANGES.md | 4 ++++ actix-web/src/request.rs | 52 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) diff --git a/actix-web/CHANGES.md b/actix-web/CHANGES.md index 28dd25fb..bb0844e0 100644 --- a/actix-web/CHANGES.md +++ b/actix-web/CHANGES.md @@ -2,6 +2,10 @@ ## Unreleased +### Added + +- Add `HttpRequest::full_url()` method to get the complete URL of the request. + ### Fixed - `ConnectionInfo::realip_remote_addr()` now handles IPv6 addresses from `Forwarded` header correctly. Previously, it sometimes returned the forwarded port as well. diff --git a/actix-web/src/request.rs b/actix-web/src/request.rs index 08a222c8..47b3e3d8 100644 --- a/actix-web/src/request.rs +++ b/actix-web/src/request.rs @@ -91,6 +91,35 @@ impl HttpRequest { &self.head().uri } + /// Returns request's original full URL. + /// + /// Reconstructed URL is best-effort, using [`connection_info`](HttpRequest::connection_info()) + /// to get forwarded scheme & host. + /// + /// ``` + /// use actix_web::test::TestRequest; + /// let req = TestRequest::with_uri("http://10.1.2.3:8443/api?id=4&name=foo") + /// .insert_header(("host", "example.com")) + /// .to_http_request(); + /// + /// assert_eq!( + /// req.full_url().as_str(), + /// "http://example.com/api?id=4&name=foo", + /// ); + /// ``` + pub fn full_url(&self) -> url::Url { + let info = self.connection_info(); + let scheme = info.scheme(); + let host = info.host(); + let path_and_query = self + .uri() + .path_and_query() + .map(|paq| paq.as_str()) + .unwrap_or("/"); + + url::Url::parse(&format!("{scheme}://{host}{path_and_query}")).unwrap() + } + /// Read the Request method. #[inline] pub fn method(&self) -> &Method { @@ -963,4 +992,27 @@ mod tests { assert!(format!("{:?}", req).contains(location_header)); } + + #[test] + fn check_full_url() { + let req = TestRequest::with_uri("/api?id=4&name=foo").to_http_request(); + assert_eq!( + req.full_url().as_str(), + "http://localhost:8080/api?id=4&name=foo", + ); + + let req = TestRequest::with_uri("https://example.com/api?id=4&name=foo").to_http_request(); + assert_eq!( + req.full_url().as_str(), + "https://example.com/api?id=4&name=foo", + ); + + let req = TestRequest::with_uri("http://10.1.2.3:8443/api?id=4&name=foo") + .insert_header(("host", "example.com")) + .to_http_request(); + assert_eq!( + req.full_url().as_str(), + "http://example.com/api?id=4&name=foo", + ); + } } From d9579cf58af2230b651d476945639c17b31ef84a Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Mon, 10 Jun 2024 04:05:21 +0100 Subject: [PATCH 142/151] test: coverage for doctests --- .github/workflows/coverage.yml | 2 +- justfile | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index de7fd703..f1d78776 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -28,7 +28,7 @@ jobs: tool: just,cargo-llvm-cov - name: Generate code coverage - run: cargo llvm-cov --workspace --all-features --codecov --output-path codecov.json + run: just test-coverage-codecov - name: Upload coverage to Codecov uses: codecov/codecov-action@v4.4.1 diff --git a/justfile b/justfile index 28b4dfd0..530bf5f6 100644 --- a/justfile +++ b/justfile @@ -53,13 +53,19 @@ test-docs toolchain="": && doc # Test workspace. test-all toolchain="": (test toolchain) (test-docs toolchain) -# Test workspace and generate Codecov coverage file. -test-coverage-codecov toolchain="": - cargo {{ toolchain }} llvm-cov --workspace {{ all_crate_features }} --codecov --output-path codecov.json +# Test workspace and collect coverage info. +[private] +test-coverage toolchain="": + cargo {{ toolchain }} llvm-cov nextest --no-report {{ all_crate_features }} + cargo {{ toolchain }} llvm-cov --doc --no-report {{ all_crate_features }} -# Test workspace and generate LCOV coverage file. -test-coverage-lcov toolchain="": - cargo {{ toolchain }} llvm-cov --workspace {{ all_crate_features }} --lcov --output-path lcov.info +# Test workspace and generate Codecov report. +test-coverage-codecov toolchain="": (test-coverage toolchain) + cargo {{ toolchain }} llvm-cov report --doctests --codecov --output-path=codecov.json + +# Test workspace and generate LCOV report. +test-coverage-lcov toolchain="": (test-coverage toolchain) + cargo {{ toolchain }} llvm-cov report --doctests --lcov --output-path=lcov.info # Document crates in workspace. doc *args: From 9553e7afff8661dd8805f77a24a1d178e1665d3a Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Mon, 10 Jun 2024 04:08:10 +0100 Subject: [PATCH 143/151] ci: fix coverage --- .github/workflows/coverage.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index f1d78776..7aeea629 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -22,10 +22,10 @@ jobs: with: components: llvm-tools-preview - - name: Install just,cargo-llvm-cov + - name: Install just, cargo-llvm-cov, cargo-nextest uses: taiki-e/install-action@v2.38.0 with: - tool: just,cargo-llvm-cov + tool: just,cargo-llvm-cov,cargo-nextest - name: Generate code coverage run: just test-coverage-codecov From 9b3de1f1fe59bd6d3ebc645590eb49f77260a20b Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Mon, 10 Jun 2024 04:15:58 +0100 Subject: [PATCH 144/151] ci: fix doctest coverage --- .github/workflows/coverage.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 7aeea629..ca311571 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -17,10 +17,11 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Install Rust + - name: Install Rust (nightly) uses: actions-rust-lang/setup-rust-toolchain@v1.9.0 with: - components: llvm-tools-preview + toolchain: nightly + components: llvm-tools - name: Install just, cargo-llvm-cov, cargo-nextest uses: taiki-e/install-action@v2.38.0 From 0fd85bae2a8fa5f804c88f01aacb2202f44baed7 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Mon, 10 Jun 2024 21:51:53 +0100 Subject: [PATCH 145/151] test: demonstrate panic in multipart forms (#3397) --- actix-multipart/src/form/mod.rs | 66 ++++++++++++++++++++++++++++++++- actix-multipart/src/server.rs | 19 ++++++++-- 2 files changed, 80 insertions(+), 5 deletions(-) diff --git a/actix-multipart/src/form/mod.rs b/actix-multipart/src/form/mod.rs index 451b103f..6fbdfa1a 100644 --- a/actix-multipart/src/form/mod.rs +++ b/actix-multipart/src/form/mod.rs @@ -33,6 +33,14 @@ pub trait FieldReader<'t>: Sized + Any { type Future: Future>; /// The form will call this function to handle the field. + /// + /// # Panics + /// + /// When reading the `field` payload using its `Stream` implementation, polling (manually or via + /// `next()`/`try_next()`) may panic after the payload is exhausted. If this is a problem for + /// your implementation of this method, you should [`fuse()`] the `Field` first. + /// + /// [`fuse()`]: https://docs.rs/futures-util/0.3/futures_util/stream/trait.StreamExt.html#method.fuse fn read_field(req: &'t HttpRequest, field: Field, limits: &'t mut Limits) -> Self::Future; } @@ -396,11 +404,20 @@ mod tests { use actix_http::encoding::Decoder; use actix_multipart_rfc7578::client::multipart; use actix_test::TestServer; - use actix_web::{dev::Payload, http::StatusCode, web, App, HttpResponse, Responder}; + use actix_web::{ + dev::Payload, http::StatusCode, web, App, HttpRequest, HttpResponse, Resource, Responder, + }; use awc::{Client, ClientResponse}; + use futures_core::future::LocalBoxFuture; + use futures_util::TryStreamExt as _; use super::MultipartForm; - use crate::form::{bytes::Bytes, tempfile::TempFile, text::Text, MultipartFormConfig}; + use crate::{ + form::{ + bytes::Bytes, tempfile::TempFile, text::Text, FieldReader, Limits, MultipartFormConfig, + }, + Field, MultipartError, + }; pub async fn send_form( srv: &TestServer, @@ -734,4 +751,49 @@ mod tests { let response = send_form(&srv, form, "/").await; assert_eq!(response.status(), StatusCode::BAD_REQUEST); } + + #[should_panic(expected = "called `Result::unwrap()` on an `Err` value: Connect(Disconnected)")] + #[actix_web::test] + async fn field_try_next_panic() { + #[derive(Debug)] + struct NullSink; + + impl<'t> FieldReader<'t> for NullSink { + type Future = LocalBoxFuture<'t, Result>; + + fn read_field( + _: &'t HttpRequest, + mut field: Field, + _limits: &'t mut Limits, + ) -> Self::Future { + Box::pin(async move { + // exhaust field stream + while let Some(_chunk) = field.try_next().await? {} + + // poll again, crash + let _post = field.try_next().await; + + Ok(Self) + }) + } + } + + #[allow(dead_code)] + #[derive(MultipartForm)] + struct NullSinkForm { + foo: NullSink, + } + + async fn null_sink(_form: MultipartForm) -> impl Responder { + "unreachable" + } + + let srv = actix_test::start(|| App::new().service(Resource::new("/").post(null_sink))); + + let mut form = multipart::Form::default(); + form.add_text("foo", "data is not important to this test"); + + // panics with Err(Connect(Disconnected)) due to form NullSink panic + let _res = send_form(&srv, form, "/").await; + } } diff --git a/actix-multipart/src/server.rs b/actix-multipart/src/server.rs index d0f83331..0256aa7b 100644 --- a/actix-multipart/src/server.rs +++ b/actix-multipart/src/server.rs @@ -465,7 +465,12 @@ impl Stream for Field { fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { let this = self.get_mut(); let mut inner = this.inner.borrow_mut(); - if let Some(mut buffer) = inner.payload.as_ref().unwrap().get_mut(&this.safety) { + if let Some(mut buffer) = inner + .payload + .as_ref() + .expect("Field should not be polled after completion") + .get_mut(&this.safety) + { // check safety and poll read payload to buffer. buffer.poll_stream(cx)?; } else if !this.safety.is_clean() { @@ -496,6 +501,7 @@ impl fmt::Debug for Field { } struct InnerField { + /// Payload is initialized as Some and is `take`n when the field stream finishes. payload: Option, boundary: String, eof: bool, @@ -643,7 +649,12 @@ impl InnerField { return Poll::Ready(None); } - let result = if let Some(mut payload) = self.payload.as_ref().unwrap().get_mut(s) { + let result = if let Some(mut payload) = self + .payload + .as_ref() + .expect("Field should not be polled after completion") + .get_mut(s) + { if !self.eof { let res = if let Some(ref mut len) = self.length { InnerField::read_len(&mut payload, len) @@ -674,8 +685,10 @@ impl InnerField { }; if let Poll::Ready(None) = result { - self.payload.take(); + // drop payload buffer and make future un-poll-able + let _ = self.payload.take(); } + result } } From 4c4c27993864249d58d9e3a04c9c80cf4f7d678c Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Mon, 10 Jun 2024 23:23:38 +0100 Subject: [PATCH 146/151] docs(test): intrgrate cargo-rdme --- actix-multipart/src/form/mod.rs | 2 +- actix-test/README.md | 45 +++++++++++++++++++++++++++++++++ actix-test/src/lib.rs | 1 + justfile | 1 + 4 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 actix-test/README.md diff --git a/actix-multipart/src/form/mod.rs b/actix-multipart/src/form/mod.rs index 6fbdfa1a..68cdefec 100644 --- a/actix-multipart/src/form/mod.rs +++ b/actix-multipart/src/form/mod.rs @@ -40,7 +40,7 @@ pub trait FieldReader<'t>: Sized + Any { /// `next()`/`try_next()`) may panic after the payload is exhausted. If this is a problem for /// your implementation of this method, you should [`fuse()`] the `Field` first. /// - /// [`fuse()`]: https://docs.rs/futures-util/0.3/futures_util/stream/trait.StreamExt.html#method.fuse + /// [`fuse()`]: futures_util::stream::StreamExt::fuse() fn read_field(req: &'t HttpRequest, field: Field, limits: &'t mut Limits) -> Self::Future; } diff --git a/actix-test/README.md b/actix-test/README.md new file mode 100644 index 00000000..1a9b6f22 --- /dev/null +++ b/actix-test/README.md @@ -0,0 +1,45 @@ +# `actix-test` + + + +[![crates.io](https://img.shields.io/crates/v/actix-test?label=latest)](https://crates.io/crates/actix-test) +[![Documentation](https://docs.rs/actix-test/badge.svg?version=0.1.5)](https://docs.rs/actix-test/0.1.5) +![Version](https://img.shields.io/badge/rustc-1.72+-ab6000.svg) +![MIT or Apache 2.0 licensed](https://img.shields.io/crates/l/actix-test.svg) +
+[![dependency status](https://deps.rs/crate/actix-test/0.1.5/status.svg)](https://deps.rs/crate/actix-test/0.1.5) +[![Download](https://img.shields.io/crates/d/actix-test.svg)](https://crates.io/crates/actix-test) +[![Chat on Discord](https://img.shields.io/discord/771444961383153695?label=chat&logo=discord)](https://discord.gg/NWpN5mmg3x) + + + + + +Integration testing tools for Actix Web applications. + +The main integration testing tool is [`TestServer`]. It spawns a real HTTP server on an unused port and provides methods that use a real HTTP client. Therefore, it is much closer to real-world cases than using `init_service`, which skips HTTP encoding and decoding. + +## Examples + +```rust +use actix_web::{get, web, test, App, HttpResponse, Error, Responder}; + +#[get("/")] +async fn my_handler() -> Result { + Ok(HttpResponse::Ok()) +} + +#[actix_rt::test] +async fn test_example() { + let srv = actix_test::start(|| + App::new().service(my_handler) + ); + + let req = srv.get("/"); + let res = req.send().await.unwrap(); + + assert!(res.status().is_success()); +} +``` + + diff --git a/actix-test/src/lib.rs b/actix-test/src/lib.rs index 80332060..9be99978 100644 --- a/actix-test/src/lib.rs +++ b/actix-test/src/lib.rs @@ -5,6 +5,7 @@ //! real-world cases than using `init_service`, which skips HTTP encoding and decoding. //! //! # Examples +//! //! ``` //! use actix_web::{get, web, test, App, HttpResponse, Error, Responder}; //! diff --git a/justfile b/justfile index 530bf5f6..2ea6031f 100644 --- a/justfile +++ b/justfile @@ -80,6 +80,7 @@ doc-watch: update-readmes: && fmt cd ./actix-files && cargo rdme --force cd ./actix-router && cargo rdme --force + cd ./actix-test && cargo rdme --force # Check for unintentional external type exposure on all crates in workspace. check-external-types-all toolchain="+nightly": From cd301a6932e274229ced4904d87600500a692229 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Mon, 10 Jun 2024 23:30:51 +0100 Subject: [PATCH 147/151] docs: local docs doc everything but only list workspace crates --- justfile | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/justfile b/justfile index 2ea6031f..f44236ec 100644 --- a/justfile +++ b/justfile @@ -68,8 +68,17 @@ test-coverage-lcov toolchain="": (test-coverage toolchain) cargo {{ toolchain }} llvm-cov report --doctests --lcov --output-path=lcov.info # Document crates in workspace. -doc *args: - RUSTDOCFLAGS="--cfg=docsrs -Dwarnings" cargo +nightly doc --no-deps --workspace {{ all_crate_features }} {{ args }} +doc *args: && doc-set-workspace-crates + RUSTDOCFLAGS="--cfg=docsrs -Dwarnings" cargo +nightly doc --workspace {{ all_crate_features }} {{ args }} + +[private] +doc-set-workspace-crates: + #!/usr/bin/env bash + ( + echo "window.ALL_CRATES =" + cargo metadata --format-version=1 | jq '[.packages[] | select(.source == null) | .name]' + echo ";" + ) > "$CARGO_TARGET_DIR/doc/crates.js" # Document crates in workspace and watch for changes. doc-watch: From cc5030c542084fefee87cce743286b79b6a58fb8 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Mon, 10 Jun 2024 23:31:45 +0100 Subject: [PATCH 148/151] docs(http-test): use cargo-rdme --- actix-http-test/README.md | 8 ++++++-- justfile | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/actix-http-test/README.md b/actix-http-test/README.md index ee242d1d..93902812 100644 --- a/actix-http-test/README.md +++ b/actix-http-test/README.md @@ -1,7 +1,5 @@ # `actix-http-test` -> Various helpers for Actix applications to use during testing. - [![crates.io](https://img.shields.io/crates/v/actix-http-test?label=latest)](https://crates.io/crates/actix-http-test) @@ -14,3 +12,9 @@ [![Chat on Discord](https://img.shields.io/discord/771444961383153695?label=chat&logo=discord)](https://discord.gg/NWpN5mmg3x) + + + +Various helpers for Actix applications to use during testing. + + diff --git a/justfile b/justfile index f44236ec..9f909bfa 100644 --- a/justfile +++ b/justfile @@ -88,6 +88,7 @@ doc-watch: # Update READMEs from crate root documentation. update-readmes: && fmt cd ./actix-files && cargo rdme --force + cd ./actix-http-test && cargo rdme --force cd ./actix-router && cargo rdme --force cd ./actix-test && cargo rdme --force From 132b84d3b1f0f01a8a4923c442039ba46f845977 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Mon, 10 Jun 2024 23:35:26 +0100 Subject: [PATCH 149/151] docs(multipart): use cargo-rdme --- actix-multipart/README.md | 21 ++++++--------------- actix-multipart/src/lib.rs | 2 ++ justfile | 1 + 3 files changed, 9 insertions(+), 15 deletions(-) diff --git a/actix-multipart/README.md b/actix-multipart/README.md index c7697785..ef763063 100644 --- a/actix-multipart/README.md +++ b/actix-multipart/README.md @@ -1,7 +1,5 @@ # `actix-multipart` -> Multipart form support for Actix Web. - [![crates.io](https://img.shields.io/crates/v/actix-multipart?label=latest)](https://crates.io/crates/actix-multipart) @@ -15,18 +13,13 @@ -## Example + -Dependencies: +Multipart form support for Actix Web. -```toml -[dependencies] -actix-multipart = "0.6" -actix-web = "4.5" -serde = { version = "1.0", features = ["derive"] } -``` +## Examples -Code: +[More available in the examples repo →](https://github.com/actix/examples/tree/master/forms/multipart) ```rust use actix_web::{post, App, HttpServer, Responder}; @@ -63,6 +56,8 @@ async fn main() -> std::io::Result<()> { } ``` + + Curl request : ```bash @@ -71,7 +66,3 @@ curl -v --request POST \ -F 'json={"name": "Cargo.lock"};type=application/json' \ -F file=@./Cargo.lock ``` - -### Examples - -https://github.com/actix/examples/tree/master/forms/multipart diff --git a/actix-multipart/src/lib.rs b/actix-multipart/src/lib.rs index d19e951e..51b06db3 100644 --- a/actix-multipart/src/lib.rs +++ b/actix-multipart/src/lib.rs @@ -1,5 +1,7 @@ //! Multipart form support for Actix Web. +//! //! # Examples +//! //! ```no_run //! use actix_web::{post, App, HttpServer, Responder}; //! diff --git a/justfile b/justfile index 9f909bfa..d15ffcf6 100644 --- a/justfile +++ b/justfile @@ -90,6 +90,7 @@ update-readmes: && fmt cd ./actix-files && cargo rdme --force cd ./actix-http-test && cargo rdme --force cd ./actix-router && cargo rdme --force + cd ./actix-multipart && cargo rdme --force cd ./actix-test && cargo rdme --force # Check for unintentional external type exposure on all crates in workspace. From 0ce488e57a06f8971f9dd8b51b16766c682bd9cc Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Mon, 10 Jun 2024 23:54:16 +0100 Subject: [PATCH 150/151] docs: fix build --- justfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/justfile b/justfile index d15ffcf6..646c6b44 100644 --- a/justfile +++ b/justfile @@ -78,7 +78,7 @@ doc-set-workspace-crates: echo "window.ALL_CRATES =" cargo metadata --format-version=1 | jq '[.packages[] | select(.source == null) | .name]' echo ";" - ) > "$CARGO_TARGET_DIR/doc/crates.js" + ) > "$(cargo metadata --format-version=1 | jq -r '.target_directory')/doc/crates.js" # Document crates in workspace and watch for changes. doc-watch: From 188206a90382111e2d8337febf4f6965c0730b6e Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Tue, 11 Jun 2024 00:36:46 +0100 Subject: [PATCH 151/151] feat: Html responder (#3399) --- actix-multipart/README.md | 4 +-- actix-web/CHANGES.md | 1 + actix-web/README.md | 2 +- actix-web/src/types/html.rs | 66 +++++++++++++++++++++++++++++++++++++ actix-web/src/types/mod.rs | 2 ++ 5 files changed, 72 insertions(+), 3 deletions(-) create mode 100644 actix-web/src/types/html.rs diff --git a/actix-multipart/README.md b/actix-multipart/README.md index ef763063..d61347f3 100644 --- a/actix-multipart/README.md +++ b/actix-multipart/README.md @@ -19,8 +19,6 @@ Multipart form support for Actix Web. ## Examples -[More available in the examples repo →](https://github.com/actix/examples/tree/master/forms/multipart) - ```rust use actix_web::{post, App, HttpServer, Responder}; @@ -58,6 +56,8 @@ async fn main() -> std::io::Result<()> { +[More available in the examples repo →](https://github.com/actix/examples/tree/master/forms/multipart) + Curl request : ```bash diff --git a/actix-web/CHANGES.md b/actix-web/CHANGES.md index bb0844e0..54c7045a 100644 --- a/actix-web/CHANGES.md +++ b/actix-web/CHANGES.md @@ -4,6 +4,7 @@ ### Added +- Add `web::Html` responder. - Add `HttpRequest::full_url()` method to get the complete URL of the request. ### Fixed diff --git a/actix-web/README.md b/actix-web/README.md index 8b4375bd..3f9d3e0d 100644 --- a/actix-web/README.md +++ b/actix-web/README.md @@ -109,4 +109,4 @@ This project is licensed under either of the following licenses, at your option: ## Code of Conduct -Contribution to the actix-web repo is organized under the terms of the Contributor Covenant. The Actix team promises to intervene to uphold that code of conduct. +Contribution to the `actix/actix-web` repo is organized under the terms of the Contributor Covenant. The Actix team promises to intervene to uphold that code of conduct. diff --git a/actix-web/src/types/html.rs b/actix-web/src/types/html.rs new file mode 100644 index 00000000..c370ee07 --- /dev/null +++ b/actix-web/src/types/html.rs @@ -0,0 +1,66 @@ +//! Semantic HTML responder. See [`Html`]. + +use crate::{ + http::{ + header::{self, ContentType, TryIntoHeaderValue}, + StatusCode, + }, + HttpRequest, HttpResponse, Responder, +}; + +/// Semantic HTML responder. +/// +/// When used as a responder, creates a 200 OK response, sets the correct HTML content type, and +/// uses the string passed to [`Html::new()`] as the body. +/// +/// ``` +/// # use actix_web::web::Html; +/// Html::new("

Hello, World!

") +/// # ; +/// ``` +#[derive(Debug, Clone, PartialEq, Hash)] +pub struct Html(String); + +impl Html { + /// Constructs a new `Html` responder. + pub fn new(html: impl Into) -> Self { + Self(html.into()) + } +} + +impl Responder for Html { + type Body = String; + + fn respond_to(self, _req: &HttpRequest) -> HttpResponse { + let mut res = HttpResponse::with_body(StatusCode::OK, self.0); + res.headers_mut().insert( + header::CONTENT_TYPE, + ContentType::html().try_into_value().unwrap(), + ); + res + } +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::test::TestRequest; + + #[test] + fn responder() { + let req = TestRequest::default().to_http_request(); + + let res = Html::new("

Hello, World!

"); + let res = res.respond_to(&req); + + assert!(res.status().is_success()); + assert!(res + .headers() + .get(header::CONTENT_TYPE) + .unwrap() + .to_str() + .unwrap() + .starts_with("text/html")); + assert!(res.body().starts_with("

")); + } +} diff --git a/actix-web/src/types/mod.rs b/actix-web/src/types/mod.rs index 792edd65..cabe53d6 100644 --- a/actix-web/src/types/mod.rs +++ b/actix-web/src/types/mod.rs @@ -3,6 +3,7 @@ mod either; mod form; mod header; +mod html; mod json; mod path; mod payload; @@ -13,6 +14,7 @@ pub use self::{ either::Either, form::{Form, FormConfig, UrlEncoded}, header::Header, + html::Html, json::{Json, JsonBody, JsonConfig}, path::{Path, PathConfig}, payload::{Payload, PayloadConfig},