Crates.io | async-http-proxy |
lib.rs | async-http-proxy |
version | 1.2.5 |
source | src |
created_at | 2021-01-16 12:04:35.928163 |
updated_at | 2022-02-19 15:01:59.975278 |
description | Lightweight asynchronous HTTP proxy client library |
homepage | |
repository | https://github.com/LinkTed/async-http-proxy |
max_upload_size | |
id | 342771 |
size | 39,235 |
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.
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(())
})
}
CONNECT
This project is licensed under the BSD-3-Clause license.
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.