#http #proxy #async #client

async-http-proxy

Lightweight asynchronous HTTP proxy client library

7 stable releases

new 1.2.3 Oct 16, 2021
1.2.2 Aug 28, 2021
1.2.1 Jul 26, 2021
1.2.0 Jun 5, 2021
1.1.0 Jan 17, 2021

#346 in Network programming

Download history 16/week @ 2021-07-02 20/week @ 2021-07-09 40/week @ 2021-07-16 35/week @ 2021-07-23 87/week @ 2021-07-30 25/week @ 2021-08-06 38/week @ 2021-08-13 88/week @ 2021-08-20 180/week @ 2021-08-27 78/week @ 2021-09-03 156/week @ 2021-09-10 130/week @ 2021-09-17 160/week @ 2021-09-24 134/week @ 2021-10-01 162/week @ 2021-10-08 97/week @ 2021-10-15

445 downloads per month
Used in 2 crates

BSD-3-Clause

18KB
268 lines

async-http-proxy

async-http-proxy is a lightweight asynchronous HTTP proxy client library, which can be used to connect a to a TCP port via HTTP Connect proxy. It can use Tokio and async-std as asynchronous runtime.

Latest version License Dependency status

Example

The following example shows how to connect to github.com via Connect proxy (tokio):

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(())
}

The following example shows how to connect to example.org with Basic Authentication via Connect proxy (async-std):

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(())
    })
}

Features

  • HTTP CONNECT
  • Basic Auth
  • Tokio
  • async-std

License

This project is licensed under the BSD-3-Clause license.

Contribution

Any contribution intentionally submitted for inclusion in async_http_proxy by you, shall be licensed as BSD-3-Clause, without any additional terms or conditions.

Dependencies

~0.4–3MB
~58K SLoC