From 8690f80a08cf064009854d6ff0dcbd108dd39e07 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 3 Feb 2025 16:57:05 +0000 Subject: [PATCH 1/7] build(deps): bump taiki-e/install-action from 2.47.18 to 2.48.1 (#3563) Bumps [taiki-e/install-action](https://github.com/taiki-e/install-action) from 2.47.18 to 2.48.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.47.18...v2.48.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 | 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 e856b0311..529278c0a 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.47.18 + uses: taiki-e/install-action@v2.48.1 with: tool: just,cargo-hack,cargo-nextest,cargo-ci-cache-clean @@ -83,7 +83,7 @@ jobs: uses: actions-rust-lang/setup-rust-toolchain@v1.10.1 - name: Install just, cargo-hack - uses: taiki-e/install-action@v2.47.18 + uses: taiki-e/install-action@v2.48.1 with: tool: just,cargo-hack diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 71d659b37..5f0ccfaf8 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.47.18 + uses: taiki-e/install-action@v2.48.1 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.47.18 + uses: taiki-e/install-action@v2.48.1 with: tool: just diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index bf7d5d5c2..fa85093ed 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -24,7 +24,7 @@ jobs: components: llvm-tools - name: Install just, cargo-llvm-cov, cargo-nextest - uses: taiki-e/install-action@v2.47.18 + uses: taiki-e/install-action@v2.48.1 with: tool: just,cargo-llvm-cov,cargo-nextest diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 9445cb566..323a8a5ae 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -77,7 +77,7 @@ jobs: toolchain: ${{ vars.RUST_VERSION_EXTERNAL_TYPES }} - name: Install just - uses: taiki-e/install-action@v2.47.18 + uses: taiki-e/install-action@v2.48.1 with: tool: just From a36280466c7ffdbc9dca3db5e4484a771df93e86 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 3 Feb 2025 18:59:09 +0000 Subject: [PATCH 2/7] build(deps): bump taiki-e/cache-cargo-install-action from 2.0.1 to 2.1.0 (#3555) Bumps [taiki-e/cache-cargo-install-action](https://github.com/taiki-e/cache-cargo-install-action) from 2.0.1 to 2.1.0. - [Release notes](https://github.com/taiki-e/cache-cargo-install-action/releases) - [Changelog](https://github.com/taiki-e/cache-cargo-install-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/taiki-e/cache-cargo-install-action/compare/v2.0.1...v2.1.0) --- updated-dependencies: - dependency-name: taiki-e/cache-cargo-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/lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 323a8a5ae..94906c852 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -82,7 +82,7 @@ jobs: tool: just - name: Install cargo-check-external-types - uses: taiki-e/cache-cargo-install-action@v2.0.1 + uses: taiki-e/cache-cargo-install-action@v2.1.0 with: tool: cargo-check-external-types From 182055bcb504a60d15ce8d01dba7e26dee439479 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 3 Feb 2025 18:59:22 +0000 Subject: [PATCH 3/7] build(deps): bump codecov/codecov-action from 5.1.2 to 5.3.1 (#3554) Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 5.1.2 to 5.3.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/v5.1.2...v5.3.1) --- 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 fa85093ed..7f0a74643 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -32,7 +32,7 @@ jobs: run: just test-coverage-codecov - name: Upload coverage to Codecov - uses: codecov/codecov-action@v5.1.2 + uses: codecov/codecov-action@v5.3.1 with: files: codecov.json fail_ci_if_error: true From 33b487e854c592dbd1deca98e4a8d6ce0007890c Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Sat, 25 Jan 2025 18:01:21 +0000 Subject: [PATCH 4/7] chore: address clippy lints --- actix-router/src/quoter.rs | 2 +- actix-router/src/resource.rs | 2 ++ actix-router/src/router.rs | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/actix-router/src/quoter.rs b/actix-router/src/quoter.rs index 6c929d3ac..78694ed72 100644 --- a/actix-router/src/quoter.rs +++ b/actix-router/src/quoter.rs @@ -105,7 +105,7 @@ fn hex_pair_to_char(d1: u8, d2: u8) -> Option { let d_low = char::from(d2).to_digit(16)?; // left shift high nibble by 4 bits - Some((d_high as u8) << 4 | (d_low as u8)) + Some(((d_high as u8) << 4) | (d_low as u8)) } #[derive(Debug, Default, Clone)] diff --git a/actix-router/src/resource.rs b/actix-router/src/resource.rs index 3a102945b..7069b5fea 100644 --- a/actix-router/src/resource.rs +++ b/actix-router/src/resource.rs @@ -1021,6 +1021,7 @@ impl ResourceDef { panic!("prefix resource definitions should not have tail segments"); } + #[allow(clippy::literal_string_with_formatting_args)] if unprocessed.ends_with('*') { // unnamed tail segment @@ -1369,6 +1370,7 @@ mod tests { assert_eq!(path.unprocessed(), ""); } + #[expect(clippy::literal_string_with_formatting_args)] #[test] fn newline_patterns_and_paths() { let re = ResourceDef::new("/user/a\nb"); diff --git a/actix-router/src/router.rs b/actix-router/src/router.rs index 1dd4449da..01f92e90b 100644 --- a/actix-router/src/router.rs +++ b/actix-router/src/router.rs @@ -145,6 +145,7 @@ mod tests { }; #[allow(clippy::cognitive_complexity)] + #[expect(clippy::literal_string_with_formatting_args)] #[test] fn test_recognizer_1() { let mut router = Router::::build(); From 59961a58a83e652769a6d26ac17c19422bffa9e7 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Sun, 9 Feb 2025 02:15:43 +0000 Subject: [PATCH 5/7] chore: fix msrv errors --- actix-router/src/resource.rs | 2 +- actix-router/src/router.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/actix-router/src/resource.rs b/actix-router/src/resource.rs index 7069b5fea..b5ee01958 100644 --- a/actix-router/src/resource.rs +++ b/actix-router/src/resource.rs @@ -1370,7 +1370,7 @@ mod tests { assert_eq!(path.unprocessed(), ""); } - #[expect(clippy::literal_string_with_formatting_args)] + #[allow(clippy::literal_string_with_formatting_args)] #[test] fn newline_patterns_and_paths() { let re = ResourceDef::new("/user/a\nb"); diff --git a/actix-router/src/router.rs b/actix-router/src/router.rs index 01f92e90b..b20cb7ee3 100644 --- a/actix-router/src/router.rs +++ b/actix-router/src/router.rs @@ -145,7 +145,7 @@ mod tests { }; #[allow(clippy::cognitive_complexity)] - #[expect(clippy::literal_string_with_formatting_args)] + #[allow(clippy::literal_string_with_formatting_args)] #[test] fn test_recognizer_1() { let mut router = Router::::build(); From 66e2afe306a35de08926316707cb44a8e56ca390 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 9 Feb 2025 02:39:22 +0000 Subject: [PATCH 6/7] build(deps): update rand requirement from 0.8 to 0.9 (#3564) * build(deps): update rand requirement from 0.8 to 0.9 Updates the requirements on [rand](https://github.com/rust-random/rand) to permit the latest version. - [Release notes](https://github.com/rust-random/rand/releases) - [Changelog](https://github.com/rust-random/rand/blob/master/CHANGELOG.md) - [Commits](https://github.com/rust-random/rand/compare/0.8.0...0.9.0) --- updated-dependencies: - dependency-name: rand dependency-type: direct:production ... Signed-off-by: dependabot[bot] * chore: fix rand upgrade * chore: address clippy lint --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Rob Ede --- actix-http/Cargo.toml | 2 +- actix-http/tests/test_server.rs | 6 +++++- actix-multipart/Cargo.toml | 2 +- actix-multipart/src/test.rs | 7 ++---- actix-web/Cargo.toml | 2 +- actix-web/tests/test_server.rs | 38 ++++++--------------------------- awc/Cargo.toml | 2 +- awc/src/ws.rs | 2 +- awc/tests/test_client.rs | 20 ++++------------- 9 files changed, 23 insertions(+), 58 deletions(-) diff --git a/actix-http/Cargo.toml b/actix-http/Cargo.toml index f164d8538..1d9a54a0d 100644 --- a/actix-http/Cargo.toml +++ b/actix-http/Cargo.toml @@ -132,7 +132,7 @@ h2 = { version = "0.3.26", optional = true } # websockets local-channel = { version = "0.1", optional = true } base64 = { version = "0.22", optional = true } -rand = { version = "0.8", optional = true } +rand = { version = "0.9", optional = true } sha1 = { version = "0.10", optional = true } # openssl/rustls diff --git a/actix-http/tests/test_server.rs b/actix-http/tests/test_server.rs index e93d35598..6f273ef33 100644 --- a/actix-http/tests/test_server.rs +++ b/actix-http/tests/test_server.rs @@ -16,6 +16,7 @@ use actix_utils::future::{err, ok, ready}; use bytes::Bytes; use derive_more::derive::{Display, Error}; use futures_util::{stream::once, FutureExt as _, StreamExt as _}; +use rand::Rng as _; use regex::Regex; #[actix_rt::test] @@ -164,7 +165,10 @@ async fn chunked_payload() { for chunk_size in chunk_sizes.iter() { let mut bytes = Vec::new(); - let random_bytes: Vec = (0..*chunk_size).map(|_| rand::random::()).collect(); + let random_bytes = rand::rng() + .sample_iter(rand::distr::StandardUniform) + .take(*chunk_size) + .collect::>(); bytes.extend(format!("{:X}\r\n", chunk_size).as_bytes()); bytes.extend(&random_bytes[..]); diff --git a/actix-multipart/Cargo.toml b/actix-multipart/Cargo.toml index 62b53eb79..c0e62d8aa 100644 --- a/actix-multipart/Cargo.toml +++ b/actix-multipart/Cargo.toml @@ -50,7 +50,7 @@ local-waker = "0.1" log = "0.4" memchr = "2.5" mime = "0.3" -rand = "0.8" +rand = "0.9" serde = "1" serde_json = "1" serde_plain = "1" diff --git a/actix-multipart/src/test.rs b/actix-multipart/src/test.rs index 7dec85f8e..b0e907266 100644 --- a/actix-multipart/src/test.rs +++ b/actix-multipart/src/test.rs @@ -5,10 +5,7 @@ use actix_web::{ web::{BufMut as _, Bytes, BytesMut}, }; use mime::Mime; -use rand::{ - distributions::{Alphanumeric, DistString as _}, - thread_rng, -}; +use rand::distr::{Alphanumeric, SampleString as _}; const CRLF: &[u8] = b"\r\n"; const CRLF_CRLF: &[u8] = b"\r\n\r\n"; @@ -64,7 +61,7 @@ pub fn create_form_data_payload_and_headers( content_type: Option, file: Bytes, ) -> (Bytes, HeaderMap) { - let boundary = Alphanumeric.sample_string(&mut thread_rng(), 32); + let boundary = Alphanumeric.sample_string(&mut rand::rng(), 32); create_form_data_payload_and_headers_with_boundary( &boundary, diff --git a/actix-web/Cargo.toml b/actix-web/Cargo.toml index f4159cf27..f7d6f56d2 100644 --- a/actix-web/Cargo.toml +++ b/actix-web/Cargo.toml @@ -180,7 +180,7 @@ criterion = { version = "0.5", features = ["html_reports"] } env_logger = "0.11" flate2 = "1.0.13" futures-util = { version = "0.3.17", default-features = false, features = ["std"] } -rand = "0.8" +rand = "0.9" rcgen = "0.13" rustls-pemfile = "2" serde = { version = "1", features = ["derive"] } diff --git a/actix-web/tests/test_server.rs b/actix-web/tests/test_server.rs index 960cf1e2b..f13aa3cfd 100644 --- a/actix-web/tests/test_server.rs +++ b/actix-web/tests/test_server.rs @@ -25,7 +25,7 @@ use openssl::{ ssl::{SslAcceptor, SslMethod}, x509::X509, }; -use rand::{distributions::Alphanumeric, Rng as _}; +use rand::distr::{Alphanumeric, SampleString as _}; mod utils; @@ -188,11 +188,7 @@ async fn body_gzip_large() { #[actix_rt::test] async fn test_body_gzip_large_random() { - let data = rand::thread_rng() - .sample_iter(&Alphanumeric) - .take(70_000) - .map(char::from) - .collect::(); + let data = Alphanumeric.sample_string(&mut rand::rng(), 70_000); let srv_data = data.clone(); let srv = actix_test::start_with(actix_test::config().h1(), move || { @@ -432,11 +428,7 @@ async fn test_zstd_encoding() { #[actix_rt::test] async fn test_zstd_encoding_large() { - let data = rand::thread_rng() - .sample_iter(&Alphanumeric) - .take(320_000) - .map(char::from) - .collect::(); + let data = Alphanumeric.sample_string(&mut rand::rng(), 320_000); let srv = actix_test::start_with(actix_test::config().h1(), || { App::new().service( @@ -529,11 +521,7 @@ async fn test_gzip_encoding_large() { #[actix_rt::test] async fn test_reading_gzip_encoding_large_random() { - let data = rand::thread_rng() - .sample_iter(&Alphanumeric) - .take(60_000) - .map(char::from) - .collect::(); + let data = Alphanumeric.sample_string(&mut rand::rng(), 60_000); let srv = actix_test::start_with(actix_test::config().h1(), || { App::new().service(web::resource("/").route(web::to(move |body: Bytes| async { @@ -599,11 +587,7 @@ async fn test_reading_deflate_encoding_large() { #[actix_rt::test] async fn test_reading_deflate_encoding_large_random() { - let data = rand::thread_rng() - .sample_iter(&Alphanumeric) - .take(160_000) - .map(char::from) - .collect::(); + let data = Alphanumeric.sample_string(&mut rand::rng(), 160_000); let srv = actix_test::start_with(actix_test::config().h1(), || { App::new().service(web::resource("/").route(web::to(move |body: Bytes| async { @@ -648,11 +632,7 @@ async fn test_brotli_encoding() { #[actix_rt::test] async fn test_brotli_encoding_large() { - let data = rand::thread_rng() - .sample_iter(&Alphanumeric) - .take(320_000) - .map(char::from) - .collect::(); + let data = Alphanumeric.sample_string(&mut rand::rng(), 320_000); let srv = actix_test::start_with(actix_test::config().h1(), || { App::new().service( @@ -737,11 +717,7 @@ mod plus_rustls { #[actix_rt::test] async fn test_reading_deflate_encoding_large_random_rustls() { - let data = rand::thread_rng() - .sample_iter(&Alphanumeric) - .take(160_000) - .map(char::from) - .collect::(); + let data = Alphanumeric.sample_string(&mut rand::rng(), 160_000); 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 { diff --git a/awc/Cargo.toml b/awc/Cargo.toml index d6626f906..e2e2bcd17 100644 --- a/awc/Cargo.toml +++ b/awc/Cargo.toml @@ -116,7 +116,7 @@ log =" 0.4" mime = "0.3" percent-encoding = "2.1" pin-project-lite = "0.2" -rand = "0.8" +rand = "0.9" serde = "1.0" serde_json = "1.0" serde_urlencoded = "0.7" diff --git a/awc/src/ws.rs b/awc/src/ws.rs index b05063d22..3ce1d286a 100644 --- a/awc/src/ws.rs +++ b/awc/src/ws.rs @@ -326,7 +326,7 @@ impl WebsocketsRequest { // Generate a random key for the `Sec-WebSocket-Key` header which is a base64-encoded // (see RFC 4648 §4) value that, when decoded, is 16 bytes in length (RFC 6455 §1.3). - let sec_key: [u8; 16] = rand::random(); + let sec_key = rand::random::<[u8; 16]>(); let key = BASE64_STANDARD.encode(sec_key); self.head.headers.insert( diff --git a/awc/tests/test_client.rs b/awc/tests/test_client.rs index 76915630f..43c83891a 100644 --- a/awc/tests/test_client.rs +++ b/awc/tests/test_client.rs @@ -20,7 +20,7 @@ use base64::prelude::*; use bytes::Bytes; use cookie::Cookie; use futures_util::stream; -use rand::Rng; +use rand::distr::{Alphanumeric, SampleString as _}; mod utils; @@ -516,11 +516,7 @@ async fn client_gzip_encoding_large() { #[cfg(feature = "compress-gzip")] #[actix_rt::test] async fn client_gzip_encoding_large_random() { - let data = rand::thread_rng() - .sample_iter(&rand::distributions::Alphanumeric) - .take(100_000) - .map(char::from) - .collect::(); + let data = Alphanumeric.sample_string(&mut rand::rng(), 100_000); let srv = actix_test::start(|| { App::new().service(web::resource("/").route(web::to(|data: Bytes| async { @@ -562,11 +558,7 @@ async fn client_brotli_encoding() { #[cfg(feature = "compress-brotli")] #[actix_rt::test] async fn client_brotli_encoding_large_random() { - let data = rand::thread_rng() - .sample_iter(&rand::distributions::Alphanumeric) - .take(70_000) - .map(char::from) - .collect::(); + let data = Alphanumeric.sample_string(&mut rand::rng(), 70_000); let srv = actix_test::start(|| { App::new().service(web::resource("/").route(web::to(|data: Bytes| async { @@ -607,11 +599,7 @@ async fn client_deflate_encoding() { #[actix_rt::test] async fn client_deflate_encoding_large_random() { - let data = rand::thread_rng() - .sample_iter(rand::distributions::Alphanumeric) - .map(char::from) - .take(70_000) - .collect::(); + let data = Alphanumeric.sample_string(&mut rand::rng(), 70_000); let srv = actix_test::start(|| { App::new().default_service(web::to(|body: Bytes| async { From a4eaa7f0bb963ec6bc67aaadafdda2d638f9ba41 Mon Sep 17 00:00:00 2001 From: Akos Vandra-Meyer Date: Sun, 9 Feb 2025 04:01:39 +0100 Subject: [PATCH 7/7] implement Responder for Result<(), E: Error> (#3560) * implement Responder for Option<()> and Result<(), E: Error> * chore: remove Option<()> impl * chore: fix changelog --------- Co-authored-by: Rob Ede --- actix-web/CHANGES.md | 1 + actix-web/src/response/responder.rs | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/actix-web/CHANGES.md b/actix-web/CHANGES.md index cee14dc4b..edbdc6982 100644 --- a/actix-web/CHANGES.md +++ b/actix-web/CHANGES.md @@ -2,6 +2,7 @@ ## Unreleased +- Implement `Responder` for `Result<(), E: Into>`. Returning `Ok(())` responds with HTTP 204 No Content. - On Windows, an error is now returned from `HttpServer::bind()` (or TLS variants) when binding to a socket that's already in use. - Update `brotli` dependency to `7`. - Minimum supported Rust version (MSRV) is now 1.75. diff --git a/actix-web/src/response/responder.rs b/actix-web/src/response/responder.rs index 90d8f6e52..82bc38d6b 100644 --- a/actix-web/src/response/responder.rs +++ b/actix-web/src/response/responder.rs @@ -131,6 +131,23 @@ where } } +// Note: see https://github.com/actix/actix-web/issues/1108 for reasoning why Responder is not +// implemented for `()`, and https://github.com/actix/actix-web/pull/3560 for discussion about this +// impl and the decision not to include a similar one for `Option<()>`. +impl Responder for Result<(), E> +where + E: Into, +{ + type Body = BoxBody; + + fn respond_to(self, _req: &HttpRequest) -> HttpResponse { + match self { + Ok(()) => HttpResponse::new(StatusCode::NO_CONTENT), + Err(err) => HttpResponse::from_error(err.into()), + } + } +} + impl Responder for (R, StatusCode) { type Body = R::Body;