diff --git a/.github/workflows/ci-post-merge.yml b/.github/workflows/ci-post-merge.yml index 059c22824..32a126ae7 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.45.6 + uses: taiki-e/install-action@v2.46.20 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.45.6 + uses: taiki-e/install-action@v2.46.20 with: tool: just,cargo-hack diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8ee35f636..89cc9bb73 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.45.6 + uses: taiki-e/install-action@v2.46.20 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.45.6 + uses: taiki-e/install-action@v2.46.20 with: tool: just diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 97437cc8e..b8efdb938 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.45.6 + uses: taiki-e/install-action@v2.46.20 with: tool: just,cargo-llvm-cov,cargo-nextest @@ -32,7 +32,7 @@ jobs: run: just test-coverage-codecov - name: Upload coverage to Codecov - uses: codecov/codecov-action@v5.0.7 + uses: codecov/codecov-action@v5.1.2 with: files: codecov.json fail_ci_if_error: true diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index ef3f30b1c..e77723d58 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.45.6 + uses: taiki-e/install-action@v2.46.20 with: tool: just @@ -88,30 +88,3 @@ jobs: - name: check external types run: just check-external-types-all +${{ vars.RUST_VERSION_EXTERNAL_TYPES }} - - public-api-diff: - runs-on: ubuntu-latest - steps: - - name: Checkout main branch - uses: actions/checkout@v4 - with: - ref: ${{ github.base_ref }} - - - name: Checkout PR branch - uses: actions/checkout@v4 - - - name: Install Rust (${{ vars.RUST_VERSION_API_DIFF }}) - uses: actions-rust-lang/setup-rust-toolchain@v1.10.1 - with: - toolchain: ${{ vars.RUST_VERSION_API_DIFF }} - - - name: Install cargo-public-api - uses: taiki-e/install-action@v2.45.6 - with: - tool: cargo-public-api - - - name: Generate API diff - run: | - for f in $(find -mindepth 2 -maxdepth 2 -name Cargo.toml); do - cargo public-api --manifest-path "$f" --simplified diff ${{ github.event.pull_request.base.sha }}..${{ github.sha }} - done diff --git a/actix-http/src/header/map.rs b/actix-http/src/header/map.rs index 6da01d2c0..7be282b11 100644 --- a/actix-http/src/header/map.rs +++ b/actix-http/src/header/map.rs @@ -830,7 +830,7 @@ impl<'a> Drain<'a> { } } -impl<'a> Iterator for Drain<'a> { +impl Iterator for Drain<'_> { type Item = (Option, HeaderValue); fn next(&mut self) -> Option { diff --git a/actix-http/src/helpers.rs b/actix-http/src/helpers.rs index 7f28018e7..61175bdc9 100644 --- a/actix-http/src/helpers.rs +++ b/actix-http/src/helpers.rs @@ -61,7 +61,7 @@ pub fn write_content_length(n: u64, buf: &mut B, camel_case: bool) { /// perform a remaining length check before writing. pub(crate) struct MutWriter<'a, B>(pub(crate) &'a mut B); -impl<'a, B> io::Write for MutWriter<'a, B> +impl io::Write for MutWriter<'_, B> where B: BufMut, { diff --git a/actix-http/src/http_message.rs b/actix-http/src/http_message.rs index 3ba9ef752..2800f40ba 100644 --- a/actix-http/src/http_message.rs +++ b/actix-http/src/http_message.rs @@ -103,7 +103,7 @@ pub trait HttpMessage: Sized { } } -impl<'a, T> HttpMessage for &'a mut T +impl HttpMessage for &mut T where T: HttpMessage, { diff --git a/actix-router/src/resource_path.rs b/actix-router/src/resource_path.rs index 45948aa2a..610dc344d 100644 --- a/actix-router/src/resource_path.rs +++ b/actix-router/src/resource_path.rs @@ -19,7 +19,7 @@ impl ResourcePath for String { } } -impl<'a> ResourcePath for &'a str { +impl ResourcePath for &str { fn path(&self) -> &str { self } diff --git a/actix-web-codegen/tests/routes.rs b/actix-web-codegen/tests/routes.rs index a6e606871..1443f9a75 100644 --- a/actix-web-codegen/tests/routes.rs +++ b/actix-web-codegen/tests/routes.rs @@ -136,7 +136,7 @@ async fn routes_overlapping_inaccessible_test(req: HttpRequest) -> impl Responde } #[get("/custom_resource_name", name = "custom")] -async fn custom_resource_name_test<'a>(req: HttpRequest) -> impl Responder { +async fn custom_resource_name_test(req: HttpRequest) -> impl Responder { assert!(req.url_for_static("custom").is_ok()); assert!(req.url_for_static("custom_resource_name_test").is_err()); HttpResponse::Ok() diff --git a/actix-web/README.md b/actix-web/README.md index e5e412c85..70f167dfd 100644 --- a/actix-web/README.md +++ b/actix-web/README.md @@ -14,7 +14,7 @@ [![Dependency Status](https://deps.rs/crate/actix-web/4.9.0/status.svg)](https://deps.rs/crate/actix-web/4.9.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) +[![codecov](https://codecov.io/gh/actix/actix-web/graph/badge.svg?token=dSwOnp9QCv)](https://codecov.io/gh/actix/actix-web) ![downloads](https://img.shields.io/crates/d/actix-web.svg) [![Chat on Discord](https://img.shields.io/discord/771444961383153695?label=chat&logo=discord)](https://discord.gg/NWpN5mmg3x) diff --git a/actix-web/src/helpers.rs b/actix-web/src/helpers.rs index 1d2679fce..c7b33a083 100644 --- a/actix-web/src/helpers.rs +++ b/actix-web/src/helpers.rs @@ -10,7 +10,7 @@ use bytes::BufMut; /// perform a remaining length check before writing. pub(crate) struct MutWriter<'a, B>(pub(crate) &'a mut B); -impl<'a, B> io::Write for MutWriter<'a, B> +impl io::Write for MutWriter<'_, B> where B: BufMut, { diff --git a/actix-web/src/middleware/logger.rs b/actix-web/src/middleware/logger.rs index 21986baae..125925603 100644 --- a/actix-web/src/middleware/logger.rs +++ b/actix-web/src/middleware/logger.rs @@ -704,7 +704,7 @@ impl FormatText { /// Converter to get a String from something that writes to a Formatter. pub(crate) struct FormatDisplay<'a>(&'a dyn Fn(&mut fmt::Formatter<'_>) -> Result<(), fmt::Error>); -impl<'a> fmt::Display for FormatDisplay<'a> { +impl fmt::Display for FormatDisplay<'_> { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> { (self.0)(fmt) } diff --git a/actix-web/src/resource.rs b/actix-web/src/resource.rs index 6486fb39d..aee0dff93 100644 --- a/actix-web/src/resource.rs +++ b/actix-web/src/resource.rs @@ -28,9 +28,9 @@ use crate::{ /// /// Resource in turn has at least one route. Route consists of an handlers objects and list of /// guards (objects that implement `Guard` trait). Resources and routes uses builder-like pattern -/// for configuration. During request handling, resource object iterate through all routes and check -/// guards for specific route, if request matches all guards, route considered matched and route -/// handler get called. +/// for configuration. During request handling, the resource object iterates through all routes +/// and checks guards for the specific route, if the request matches all the guards, then the route +/// is considered matched and the route handler gets called. /// /// # Examples /// ``` diff --git a/actix-web/src/types/json.rs b/actix-web/src/types/json.rs index 51a322e43..22ed624c3 100644 --- a/actix-web/src/types/json.rs +++ b/actix-web/src/types/json.rs @@ -332,7 +332,7 @@ impl JsonBody { (true, Ok(Some(mime))) => { mime.subtype() == mime::JSON || mime.suffix() == Some(mime::JSON) - || ctype_fn.map_or(false, |predicate| predicate(mime)) + || ctype_fn.is_some_and(|predicate| predicate(mime)) } // if content-type is expected but not parsable as mime type, bail diff --git a/awc/Cargo.toml b/awc/Cargo.toml index c09f32ac8..d6626f906 100644 --- a/awc/Cargo.toml +++ b/awc/Cargo.toml @@ -153,9 +153,9 @@ 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 -[lints] -workspace = true - [[example]] name = "client" required-features = ["rustls-0_23-webpki-roots"] + +[lints] +workspace = true diff --git a/awc/examples/client.rs b/awc/examples/client.rs index 41626315c..b6eb919c7 100644 --- a/awc/examples/client.rs +++ b/awc/examples/client.rs @@ -1,25 +1,39 @@ -use std::error::Error as StdError; +//! Demonstrates construction and usage of a TLS-capable HTTP client. + +extern crate tls_rustls_0_23 as rustls; + +use std::{error::Error as StdError, sync::Arc}; + +use actix_tls::connect::rustls_0_23::webpki_roots_cert_store; +use rustls::ClientConfig; -/// If we want to make requests to addresses starting with `https`, we need to enable the rustls feature of awc -/// `awc = { version = "3.5.0", features = ["rustls"] }` #[actix_rt::main] async fn main() -> Result<(), Box> { env_logger::init_from_env(env_logger::Env::new().default_filter_or("info")); - // construct request builder - let client = awc::Client::new(); + let mut config = ClientConfig::builder() + .with_root_certificates(webpki_roots_cert_store()) + .with_no_client_auth(); + + let protos = vec![b"h2".to_vec(), b"http/1.1".to_vec()]; + config.alpn_protocols = protos; + + // construct request builder with TLS support + let client = awc::Client::builder() + .connector(awc::Connector::new().rustls_0_23(Arc::new(config))) + .finish(); // configure request let request = client .get("https://www.rust-lang.org/") - .append_header(("User-Agent", "Actix-web")); + .append_header(("User-Agent", "awc/3.0")); - println!("Request: {:?}", request); + println!("Request: {request:?}"); let mut response = request.send().await?; // server response head - println!("Response: {:?}", response); + println!("Response: {response:?}"); // read response body let body = response.body().await?; diff --git a/awc/src/client/connector.rs b/awc/src/client/connector.rs index 2e3f977fa..b966e935c 100644 --- a/awc/src/client/connector.rs +++ b/awc/src/client/connector.rs @@ -548,7 +548,8 @@ where let h2 = sock .ssl() .selected_alpn_protocol() - .map_or(false, |protos| protos.windows(2).any(|w| w == H2)); + .is_some_and(|protos| protos.windows(2).any(|w| w == H2)); + if h2 { (Box::new(sock), Protocol::Http2) } else { @@ -587,7 +588,8 @@ where .get_ref() .1 .alpn_protocol() - .map_or(false, |protos| protos.windows(2).any(|w| w == H2)); + .is_some_and(|protos| protos.windows(2).any(|w| w == H2)); + if h2 { (Box::new(sock), Protocol::Http2) } else { @@ -621,7 +623,8 @@ where .get_ref() .1 .alpn_protocol() - .map_or(false, |protos| protos.windows(2).any(|w| w == H2)); + .is_some_and(|protos| protos.windows(2).any(|w| w == H2)); + if h2 { (Box::new(sock), Protocol::Http2) } else { @@ -658,7 +661,8 @@ where .get_ref() .1 .alpn_protocol() - .map_or(false, |protos| protos.windows(2).any(|w| w == H2)); + .is_some_and(|protos| protos.windows(2).any(|w| w == H2)); + if h2 { (Box::new(sock), Protocol::Http2) } else { @@ -692,7 +696,8 @@ where .get_ref() .1 .alpn_protocol() - .map_or(false, |protos| protos.windows(2).any(|w| w == H2)); + .is_some_and(|protos| protos.windows(2).any(|w| w == H2)); + if h2 { (Box::new(sock), Protocol::Http2) } else { diff --git a/awc/src/ws.rs b/awc/src/ws.rs index ef5cb7155..e060177a3 100644 --- a/awc/src/ws.rs +++ b/awc/src/ws.rs @@ -452,7 +452,7 @@ struct Host<'a> { port: Option>, } -impl<'a> fmt::Display for Host<'a> { +impl fmt::Display for Host<'_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str(self.hostname)?; diff --git a/justfile b/justfile index 0a69a1e89..3a5e417fd 100644 --- a/justfile +++ b/justfile @@ -51,8 +51,8 @@ test-msrv: downgrade-for-msrv (test msrv_rustup) 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)" + cargo {{ toolchain }} nextest run --no-tests=warn -p=actix-router --no-default-features + cargo {{ toolchain }} nextest run --no-tests=warn --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 @@ -64,7 +64,7 @@ test-all toolchain="": (test toolchain) (test-docs toolchain) # Test workspace and collect coverage info. [private] test-coverage toolchain="": - cargo {{ toolchain }} llvm-cov nextest --no-report {{ all_crate_features }} + cargo {{ toolchain }} llvm-cov nextest --no-tests=warn --no-report {{ all_crate_features }} cargo {{ toolchain }} llvm-cov --doc --no-report {{ all_crate_features }} # Test workspace and generate Codecov report.