pub fn handshake<T, B>(
        &self,
        io: T,
    ) -> impl Future<Output = crate::Result<(SendRequest<B>, Connection<T, B>)>>
    where
        T: AsyncRead + AsyncWrite + Unpin + Send + 'static,
        B: Payload + 'static,
    {
        let opts = self.clone();

        async move {
            trace!("client handshake HTTP/{}", if opts.http2 { 2 } else { 1 });

            let (tx, rx) = dispatch::channel();
            let proto = if !opts.http2 {
                let mut conn = proto::Conn::new(io);
                if !opts.h1_writev {
                    conn.set_write_strategy_flatten();
                }
                if opts.h1_title_case_headers {
                    conn.set_title_case_headers();
                }
                if let Some(sz) = opts.h1_read_buf_exact_size {
                    conn.set_read_buf_exact_size(sz);
                }
                if let Some(max) = opts.h1_max_buf_size {
                    conn.set_max_buf_size(max);
                }
                let cd = proto::h1::dispatch::Client::new(rx);
                let dispatch = proto::h1::Dispatcher::new(cd, conn);
                ProtoClient::H1(dispatch)
            } else {
                let h2 = proto::h2::client::handshake(io, rx, &opts.h2_builder, opts.exec.clone())
                    .await?;
                ProtoClient::H2(h2)
            };

            Ok((
                SendRequest { dispatch: tx },
                Connection { inner: Some(proto) },
            ))
        }
    }
/// Constructs a connection with the configured options and IO.
Constructs a connection with the configured options and IO.
Constructs a connection with the configured options and IO .
pub fn handshake<T, B>(
        &self,
        io: T,
    ) -> impl Future<Output = crate::Result<(SendRequest<B>, Connection<T, B>)>>
    where
        T: AsyncRead + AsyncWrite + Unpin + Send + 'static,
        B: Payload + 'static,
    {
        let opts = self.clone();
        async move {
            trace!("client handshake HTTP/{}", if opts.http2 { 2 } else { 1 });
            let (tx, rx) = dispatch::channel();
            let proto = if !opts.http2 {
                let mut conn = proto::Conn::new(io);
                if !opts.h1_writev {
                    conn.set_write_strategy_flatten();
                }
                if opts.h1_title_case_headers {
                    conn.set_title_case_headers();
                }
                if let Some(sz) = opts.h1_read_buf_exact_size {
                    conn.set_read_buf_exact_size(sz);
                }
                if let Some(max) = opts.h1_max_buf_size {
                    conn.set_max_buf_size(max);
                }
                let cd = proto::h1::dispatch::Client::new(rx);
                let dispatch = proto::h1::Dispatcher::new(cd, conn);
                ProtoClient::H1(dispatch)
            } else {
                let h2 = proto::h2::client::handshake(io, rx, &opts.h2_builder, opts.exec.clone())
                    .await?;
                ProtoClient::H2(h2)
            };
            Ok((
                SendRequest { dispatch: tx },
                Connection { inner: Some(proto) },
            ))
        }
    }
pub fn handshake < T , B > ( & self , io : T , ) -> impl Future < Output = crate :: Result < ( SendRequest < B > , Connection < T , B > ) > > where T : AsyncRead + AsyncWrite + Unpin + Send + ' static , B : Payload + ' static , { let opts = self . clone ( ) ; async move { trace ! ( " " if opts http2 { 2 } else { 1 } ) ; let ( tx , rx ) = dispatch :: channel ( ) ; let proto = if ! opts . http2 { let mut conn = proto :: Conn :: new ( io ) ; if ! opts . h1_writev { conn . set_write_strategy_flatten ( ) ; } if opts . h1_title_case_headers { conn . set_title_case_headers ( ) ; } if let Some ( sz ) = opts . h1_read_buf_exact_size { conn . set_read_buf_exact_size ( sz ) ; } if let Some ( max ) = opts . h1_max_buf_size { conn . set_max_buf_size ( max ) ; } let cd = proto :: h1 :: dispatch :: Client :: new ( rx ) ; let dispatch = proto :: h1 :: Dispatcher :: new ( cd , conn ) ; ProtoClient :: H1 ( dispatch ) } else { let h2 = proto :: h2 :: client :: handshake ( io , rx , & opts . h2_builder , opts . exec . clone ( ) ) . await ? ; ProtoClient :: H2 ( h2 ) } ; Ok ( ( SendRequest { dispatch : tx } , Connection { inner : Some ( proto ) } , ) ) } }
Constructs a connection with the configured options and IO.
Constructs a connection with the configured options and IO .
&self
io
T
&self
io
T