@@ -17,7 +17,7 @@ use tokio::net::TcpStream;
17
17
use tokio:: time:: Delay ;
18
18
19
19
use super :: dns:: { self , resolve, GaiResolver , Resolve } ;
20
- use super :: { Connected , Destination } ;
20
+ use super :: { Connected } ;
21
21
//#[cfg(feature = "runtime")] use super::dns::TokioThreadpoolGaiResolver;
22
22
23
23
@@ -229,7 +229,7 @@ impl<R: fmt::Debug> fmt::Debug for HttpConnector<R> {
229
229
}
230
230
}
231
231
232
- impl < R > tower_service:: Service < Destination > for HttpConnector < R >
232
+ impl < R > tower_service:: Service < Uri > for HttpConnector < R >
233
233
where
234
234
R : Resolve + Clone + Send + Sync + ' static ,
235
235
R :: Future : Send ,
@@ -243,7 +243,7 @@ where
243
243
Poll :: Ready ( Ok ( ( ) ) )
244
244
}
245
245
246
- fn call ( & mut self , dst : Destination ) -> Self :: Future {
246
+ fn call ( & mut self , dst : Uri ) -> Self :: Future {
247
247
let mut self_ = self . clone ( ) ;
248
248
HttpConnecting {
249
249
fut : Box :: pin ( async move { self_. call_async ( dst) . await } ) ,
@@ -258,30 +258,30 @@ where
258
258
{
259
259
async fn call_async (
260
260
& mut self ,
261
- dst : Destination ,
261
+ dst : Uri ,
262
262
) -> Result < ( TcpStream , Connected ) , ConnectError > {
263
263
trace ! (
264
- "Http::connect; scheme={}, host={}, port={:?}" ,
264
+ "Http::connect; scheme={:? }, host={:? }, port={:?}" ,
265
265
dst. scheme( ) ,
266
266
dst. host( ) ,
267
267
dst. port( ) ,
268
268
) ;
269
269
270
270
if self . config . enforce_http {
271
- if dst. uri . scheme ( ) != Some ( & Scheme :: HTTP ) {
271
+ if dst. scheme ( ) != Some ( & Scheme :: HTTP ) {
272
272
return Err ( ConnectError {
273
273
msg : INVALID_NOT_HTTP . into ( ) ,
274
274
cause : None ,
275
275
} ) ;
276
276
}
277
- } else if dst. uri . scheme ( ) . is_none ( ) {
277
+ } else if dst. scheme ( ) . is_none ( ) {
278
278
return Err ( ConnectError {
279
279
msg : INVALID_MISSING_SCHEME . into ( ) ,
280
280
cause : None ,
281
281
} ) ;
282
282
}
283
283
284
- let host = match dst. uri . host ( ) {
284
+ let host = match dst. host ( ) {
285
285
Some ( s) => s,
286
286
None => {
287
287
return Err ( ConnectError {
@@ -290,9 +290,9 @@ where
290
290
} )
291
291
}
292
292
} ;
293
- let port = match dst. uri . port ( ) {
293
+ let port = match dst. port ( ) {
294
294
Some ( port) => port. as_u16 ( ) ,
295
- None => if dst. uri . scheme ( ) == Some ( & Scheme :: HTTPS ) { 443 } else { 80 } ,
295
+ None => if dst. scheme ( ) == Some ( & Scheme :: HTTPS ) { 443 } else { 80 } ,
296
296
} ;
297
297
298
298
let config = & self . config ;
@@ -351,26 +351,6 @@ where
351
351
}
352
352
}
353
353
354
- impl < R > tower_service:: Service < Uri > for HttpConnector < R >
355
- where
356
- R : Resolve + Clone + Send + Sync + ' static ,
357
- R :: Future : Send ,
358
- {
359
- type Response = TcpStream ;
360
- type Error = ConnectError ;
361
- type Future =
362
- Pin < Box < dyn Future < Output = Result < Self :: Response , Self :: Error > > + Send + ' static > > ;
363
-
364
- fn poll_ready ( & mut self , cx : & mut task:: Context < ' _ > ) -> Poll < Result < ( ) , Self :: Error > > {
365
- tower_service:: Service :: < Destination > :: poll_ready ( self , cx)
366
- }
367
-
368
- fn call ( & mut self , uri : Uri ) -> Self :: Future {
369
- let mut self_ = self . clone ( ) ;
370
- Box :: pin ( async move { self_. call_async ( Destination { uri } ) . await . map ( |( s, _) | s) } )
371
- }
372
- }
373
-
374
354
impl HttpInfo {
375
355
/// Get the remote address of the transport used.
376
356
pub fn remote_addr ( & self ) -> SocketAddr {
@@ -661,12 +641,14 @@ impl ConnectingTcp {
661
641
mod tests {
662
642
use std:: io;
663
643
644
+ use :: http:: Uri ;
645
+
664
646
use super :: super :: sealed:: Connect ;
665
- use super :: { Connected , Destination , HttpConnector } ;
647
+ use super :: { Connected , HttpConnector } ;
666
648
667
649
async fn connect < C > (
668
650
connector : C ,
669
- dst : Destination ,
651
+ dst : Uri ,
670
652
) -> Result < ( C :: Transport , Connected ) , C :: Error >
671
653
where
672
654
C : Connect ,
@@ -676,8 +658,7 @@ mod tests {
676
658
677
659
#[ tokio:: test]
678
660
async fn test_errors_enforce_http ( ) {
679
- let uri = "https://example.domain/foo/bar?baz" . parse ( ) . unwrap ( ) ;
680
- let dst = Destination { uri } ;
661
+ let dst = "https://example.domain/foo/bar?baz" . parse ( ) . unwrap ( ) ;
681
662
let connector = HttpConnector :: new ( ) ;
682
663
683
664
let err = connect ( connector, dst) . await . unwrap_err ( ) ;
@@ -686,8 +667,7 @@ mod tests {
686
667
687
668
#[ tokio:: test]
688
669
async fn test_errors_missing_scheme ( ) {
689
- let uri = "example.domain" . parse ( ) . unwrap ( ) ;
690
- let dst = Destination { uri } ;
670
+ let dst = "example.domain" . parse ( ) . unwrap ( ) ;
691
671
let mut connector = HttpConnector :: new ( ) ;
692
672
connector. enforce_http ( false ) ;
693
673
0 commit comments