Function http_connect_async_std_with_basic_auth

Source
pub async fn http_connect_async_std_with_basic_auth<IO>(
    io: &mut IO,
    host: &str,
    port: u16,
    username: &str,
    password: &str,
) -> Result<(), HttpError>
where IO: Read + Write + Unpin,
Available on crate features runtime-async-std and basic-auth only.
Expand description

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

The functions will use HTTP CONNECT request and the async std framework.

ยงExample

use async_http_proxy::http_connect_async_std_with_basic_auth;
use async_std::net::TcpStream;
use async_std::task;
use std::error::Error;
// Features "async-std-tokio" and "basic-auth" have to be activated
fn main() -> Result<(), Box<dyn Error>> {
    task::block_on(async {
        let mut stream = TcpStream::connect("127.0.0.1:8080").await?;
        http_connect_async_std_with_basic_auth(
            &mut stream,
            "example.org",
            443,
            "username",
            "password",
        )
        .await?;
        // stream is now connect to github.com
        Ok(())
    })
}