From c3e38d45b83848a925bd97f4cda1dcc3005dc1d5 Mon Sep 17 00:00:00 2001 From: geoffsee <> Date: Thu, 28 Aug 2025 15:09:53 -0400 Subject: [PATCH] - Downgrade `edition` from 2024 to 2021 in Cargo.toml files for compatibility. - Fix nested `if let` statements to improve readability and correctness. - Reorganize imports for consistency and structure. --- crates/example/Cargo.toml | 2 +- crates/example/src/main.rs | 4 ++-- crates/hyper-custom-cert/Cargo.toml | 2 +- crates/hyper-custom-cert/src/lib.rs | 30 ++++++++++++++--------------- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/crates/example/Cargo.toml b/crates/example/Cargo.toml index 47f1da8..9590b49 100644 --- a/crates/example/Cargo.toml +++ b/crates/example/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "example" version = "0.1.0" -edition = "2024" +edition = "2021" [features] # No-op features used only by the example to allow conditional compilation in docs/examples. diff --git a/crates/example/src/main.rs b/crates/example/src/main.rs index 086b604..1fb9d1f 100644 --- a/crates/example/src/main.rs +++ b/crates/example/src/main.rs @@ -1,12 +1,12 @@ use axum::{ - Router, extract::{Path, Query}, response::Json, routing::{delete, get, post, put}, + Router, }; use hyper_custom_cert::HttpClient; use serde::{Deserialize, Serialize}; -use serde_json::{Value, json}; +use serde_json::{json, Value}; use std::collections::HashMap; use std::time::Duration; diff --git a/crates/hyper-custom-cert/Cargo.toml b/crates/hyper-custom-cert/Cargo.toml index 058ba46..c3eea7f 100644 --- a/crates/hyper-custom-cert/Cargo.toml +++ b/crates/hyper-custom-cert/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "hyper-custom-cert" version = "0.3.6" -edition = "2024" +edition = "2021" description = "A small, ergonomic HTTP client wrapper around hyper with optional support for custom Root CAs and a dev-only insecure mode for self-signed certificates." license = "MIT OR Apache-2.0" repository = "https://github.com/seemueller-io/hyper-custom-cert" diff --git a/crates/hyper-custom-cert/src/lib.rs b/crates/hyper-custom-cert/src/lib.rs index f57a04f..5686559 100644 --- a/crates/hyper-custom-cert/src/lib.rs +++ b/crates/hyper-custom-cert/src/lib.rs @@ -37,7 +37,7 @@ use std::time::Duration; use bytes::Bytes; use http_body_util::BodyExt; -use hyper::{Method, Request, Response, StatusCode, Uri, body::Incoming}; +use hyper::{body::Incoming, Method, Request, Response, StatusCode, Uri}; use hyper_util::client::legacy::Client; use hyper_util::rt::TokioExecutor; @@ -367,11 +367,11 @@ impl HttpClient { } // Add any request-specific headers from options - if let Some(options) = &options - && let Some(headers) = &options.headers - { - for (key, value) in headers { - req = req.header(key, value); + if let Some(options) = &options { + if let Some(headers) = &options.headers { + for (key, value) in headers { + req = req.header(key, value); + } } } @@ -503,11 +503,11 @@ impl HttpClient { } // Add any request-specific headers from options - if let Some(options) = &options - && let Some(headers) = &options.headers - { - for (key, value) in headers { - req = req.header(key, value); + if let Some(options) = &options { + if let Some(headers) = &options.headers { + for (key, value) in headers { + req = req.header(key, value); + } } } @@ -654,10 +654,10 @@ impl HttpClient { // and NEVER in production environments. This creates a vulnerability to // man-in-the-middle attacks and is extremely dangerous. - use rustls::DigitallySignedStruct; - use rustls::SignatureScheme; use rustls::client::danger::{HandshakeSignatureValid, ServerCertVerified}; use rustls::pki_types::UnixTime; + use rustls::DigitallySignedStruct; + use rustls::SignatureScheme; use std::sync::Arc; // Override the certificate verifier with a no-op verifier that accepts all certificates @@ -731,12 +731,12 @@ impl HttpClient { #[cfg(feature = "rustls")] let rustls_config = if let Some(ref pins) = self.pinned_cert_sha256 { // Implement certificate pinning by creating a custom certificate verifier - use rustls::DigitallySignedStruct; - use rustls::SignatureScheme; use rustls::client::danger::{ HandshakeSignatureValid, ServerCertVerified, ServerCertVerifier, }; use rustls::pki_types::{CertificateDer, ServerName, UnixTime}; + use rustls::DigitallySignedStruct; + use rustls::SignatureScheme; use std::sync::Arc; // Create a custom certificate verifier that checks certificate pins