#http #proxy #async #client

async-http-proxy

Lightweight asynchronous HTTP proxy client library

3 stable releases

1.1.1 Apr 4, 2021
1.1.0 Jan 17, 2021
1.0.0 Jan 16, 2021

#716 in Network programming

Download history 77/week @ 2021-01-20 10/week @ 2021-01-27 38/week @ 2021-02-03 13/week @ 2021-02-10 14/week @ 2021-02-17 5/week @ 2021-02-24 9/week @ 2021-03-03 8/week @ 2021-03-10 4/week @ 2021-03-17 11/week @ 2021-03-24 42/week @ 2021-03-31 16/week @ 2021-04-07 14/week @ 2021-04-14 13/week @ 2021-04-21 9/week @ 2021-04-28 15/week @ 2021-05-05

78 downloads per month
Used in doh-client

BSD-3-Clause

19KB
283 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;
use url::Url;
// Features "runtime-tokio" and "basic-auth" have to be activated
#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
    let mut stream = TcpStream::connect("127.0.0.1:8080").await?;
    let url = Url::parse("https://github.com")?;

    http_connect_tokio(&mut stream, &url).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;
use async_std::net::TcpStream;
use async_std::task;
use std::error::Error;
use url::Url;
// 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?;
        // feature "basic-auth" have to be active
        let url = Url::parse("https://USER:PASSWORD@example.org")?;

        http_connect_async_std(&mut stream, &url).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–2.9MB
~57K SLoC