Revert "Merge pull request #232 from tafia/hyper-proxy"

This reverts commit b09b8620a6, reversing
changes made to abfcd2796e.
This commit is contained in:
Sean McArthur
2018-02-15 12:12:29 -08:00
parent 0203fad886
commit 7db860759d
8 changed files with 517 additions and 67 deletions

View File

@@ -1,7 +1,5 @@
extern crate reqwest;
use reqwest::header::Bearer;
#[macro_use]
mod support;
@@ -14,7 +12,6 @@ fn test_http_proxy() {
User-Agent: $USERAGENT\r\n\
Accept: */*\r\n\
Accept-Encoding: gzip\r\n\
Authorization: Bearer MY_SECRET_TOKEN\r\n\
\r\n\
",
response: b"\
@@ -22,16 +19,14 @@ fn test_http_proxy() {
Server: proxied\r\n\
Content-Length: 0\r\n\
\r\n\
";
"
};
let proxy_uri = format!("http://{}", server.addr());
let mut proxy = reqwest::Proxy::http(&proxy_uri).unwrap();
proxy.set_authorization(Bearer { token: "MY_SECRET_TOKEN".to_string() });
let proxy = format!("http://{}", server.addr());
let url = "http://hyper.rs/prox";
let res = reqwest::Client::builder()
.proxy(proxy)
.proxy(reqwest::Proxy::http(&proxy).unwrap())
.build()
.unwrap()
.get(url)

View File

@@ -52,11 +52,11 @@ pub fn spawn(txns: Vec<Txn>) -> Server {
let mut n = 0;
while n < expected.len() {
match socket.read(&mut buf[n..]) {
Ok(0) => break,
Err(e) => panic!(e),
Ok(0) | Err(_) => break,
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]),