add proxy authorization

This commit is contained in:
Johann Tuffe
2017-12-19 15:44:06 +08:00
parent 2f403175dc
commit 871b8076e4
3 changed files with 26 additions and 12 deletions

View File

@@ -1,5 +1,7 @@
extern crate reqwest;
use reqwest::header::Bearer;
#[macro_use]
mod support;
@@ -12,6 +14,7 @@ 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"\
@@ -23,7 +26,8 @@ fn test_http_proxy() {
};
let proxy_uri = format!("http://{}", server.addr());
let proxy = reqwest::Proxy::http(&proxy_uri).unwrap();
let mut proxy = reqwest::Proxy::http(&proxy_uri).unwrap();
proxy.set_authorization(Bearer { token: "MY_SECRET_TOKEN".to_string() });
let url = "http://hyper.rs/prox";
let res = reqwest::Client::builder()