Skip to content

Commit

Permalink
Merge branch 'master' into fix-idna-vuln
Browse files Browse the repository at this point in the history
  • Loading branch information
robjtede authored Dec 29, 2024
2 parents 654fdd3 + ac2a3bb commit 2e6a643
Show file tree
Hide file tree
Showing 24 changed files with 70 additions and 78 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci-post-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -83,7 +83,7 @@ jobs:
uses: actions-rust-lang/[email protected]

- 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

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ 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

- name: Generate code coverage
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
Expand Down
29 changes: 1 addition & 28 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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/[email protected]
with:
toolchain: ${{ vars.RUST_VERSION_API_DIFF }}

- name: Install cargo-public-api
uses: taiki-e/[email protected]
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
2 changes: 1 addition & 1 deletion actix-http/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,12 @@ actix-codec = "0.5"
actix-utils = "3"
actix-rt = { version = "2.2", default-features = false }

ahash = "0.8"
bitflags = "2"
bytes = "1"
bytestring = "1"
derive_more = { version = "1", features = ["as_ref", "deref", "deref_mut", "display", "error", "from"] }
encoding_rs = "0.8"
foldhash = "0.1"
futures-core = { version = "0.3.17", default-features = false, features = ["alloc"] }
http = "0.2.7"
httparse = "1.5.1"
Expand Down
2 changes: 1 addition & 1 deletion actix-http/src/extensions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ impl Hasher for NoOpHasher {
/// All entries into this map must be owned types (or static references).
#[derive(Default)]
pub struct Extensions {
/// Use AHasher with a std HashMap with for faster lookups on the small `TypeId` keys.
// use no-op hasher with a std HashMap with for faster lookups on the small `TypeId` keys
map: HashMap<TypeId, Box<dyn Any>, BuildHasherDefault<NoOpHasher>>,
}

Expand Down
8 changes: 4 additions & 4 deletions actix-http/src/header/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use std::{borrow::Cow, collections::hash_map, iter, ops};

use ahash::AHashMap;
use foldhash::{HashMap as FoldHashMap, HashMapExt as _};
use http::header::{HeaderName, HeaderValue};
use smallvec::{smallvec, SmallVec};

Expand Down Expand Up @@ -47,7 +47,7 @@ use super::AsHeaderName;
/// ```
#[derive(Debug, Clone, Default)]
pub struct HeaderMap {
pub(crate) inner: AHashMap<HeaderName, Value>,
pub(crate) inner: FoldHashMap<HeaderName, Value>,
}

/// A bespoke non-empty list for HeaderMap values.
Expand Down Expand Up @@ -116,7 +116,7 @@ impl HeaderMap {
/// ```
pub fn with_capacity(capacity: usize) -> Self {
HeaderMap {
inner: AHashMap::with_capacity(capacity),
inner: FoldHashMap::with_capacity(capacity),
}
}

Expand Down Expand Up @@ -830,7 +830,7 @@ impl<'a> Drain<'a> {
}
}

impl<'a> Iterator for Drain<'a> {
impl Iterator for Drain<'_> {
type Item = (Option<HeaderName>, HeaderValue);

fn next(&mut self) -> Option<Self::Item> {
Expand Down
2 changes: 1 addition & 1 deletion actix-http/src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ pub fn write_content_length<B: BufMut>(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<B> io::Write for MutWriter<'_, B>
where
B: BufMut,
{
Expand Down
2 changes: 1 addition & 1 deletion actix-http/src/http_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ pub trait HttpMessage: Sized {
}
}

impl<'a, T> HttpMessage for &'a mut T
impl<T> HttpMessage for &mut T
where
T: HttpMessage,
{
Expand Down
2 changes: 1 addition & 1 deletion actix-router/src/resource_path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ impl ResourcePath for String {
}
}

impl<'a> ResourcePath for &'a str {
impl ResourcePath for &str {
fn path(&self) -> &str {
self
}
Expand Down
2 changes: 1 addition & 1 deletion actix-web-codegen/tests/routes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion actix-web/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,13 @@ actix-http = { version = "3.7", features = ["ws"] }
actix-router = { version = "0.5.3", default-features = false, features = ["http"] }
actix-web-codegen = { version = "4.3", optional = true, default-features = false }

ahash = "0.8"
bytes = "1"
bytestring = "1"
cfg-if = "1"
cookie = { version = "0.16", features = ["percent-encode"], optional = true }
derive_more = { version = "1", features = ["display", "error", "from"] }
encoding_rs = "0.8"
foldhash = "0.1"
futures-core = { version = "0.3.17", default-features = false }
futures-util = { version = "0.3.17", default-features = false }
itoa = "1"
Expand Down
2 changes: 1 addition & 1 deletion actix-web/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
<br />
[![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)

Expand Down
2 changes: 1 addition & 1 deletion actix-web/src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<B> io::Write for MutWriter<'_, B>
where
B: BufMut,
{
Expand Down
4 changes: 2 additions & 2 deletions actix-web/src/middleware/err_handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use std::{
};

use actix_service::{Service, Transform};
use ahash::AHashMap;
use foldhash::HashMap as FoldHashMap;
use futures_core::{future::LocalBoxFuture, ready};
use pin_project_lite::pin_project;

Expand Down Expand Up @@ -185,7 +185,7 @@ pub struct ErrorHandlers<B> {
handlers: Handlers<B>,
}

type Handlers<B> = Rc<AHashMap<StatusCode, Box<ErrorHandler<B>>>>;
type Handlers<B> = Rc<FoldHashMap<StatusCode, Box<ErrorHandler<B>>>>;

impl<B> Default for ErrorHandlers<B> {
fn default() -> Self {
Expand Down
2 changes: 1 addition & 1 deletion actix-web/src/middleware/logger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
6 changes: 3 additions & 3 deletions actix-web/src/resource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
/// ```
Expand Down
8 changes: 4 additions & 4 deletions actix-web/src/rmap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::{
};

use actix_router::ResourceDef;
use ahash::AHashMap;
use foldhash::HashMap as FoldHashMap;
use url::Url;

use crate::{error::UrlGenerationError, request::HttpRequest};
Expand All @@ -19,7 +19,7 @@ pub struct ResourceMap {

/// Named resources within the tree or, for external resources, it points to isolated nodes
/// outside the tree.
named: AHashMap<String, Rc<ResourceMap>>,
named: FoldHashMap<String, Rc<ResourceMap>>,

parent: RefCell<Weak<ResourceMap>>,

Expand All @@ -32,7 +32,7 @@ impl ResourceMap {
pub fn new(root: ResourceDef) -> Self {
ResourceMap {
pattern: root,
named: AHashMap::default(),
named: FoldHashMap::default(),
parent: RefCell::new(Weak::new()),
nodes: Some(Vec::new()),
}
Expand Down Expand Up @@ -86,7 +86,7 @@ impl ResourceMap {
} else {
let new_node = Rc::new(ResourceMap {
pattern: pattern.clone(),
named: AHashMap::default(),
named: FoldHashMap::default(),
parent: RefCell::new(Weak::new()),
nodes: None,
});
Expand Down
2 changes: 1 addition & 1 deletion actix-web/src/types/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ impl<T: DeserializeOwned> JsonBody<T> {
(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
Expand Down
6 changes: 3 additions & 3 deletions awc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
30 changes: 22 additions & 8 deletions awc/examples/client.rs
Original file line number Diff line number Diff line change
@@ -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<dyn StdError>> {
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?;
Expand Down
Loading

0 comments on commit 2e6a643

Please sign in to comment.