pub fn finish(
        self,
    ) -> impl Service<Request = Connect, Response = impl Connection, Error = ConnectError>
           + Clone {
        #[cfg(not(any(feature = "openssl", feature = "rustls")))]
        {
            let connector = TimeoutService::new(
                self.config.timeout,
                apply_fn(self.connector, |msg: Connect, srv| {
                    srv.call(TcpConnect::new(msg.uri).set_addr(msg.addr))
                })
                .map_err(ConnectError::from)
                .map(|stream| (stream.into_parts().0, Protocol::Http1)),
            )
            .map_err(|e| match e {
                TimeoutError::Service(e) => e,
                TimeoutError::Timeout => ConnectError::Timeout,
            });

            connect_impl::InnerConnector {
                tcp_pool: ConnectionPool::new(
                    connector,
                    self.config.no_disconnect_timeout(),
                ),
            }
        }
        #[cfg(any(feature = "openssl", feature = "rustls"))]
        {
            const H2: &[u8] = b"h2";
            #[cfg(feature = "openssl")]
            use actix_connect::ssl::openssl::OpensslConnector;
            #[cfg(feature = "rustls")]
            use actix_connect::ssl::rustls::{RustlsConnector, Session};
            use actix_service::{boxed::service, pipeline};

            let ssl_service = TimeoutService::new(
                self.config.timeout,
                pipeline(
                    apply_fn(self.connector.clone(), |msg: Connect, srv| {
                        srv.call(TcpConnect::new(msg.uri).set_addr(msg.addr))
                    })
                    .map_err(ConnectError::from),
                )
                .and_then(match self.ssl {
                    #[cfg(feature = "openssl")]
                    SslConnector::Openssl(ssl) => service(
                        OpensslConnector::service(ssl)
                            .map(|stream| {
                                let sock = stream.into_parts().0;
                                let h2 = sock
                                    .ssl()
                                    .selected_alpn_protocol()
                                    .map(|protos| protos.windows(2).any(|w| w == H2))
                                    .unwrap_or(false);
                                if h2 {
                                    (Box::new(sock) as Box<dyn Io>, Protocol::Http2)
                                } else {
                                    (Box::new(sock) as Box<dyn Io>, Protocol::Http1)
                                }
                            })
                            .map_err(ConnectError::from),
                    ),
                    #[cfg(feature = "rustls")]
                    SslConnector::Rustls(ssl) => service(
                        RustlsConnector::service(ssl)
                            .map_err(ConnectError::from)
                            .map(|stream| {
                                let sock = stream.into_parts().0;
                                let h2 = sock
                                    .get_ref()
                                    .1
                                    .get_alpn_protocol()
                                    .map(|protos| protos.windows(2).any(|w| w == H2))
                                    .unwrap_or(false);
                                if h2 {
                                    (Box::new(sock) as Box<dyn Io>, Protocol::Http2)
                                } else {
                                    (Box::new(sock) as Box<dyn Io>, Protocol::Http1)
                                }
                            }),
                    ),
                }),
            )
            .map_err(|e| match e {
                TimeoutError::Service(e) => e,
                TimeoutError::Timeout => ConnectError::Timeout,
            });

            let tcp_service = TimeoutService::new(
                self.config.timeout,
                apply_fn(self.connector, |msg: Connect, srv| {
                    srv.call(TcpConnect::new(msg.uri).set_addr(msg.addr))
                })
                .map_err(ConnectError::from)
                .map(|stream| (stream.into_parts().0, Protocol::Http1)),
            )
            .map_err(|e| match e {
                TimeoutError::Service(e) => e,
                TimeoutError::Timeout => ConnectError::Timeout,
            });

            connect_impl::InnerConnector {
                tcp_pool: ConnectionPool::new(
                    tcp_service,
                    self.config.no_disconnect_timeout(),
                ),
                ssl_pool: ConnectionPool::new(ssl_service, self.config),
            }
        }
    }
/// Finish configuration process and create connector service.
/// The Connector builder always concludes by calling `finish()` last in
/// its combinator chain.
Finish configuration process and create connector service.
The Connector builder always concludes by calling `finish()` last in
its combinator chain.
Finish configuration process and create connector service . The Connector builder always concludes by calling ` finish () ` last in its combinator chain .
pub fn finish(
        self,
    ) -> impl Service<Request = Connect, Response = impl Connection, Error = ConnectError>
           + Clone {
        #[cfg(not(any(feature = "openssl", feature = "rustls")))]
        {
            let connector = TimeoutService::new(
                self.config.timeout,
                apply_fn(self.connector, |msg: Connect, srv| {
                    srv.call(TcpConnect::new(msg.uri).set_addr(msg.addr))
                })
                .map_err(ConnectError::from)
                .map(|stream| (stream.into_parts().0, Protocol::Http1)),
            )
            .map_err(|e| match e {
                TimeoutError::Service(e) => e,
                TimeoutError::Timeout => ConnectError::Timeout,
            });
            connect_impl::InnerConnector {
                tcp_pool: ConnectionPool::new(
                    connector,
                    self.config.no_disconnect_timeout(),
                ),
            }
        }
        #[cfg(any(feature = "openssl", feature = "rustls"))]
        {
            const H2: &[u8] = b"h2";
            #[cfg(feature = "openssl")]
            use actix_connect::ssl::openssl::OpensslConnector;
            #[cfg(feature = "rustls")]
            use actix_connect::ssl::rustls::{RustlsConnector, Session};
            use actix_service::{boxed::service, pipeline};
            let ssl_service = TimeoutService::new(
                self.config.timeout,
                pipeline(
                    apply_fn(self.connector.clone(), |msg: Connect, srv| {
                        srv.call(TcpConnect::new(msg.uri).set_addr(msg.addr))
                    })
                    .map_err(ConnectError::from),
                )
                .and_then(match self.ssl {
                    #[cfg(feature = "openssl")]
                    SslConnector::Openssl(ssl) => service(
                        OpensslConnector::service(ssl)
                            .map(|stream| {
                                let sock = stream.into_parts().0;
                                let h2 = sock
                                    .ssl()
                                    .selected_alpn_protocol()
                                    .map(|protos| protos.windows(2).any(|w| w == H2))
                                    .unwrap_or(false);
                                if h2 {
                                    (Box::new(sock) as Box<dyn Io>, Protocol::Http2)
                                } else {
                                    (Box::new(sock) as Box<dyn Io>, Protocol::Http1)
                                }
                            })
                            .map_err(ConnectError::from),
                    ),
                    #[cfg(feature = "rustls")]
                    SslConnector::Rustls(ssl) => service(
                        RustlsConnector::service(ssl)
                            .map_err(ConnectError::from)
                            .map(|stream| {
                                let sock = stream.into_parts().0;
                                let h2 = sock
                                    .get_ref()
                                    .1
                                    .get_alpn_protocol()
                                    .map(|protos| protos.windows(2).any(|w| w == H2))
                                    .unwrap_or(false);
                                if h2 {
                                    (Box::new(sock) as Box<dyn Io>, Protocol::Http2)
                                } else {
                                    (Box::new(sock) as Box<dyn Io>, Protocol::Http1)
                                }
                            }),
                    ),
                }),
            )
            .map_err(|e| match e {
                TimeoutError::Service(e) => e,
                TimeoutError::Timeout => ConnectError::Timeout,
            });
            let tcp_service = TimeoutService::new(
                self.config.timeout,
                apply_fn(self.connector, |msg: Connect, srv| {
                    srv.call(TcpConnect::new(msg.uri).set_addr(msg.addr))
                })
                .map_err(ConnectError::from)
                .map(|stream| (stream.into_parts().0, Protocol::Http1)),
            )
            .map_err(|e| match e {
                TimeoutError::Service(e) => e,
                TimeoutError::Timeout => ConnectError::Timeout,
            });
            connect_impl::InnerConnector {
                tcp_pool: ConnectionPool::new(
                    tcp_service,
                    self.config.no_disconnect_timeout(),
                ),
                ssl_pool: ConnectionPool::new(ssl_service, self.config),
            }
        }
    }
pub fn finish ( self , ) -> impl Service < Request = Connect , Response = impl Connection , Error = ConnectError > + Clone { # [ cfg ( not ( any ( feature " " feature " " ) ) ) ] { let connector = TimeoutService :: new ( self . config . timeout , apply_fn ( self . connector , | msg : Connect , srv | { srv . call ( TcpConnect :: new ( msg . uri ) . set_addr ( msg . addr ) ) } ) . map_err ( ConnectError :: from ) . map ( | stream | ( stream . into_parts ( ) . 0 , Protocol :: Http1 ) ) , ) . map_err ( | e | match e { TimeoutError :: Service ( e ) => e , TimeoutError :: Timeout => ConnectError :: Timeout , } ) ; connect_impl :: InnerConnector { tcp_pool : ConnectionPool :: new ( connector , self . config . no_disconnect_timeout ( ) , ) , } } # [ cfg ( any ( feature " " feature " " ) ) ] { const H2 : & [ u8 ] = b" " ; # [ cfg ( feature " " ) ] use actix_connect :: ssl :: openssl :: OpensslConnector ; # [ cfg ( feature " " ) ] use actix_connect :: ssl :: rustls :: { RustlsConnector , Session } ; use actix_service :: { boxed :: service , pipeline } ; let ssl_service = TimeoutService :: new ( self . config . timeout , pipeline ( apply_fn ( self . connector . clone ( ) , | msg : Connect , srv | { srv . call ( TcpConnect :: new ( msg . uri ) . set_addr ( msg . addr ) ) } ) . map_err ( ConnectError :: from ) , ) . and_then ( match self . ssl { # [ cfg ( feature " " ) ] SslConnector :: Openssl ( ssl ) => service ( OpensslConnector :: service ( ssl ) . map ( | stream | { let sock = stream . into_parts ( ) . 0 ; let h2 = sock . ssl ( ) . selected_alpn_protocol ( ) . map ( | protos | protos . windows ( 2 ) . any ( | w | w == H2 ) ) . unwrap_or ( false ) ; if h2 { ( Box :: new ( sock ) as Box < dyn Io > , Protocol :: Http2 ) } else { ( Box :: new ( sock ) as Box < dyn Io > , Protocol :: Http1 ) } } ) . map_err ( ConnectError :: from ) , ) , # [ cfg ( feature " " ) ] SslConnector :: Rustls ( ssl ) => service ( RustlsConnector :: service ( ssl ) . map_err ( ConnectError :: from ) . map ( | stream | { let sock = stream . into_parts ( ) . 0 ; let h2 = sock . get_ref ( ) . 1 . get_alpn_protocol ( ) . map ( | protos | protos . windows ( 2 ) . any ( | w | w == H2 ) ) . unwrap_or ( false ) ; if h2 { ( Box :: new ( sock ) as Box < dyn Io > , Protocol :: Http2 ) } else { ( Box :: new ( sock ) as Box < dyn Io > , Protocol :: Http1 ) } } ) , ) , } ) , ) . map_err ( | e | match e { TimeoutError :: Service ( e ) => e , TimeoutError :: Timeout => ConnectError :: Timeout , } ) ; let tcp_service = TimeoutService :: new ( self . config . timeout , apply_fn ( self . connector , | msg : Connect , srv | { srv . call ( TcpConnect :: new ( msg . uri ) . set_addr ( msg . addr ) ) } ) . map_err ( ConnectError :: from ) . map ( | stream | ( stream . into_parts ( ) . 0 , Protocol :: Http1 ) ) , ) . map_err ( | e | match e { TimeoutError :: Service ( e ) => e , TimeoutError :: Timeout => ConnectError :: Timeout , } ) ; connect_impl :: InnerConnector { tcp_pool : ConnectionPool :: new ( tcp_service , self . config . no_disconnect_timeout ( ) , ) , ssl_pool : ConnectionPool :: new ( ssl_service , self . config ) , } } }
Finish configuration process and create connector service.
Finish configuration process and create connector service .
self
self