@@ -217,26 +217,40 @@ pub struct Transport<H: Http> {
217217impl < H : Http > Transport < H > {
218218 /// Create a new instance with `http` as implementation to communicate to `url` using the given `desired_version`.
219219 /// Note that we will always fallback to other versions as supported by the server.
220- pub fn new_http ( http : H , url : & str , desired_version : Protocol ) -> Self {
220+ pub fn new_http ( http : H , url : gix_url:: Url , desired_version : Protocol ) -> Self {
221+ let identity = url
222+ . user ( )
223+ . zip ( url. password ( ) )
224+ . map ( |( user, pass) | gix_sec:: identity:: Account {
225+ username : user. to_string ( ) ,
226+ password : pass. to_string ( ) ,
227+ } ) ;
221228 Transport {
222- url : url. to_owned ( ) ,
229+ url : url. to_bstring ( ) . to_string ( ) ,
223230 user_agent_header : concat ! ( "User-Agent: git/oxide-" , env!( "CARGO_PKG_VERSION" ) ) ,
224231 desired_version,
225232 actual_version : Default :: default ( ) ,
226233 service : None ,
227234 http,
228235 line_provider : None ,
229- identity : None ,
236+ identity,
230237 }
231238 }
232239}
233240
241+ impl < H : Http > Transport < H > {
242+ /// Returns the identity that the transport uses when connecting to the remote.
243+ pub fn identity ( & self ) -> Option < & gix_sec:: identity:: Account > {
244+ self . identity . as_ref ( )
245+ }
246+ }
247+
234248#[ cfg( any( feature = "http-client-curl" , feature = "http-client-reqwest" ) ) ]
235249impl Transport < Impl > {
236250 /// Create a new instance to communicate to `url` using the given `desired_version` of the `git` protocol.
237251 ///
238252 /// Note that the actual implementation depends on feature toggles.
239- pub fn new ( url : & str , desired_version : Protocol ) -> Self {
253+ pub fn new ( url : gix_url :: Url , desired_version : Protocol ) -> Self {
240254 Self :: new_http ( Impl :: default ( ) , url, desired_version)
241255 }
242256}
@@ -497,13 +511,13 @@ impl<H: Http, B: ExtendedBufRead + Unpin> ExtendedBufRead for HeadersThenBody<H,
497511
498512/// Connect to the given `url` via HTTP/S using the `desired_version` of the `git` protocol, with `http` as implementation.
499513#[ cfg( all( feature = "http-client" , not( feature = "http-client-curl" ) ) ) ]
500- pub fn connect_http < H : Http > ( http : H , url : & str , desired_version : Protocol ) -> Transport < H > {
514+ pub fn connect_http < H : Http > ( http : H , url : gix_url :: Url , desired_version : Protocol ) -> Transport < H > {
501515 Transport :: new_http ( http, url, desired_version)
502516}
503517
504518/// Connect to the given `url` via HTTP/S using the `desired_version` of the `git` protocol.
505519#[ cfg( any( feature = "http-client-curl" , feature = "http-client-reqwest" ) ) ]
506- pub fn connect ( url : & str , desired_version : Protocol ) -> Transport < Impl > {
520+ pub fn connect ( url : gix_url :: Url , desired_version : Protocol ) -> Transport < Impl > {
507521 Transport :: new ( url, desired_version)
508522}
509523
0 commit comments