From 2f403175dcfe234a23cae079ecbf4a70de9db6e7 Mon Sep 17 00:00:00 2001 From: Johann Tuffe Date: Tue, 19 Dec 2017 15:23:39 +0800 Subject: [PATCH] uses hyper-proxy 0.3.0 --- Cargo.toml | 3 +-- src/proxy.rs | 9 ++------- tests/proxy.rs | 7 ++++--- tests/support/server.rs | 1 - 4 files changed, 7 insertions(+), 13 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 6e3bf95..9b2e717 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,8 +26,7 @@ tokio-io = "0.1" tokio-tls = "0.1" url = "1.2" uuid = { version = "0.5", features = ["v4"] } -hyper-proxy = { version = "0.2.0", path = "../hyper-proxy" } -#hyper-proxy = "0.2.0" +hyper-proxy = "0.3.0" [dev-dependencies] env_logger = "0.4" diff --git a/src/proxy.rs b/src/proxy.rs index d1f84e3..4eee7f2 100644 --- a/src/proxy.rs +++ b/src/proxy.rs @@ -100,13 +100,8 @@ impl Proxy { /// # fn run() -> Result<(), Box<::std::error::Error>> { /// let target = reqwest::Url::parse("https://my.prox")?; /// let client = reqwest::Client::builder() - /// .proxy(reqwest::Proxy::custom(move |url| { - /// if url.host_str() == Some("hyper.rs") { - /// Some(target.clone()) - /// } else { - /// None - /// } - /// })) + /// .proxy(reqwest::Proxy::custom(|url| url.host() == Some("hyper.rs"), + /// "http://proxy.custom")?) /// .build()?; /// # Ok(()) /// # } diff --git a/tests/proxy.rs b/tests/proxy.rs index 75dbbb6..49c8e5c 100644 --- a/tests/proxy.rs +++ b/tests/proxy.rs @@ -19,14 +19,15 @@ fn test_http_proxy() { Server: proxied\r\n\ Content-Length: 0\r\n\ \r\n\ - " + "; }; - let proxy = format!("http://{}", server.addr()); + let proxy_uri = format!("http://{}", server.addr()); + let proxy = reqwest::Proxy::http(&proxy_uri).unwrap(); let url = "http://hyper.rs/prox"; let res = reqwest::Client::builder() - .proxy(reqwest::Proxy::http(&proxy).unwrap()) + .proxy(proxy) .build() .unwrap() .get(url) diff --git a/tests/support/server.rs b/tests/support/server.rs index e882e29..dc10a39 100644 --- a/tests/support/server.rs +++ b/tests/support/server.rs @@ -57,7 +57,6 @@ pub fn spawn(txns: Vec) -> Server { Ok(nread) => n += nread, } } - match (::std::str::from_utf8(&expected), ::std::str::from_utf8(&buf[..n])) { (Ok(expected), Ok(received)) => assert_eq!(expected, received), _ => assert_eq!(expected, &buf[..n]),