@@ -545,8 +545,7 @@ where
545545 . map_err ( ConnectError :: dns) ?;
546546 let addrs = addrs
547547 . map ( |mut addr| {
548- set_port ( & mut addr, port, dst. port ( ) . is_some ( ) ) ;
549-
548+ addr. set_port ( port) ;
550549 addr
551550 } )
552551 . collect ( ) ;
@@ -987,19 +986,9 @@ impl ConnectingTcp<'_> {
987986 }
988987}
989988
990- /// Respect explicit ports in the URI, if none, either
991- /// keep non `0` ports resolved from a custom dns resolver,
992- /// or use the default port for the scheme.
993- fn set_port ( addr : & mut SocketAddr , host_port : u16 , explicit : bool ) {
994- if explicit || addr. port ( ) == 0 {
995- addr. set_port ( host_port)
996- } ;
997- }
998-
999989#[ cfg( test) ]
1000990mod tests {
1001991 use std:: io;
1002- use std:: net:: SocketAddr ;
1003992
1004993 use :: http:: Uri ;
1005994
@@ -1008,8 +997,6 @@ mod tests {
1008997 use super :: super :: sealed:: { Connect , ConnectSvc } ;
1009998 use super :: { Config , ConnectError , HttpConnector } ;
1010999
1011- use super :: set_port;
1012-
10131000 async fn connect < C > (
10141001 connector : C ,
10151002 dst : Uri ,
@@ -1428,22 +1415,4 @@ mod tests {
14281415 panic ! ( "test failed" ) ;
14291416 }
14301417 }
1431-
1432- #[ test]
1433- fn test_set_port ( ) {
1434- // Respect explicit ports no matter what the resolved port is.
1435- let mut addr = SocketAddr :: from ( ( [ 0 , 0 , 0 , 0 ] , 6881 ) ) ;
1436- set_port ( & mut addr, 42 , true ) ;
1437- assert_eq ! ( addr. port( ) , 42 ) ;
1438-
1439- // Ignore default host port, and use the socket port instead.
1440- let mut addr = SocketAddr :: from ( ( [ 0 , 0 , 0 , 0 ] , 6881 ) ) ;
1441- set_port ( & mut addr, 443 , false ) ;
1442- assert_eq ! ( addr. port( ) , 6881 ) ;
1443-
1444- // Use the default port if the resolved port is `0`.
1445- let mut addr = SocketAddr :: from ( ( [ 0 , 0 , 0 , 0 ] , 0 ) ) ;
1446- set_port ( & mut addr, 443 , false ) ;
1447- assert_eq ! ( addr. port( ) , 443 ) ;
1448- }
14491418}
0 commit comments