Function http_connect_tokio

Source
pub async fn http_connect_tokio<IO>(
    io: &mut IO,
    host: &str,
    port: u16,
) -> Result<(), HttpError>
where IO: AsyncRead + AsyncWrite + Unpin,
Available on crate feature runtime-tokio only.
Expand description

Connect to the server defined by the host and port and check if the connection was established.

The functions will use HTTP CONNECT request and the tokio runtime.

ยงExample

use async_http_proxy::http_connect_tokio;
use std::error::Error;
use tokio::net::TcpStream;
// Features "runtime-tokio" have to be activated
#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
    let mut stream = TcpStream::connect("127.0.0.1:8080").await?;
    http_connect_tokio(&mut stream, "example.org", 443).await?;
    // stream is now connect to github.com
    Ok(())
}