Repository: seanmonstar/reqwest (language: rust)

Issue:
SOCKS5 proxy example please?
It is not obvious at all how to use the SOCKS5 capability. Can an example be provided please?


Discussion / hints:
Hm, you're right, it is rather opaque. The `Proxy` docs should be updated to explain it's design a bit more.

The `Proxy` type has several constructors. You pick the one based on what kinds of URLs you want to match this proxy. And you pass as an argument the proxy destination.

For example, to proxy HTTPS only, you'd use something like `Proxy::https("http://localhost:3333"/)`. For socks, you just pass a socks URL as the argument. You can still pick whether to only use socks for HTTP, HTTPS, or *all* URLs by the name of the constructor. Something like `Proxy::all("socks5://10.1.1.1:12345")`.

Fix patch:
diff --git a/src/proxy.rs b/src/proxy.rs
index 7ee3661cb..f2818ef00 100644
--- a/src/proxy.rs
+++ b/src/proxy.rs
@@ -40,6 +40,14 @@ use winreg::RegKey;
 /// check each `Proxy` in the order it was added. This could mean that a
 /// `Proxy` added first with eager intercept rules, such as `Proxy::all`,
 /// would prevent a `Proxy` later in the list from ever working, so take care.
+///
+/// By enabling the `"socks"` feature it is possible to use a socks proxy:
+/// ```rust
+/// # fn run() -> Result<(), Box<std::error::Error>> {
+/// let proxy = reqwest::Proxy::http("socks5://192.168.1.1:9000")?;
+/// # Ok(())
+/// # }
+/// ```
 #[derive(Clone, Debug)]
 pub struct Proxy {
     intercept: Intercept,


Test patch: