@@ -490,7 +490,7 @@ impl<'u> ClientBuilder<'u> {
490490 handle : & Handle ,
491491 ) -> async :: ClientNew < Box < stream:: async:: Stream + Send > > {
492492 // connect to the tcp stream
493- let tcp_stream = match self . async_tcpstream ( handle) {
493+ let tcp_stream = match self . async_tcpstream ( None , handle) {
494494 Ok ( t) => t,
495495 Err ( e) => return future:: err ( e) . boxed ( ) ,
496496 } ;
@@ -543,7 +543,7 @@ impl<'u> ClientBuilder<'u> {
543543 handle : & Handle ,
544544 ) -> async :: ClientNew < async :: TlsStream < async :: TcpStream > > {
545545 // connect to the tcp stream
546- let tcp_stream = match self . async_tcpstream ( handle) {
546+ let tcp_stream = match self . async_tcpstream ( Some ( true ) , handle) {
547547 Ok ( t) => t,
548548 Err ( e) => return future:: err ( e) . boxed ( ) ,
549549 } ;
@@ -565,22 +565,22 @@ impl<'u> ClientBuilder<'u> {
565565 } ;
566566
567567 // put it all together
568- let future =
569- tcp_stream . map_err ( |e| e . into ( ) )
570- . and_then ( move |s| {
571- connector . connect_async ( & host , s ) . map_err ( |e| e. into ( ) )
572- } )
573- . and_then ( move |stream| {
574- builder. async_connect_on ( stream)
575- } ) ;
568+ let future = tcp_stream . map_err ( |e| e . into ( ) )
569+ . and_then ( move |s| {
570+ connector . connect_async ( & host , s )
571+ . map_err ( |e| e. into ( ) )
572+ } )
573+ . and_then ( move |stream| {
574+ builder. async_connect_on ( stream)
575+ } ) ;
576576 Box :: new ( future)
577577 }
578578
579579 // TODO: add timeout option for connecting
580580 // TODO: add conveniences like .response_to_pings, .send_close, etc.
581581 #[ cfg( feature="async" ) ]
582582 pub fn async_connect_insecure ( self , handle : & Handle ) -> async :: ClientNew < async :: TcpStream > {
583- let tcp_stream = match self . async_tcpstream ( handle) {
583+ let tcp_stream = match self . async_tcpstream ( Some ( false ) , handle) {
584584 Ok ( t) => t,
585585 Err ( e) => return future:: err ( e) . boxed ( ) ,
586586 } ;
@@ -645,20 +645,23 @@ impl<'u> ClientBuilder<'u> {
645645 }
646646
647647 #[ cfg( feature="async" ) ]
648- fn async_tcpstream ( & self , handle : & Handle ) -> WebSocketResult < TcpStreamNew > {
648+ fn async_tcpstream (
649+ & self ,
650+ secure : Option < bool > ,
651+ handle : & Handle ,
652+ ) -> WebSocketResult < TcpStreamNew > {
649653 // get the address to connect to, return an error future if ther's a problem
650- let address =
651- match self . extract_host_port ( Some ( false ) ) . and_then ( |p| Ok ( p. to_socket_addrs ( ) ?) ) {
652- Ok ( mut s) => {
653- match s. next ( ) {
654- Some ( a) => a,
655- None => {
656- return Err ( WebSocketError :: WebSocketUrlError ( WSUrlErrorKind :: NoHostName ) ) ;
657- }
654+ let address = match self . extract_host_port ( secure) . and_then ( |p| Ok ( p. to_socket_addrs ( ) ?) ) {
655+ Ok ( mut s) => {
656+ match s. next ( ) {
657+ Some ( a) => a,
658+ None => {
659+ return Err ( WebSocketError :: WebSocketUrlError ( WSUrlErrorKind :: NoHostName ) ) ;
658660 }
659661 }
660- Err ( e) => return Err ( e. into ( ) ) ,
661- } ;
662+ }
663+ Err ( e) => return Err ( e. into ( ) ) ,
664+ } ;
662665
663666 // connect a tcp stream
664667 Ok ( async :: TcpStream :: connect ( & address, handle) )
0 commit comments