@@ -489,7 +489,51 @@ impl<'u> ClientBuilder<'u> {
489489 ssl_config : Option < TlsConnector > ,
490490 handle : & Handle ,
491491 ) -> async :: ClientNew < Box < stream:: async:: Stream + Send > > {
492- unimplemented ! ( ) ;
492+ // connect to the tcp stream
493+ let tcp_stream = match self . async_tcpstream ( handle) {
494+ Ok ( t) => t,
495+ Err ( e) => return future:: err ( e) . boxed ( ) ,
496+ } ;
497+
498+ let builder = ClientBuilder {
499+ url : Cow :: Owned ( self . url . into_owned ( ) ) ,
500+ version : self . version ,
501+ headers : self . headers ,
502+ version_set : self . version_set ,
503+ key_set : self . key_set ,
504+ } ;
505+
506+ // check if we should connect over ssl or not
507+ if builder. url . scheme ( ) == "wss" {
508+ // configure the tls connection
509+ let ( host, connector) = {
510+ match builder. extract_host_ssl_conn ( ssl_config) {
511+ Ok ( ( h, conn) ) => ( h. to_string ( ) , conn) ,
512+ Err ( e) => return future:: err ( e) . boxed ( ) ,
513+ }
514+ } ;
515+ // secure connection, wrap with ssl
516+ let future =
517+ tcp_stream. map_err ( |e| e. into ( ) )
518+ . and_then ( move |s| {
519+ connector. connect_async ( & host, s)
520+ . map_err ( |e| e. into ( ) )
521+ } )
522+ . and_then ( move |stream| {
523+ let stream: Box < stream:: async:: Stream + Send > = Box :: new ( stream) ;
524+ builder. async_connect_on ( stream)
525+ } ) ;
526+ Box :: new ( future)
527+ } else {
528+ // insecure connection, connect normally
529+ let future =
530+ tcp_stream. map_err ( |e| e. into ( ) )
531+ . and_then ( move |stream| {
532+ let stream: Box < stream:: async:: Stream + Send > = Box :: new ( stream) ;
533+ builder. async_connect_on ( stream)
534+ } ) ;
535+ Box :: new ( future)
536+ }
493537 }
494538
495539 #[ cfg( feature="async-ssl" ) ]
0 commit comments