uses hyper-proxy 0.3.0
This commit is contained in:
@@ -26,8 +26,7 @@ tokio-io = "0.1"
|
|||||||
tokio-tls = "0.1"
|
tokio-tls = "0.1"
|
||||||
url = "1.2"
|
url = "1.2"
|
||||||
uuid = { version = "0.5", features = ["v4"] }
|
uuid = { version = "0.5", features = ["v4"] }
|
||||||
hyper-proxy = { version = "0.2.0", path = "../hyper-proxy" }
|
hyper-proxy = "0.3.0"
|
||||||
#hyper-proxy = "0.2.0"
|
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
env_logger = "0.4"
|
env_logger = "0.4"
|
||||||
|
|||||||
@@ -100,13 +100,8 @@ impl Proxy {
|
|||||||
/// # fn run() -> Result<(), Box<::std::error::Error>> {
|
/// # fn run() -> Result<(), Box<::std::error::Error>> {
|
||||||
/// let target = reqwest::Url::parse("https://my.prox")?;
|
/// let target = reqwest::Url::parse("https://my.prox")?;
|
||||||
/// let client = reqwest::Client::builder()
|
/// let client = reqwest::Client::builder()
|
||||||
/// .proxy(reqwest::Proxy::custom(move |url| {
|
/// .proxy(reqwest::Proxy::custom(|url| url.host() == Some("hyper.rs"),
|
||||||
/// if url.host_str() == Some("hyper.rs") {
|
/// "http://proxy.custom")?)
|
||||||
/// Some(target.clone())
|
|
||||||
/// } else {
|
|
||||||
/// None
|
|
||||||
/// }
|
|
||||||
/// }))
|
|
||||||
/// .build()?;
|
/// .build()?;
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
/// # }
|
||||||
|
|||||||
@@ -19,14 +19,15 @@ fn test_http_proxy() {
|
|||||||
Server: proxied\r\n\
|
Server: proxied\r\n\
|
||||||
Content-Length: 0\r\n\
|
Content-Length: 0\r\n\
|
||||||
\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 url = "http://hyper.rs/prox";
|
||||||
let res = reqwest::Client::builder()
|
let res = reqwest::Client::builder()
|
||||||
.proxy(reqwest::Proxy::http(&proxy).unwrap())
|
.proxy(proxy)
|
||||||
.build()
|
.build()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.get(url)
|
.get(url)
|
||||||
|
|||||||
@@ -57,7 +57,6 @@ pub fn spawn(txns: Vec<Txn>) -> Server {
|
|||||||
Ok(nread) => n += nread,
|
Ok(nread) => n += nread,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
match (::std::str::from_utf8(&expected), ::std::str::from_utf8(&buf[..n])) {
|
match (::std::str::from_utf8(&expected), ::std::str::from_utf8(&buf[..n])) {
|
||||||
(Ok(expected), Ok(received)) => assert_eq!(expected, received),
|
(Ok(expected), Ok(received)) => assert_eq!(expected, received),
|
||||||
_ => assert_eq!(expected, &buf[..n]),
|
_ => assert_eq!(expected, &buf[..n]),
|
||||||
|
|||||||
Reference in New Issue
Block a user