This article provides an example of using a proxy to make an HTTP request with the Rust programming language.

Rust Code

In this example, we use the Residential proxy below:
This proxy is split into four parts separated by colons. We first save the proxy as a string variable, then split it into four parts at each colon (:) and then add it, with authentication, to our proxy dictionary.
use reqwest;
async fn main() {
let proxy_string = "".to_string();
let split_proxy: Vec<&str> = proxy_string.split(":").collect();
match &split_proxy[..] {
[ip, port, user, pass] => {
let uri = format!("{}:{}", ip, port);
let http = reqwest::Proxy::http(&uri).unwrap().basic_auth(user, pass);
let https = reqwest::Proxy::https(&uri).unwrap().basic_auth(user, pass);
let client = reqwest::Client::builder()
let res = client.get("").send().await.unwrap();
_ => panic!(),
This requires tokio as an async driver and reqwest as a http client.
reqwest = "0.11.12"
tokio = { version = "1.12.2", features = ["full"] }
Last modified 1yr ago