Rust
一、安装依赖
[dependencies]
reqwest = { version = "0.12", features = ["blocking"] }二、HTTP 代理示例
use reqwest::blocking::Client;
use reqwest::Proxy;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let proxy = Proxy::http(
"http://username_custom_zone_us:password@us.ipwo.net:7878"
)?;
let client = Client::builder()
.proxy(proxy)
.timeout(std::time::Duration::from_secs(30))
.build()?;
let response = client
.get("http://ipinfo.io")
.send()?
.text()?;
println!("{}", response);
Ok(())
}三、正常返回示例
四、异步请求示例(推荐)
五、常见问题
六、推荐开发建议
七、相关文章
最后更新于
这有帮助吗?
