From 35d64b84615eeff9d57ae070fba7c69e1112cbca Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Wed, 22 Oct 2025 18:31:01 +0200 Subject: [PATCH 1/2] fix!: prefer curl over reqwest connections if both are enabled --- .../src/client/blocking_io/connect.rs | 18 +++++++++++++----- .../src/client/blocking_io/http/mod.rs | 16 +++------------- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/gix-transport/src/client/blocking_io/connect.rs b/gix-transport/src/client/blocking_io/connect.rs index c982805568e..8dfcabefe81 100644 --- a/gix-transport/src/client/blocking_io/connect.rs +++ b/gix-transport/src/client/blocking_io/connect.rs @@ -1,6 +1,10 @@ pub use crate::client::non_io_types::connect::{Error, Options}; pub(crate) mod function { + #[cfg(feature = "http-client-curl")] + use crate::client::blocking_io::http::curl::Curl; + #[cfg(feature = "http-client-reqwest")] + use crate::client::blocking_io::http::reqwest::Remote; use crate::client::{blocking_io::Transport, non_io_types::connect::Error}; /// A general purpose connector connecting to a repository identified by the given `url`. @@ -57,11 +61,15 @@ pub(crate) mod function { } #[cfg(not(any(feature = "http-client-curl", feature = "http-client-reqwest")))] gix_url::Scheme::Https | gix_url::Scheme::Http => return Err(Error::CompiledWithoutHttp(url.scheme)), - #[cfg(any(feature = "http-client-curl", feature = "http-client-reqwest"))] - gix_url::Scheme::Https | gix_url::Scheme::Http => Box::new(crate::client::blocking_io::http::connect( - url, - options.version, - options.trace, + #[cfg(feature = "http-client-curl")] + gix_url::Scheme::Https | gix_url::Scheme::Http => Box::new( + crate::client::blocking_io::http::connect::(url, options.version, options.trace), + ), + #[cfg(all(feature = "http-client-reqwest", not(feature = "http-client-curl")))] + gix_url::Scheme::Https | gix_url::Scheme::Http => Box::new(crate::client::blocking_io::http::connect::< + Remote, + >( + url, options.version, options.trace )), }) } diff --git a/gix-transport/src/client/blocking_io/http/mod.rs b/gix-transport/src/client/blocking_io/http/mod.rs index 154aa89fd4a..8b6b90e57d9 100644 --- a/gix-transport/src/client/blocking_io/http/mod.rs +++ b/gix-transport/src/client/blocking_io/http/mod.rs @@ -25,9 +25,6 @@ use crate::{ Protocol, Service, }; -#[cfg(all(feature = "http-client-reqwest", feature = "http-client-curl"))] -compile_error!("Cannot set both 'http-client-reqwest' and 'http-client-curl' features as they are mutually exclusive"); - #[cfg(feature = "http-client-curl")] /// pub mod curl; @@ -215,13 +212,6 @@ impl Default for Options { } } -/// The actual http client implementation, using curl -#[cfg(feature = "http-client-curl")] -pub type Impl = curl::Curl; -/// The actual http client implementation, using reqwest -#[cfg(feature = "http-client-reqwest")] -pub type Impl = reqwest::Remote; - /// A transport for supporting arbitrary http clients by abstracting interactions with them into the [Http] trait. pub struct Transport { url: String, @@ -270,13 +260,13 @@ impl Transport { } #[cfg(any(feature = "http-client-curl", feature = "http-client-reqwest"))] -impl Transport { +impl Transport { /// Create a new instance to communicate to `url` using the given `desired_version` of the `git` protocol. /// If `trace` is `true`, all packetlines received or sent will be passed to the facilities of the `gix-trace` crate. /// /// Note that the actual implementation depends on feature toggles. pub fn new(url: gix_url::Url, desired_version: Protocol, trace: bool) -> Self { - Self::new_http(Impl::default(), url, desired_version, trace) + Self::new_http(H::default(), url, desired_version, trace) } } @@ -555,7 +545,7 @@ pub fn connect_http(http: H, url: gix_url::Url, desired_version: Protoc /// Connect to the given `url` via HTTP/S using the `desired_version` of the `git` protocol. /// If `trace` is `true`, all packetlines received or sent will be passed to the facilities of the `gix-trace` crate. #[cfg(any(feature = "http-client-curl", feature = "http-client-reqwest"))] -pub fn connect(url: gix_url::Url, desired_version: Protocol, trace: bool) -> Transport { +pub fn connect(url: gix_url::Url, desired_version: Protocol, trace: bool) -> Transport { Transport::new(url, desired_version, trace) } From 7ce415e0f9ee11e02d05b75dfb347dc3bc85ad59 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Sun, 26 Oct 2025 04:50:41 +0100 Subject: [PATCH 2/2] refactor * Provide a clearer name to the request connection. --- gix-transport/src/client/blocking_io/connect.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gix-transport/src/client/blocking_io/connect.rs b/gix-transport/src/client/blocking_io/connect.rs index 8dfcabefe81..ba9519d4b27 100644 --- a/gix-transport/src/client/blocking_io/connect.rs +++ b/gix-transport/src/client/blocking_io/connect.rs @@ -4,7 +4,7 @@ pub(crate) mod function { #[cfg(feature = "http-client-curl")] use crate::client::blocking_io::http::curl::Curl; #[cfg(feature = "http-client-reqwest")] - use crate::client::blocking_io::http::reqwest::Remote; + use crate::client::blocking_io::http::reqwest::Remote as Reqwest; use crate::client::{blocking_io::Transport, non_io_types::connect::Error}; /// A general purpose connector connecting to a repository identified by the given `url`. @@ -67,7 +67,7 @@ pub(crate) mod function { ), #[cfg(all(feature = "http-client-reqwest", not(feature = "http-client-curl")))] gix_url::Scheme::Https | gix_url::Scheme::Http => Box::new(crate::client::blocking_io::http::connect::< - Remote, + Reqwest, >( url, options.version, options.trace )),