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,4 +1,6 @@
use std::any::Any;
use hyper::Uri;
use hyper::header::{Scheme};
use {IntoUrl};
use hyper_proxy::Intercept;
use hyper_proxy::Proxy as HyperProxy;
@@ -14,11 +16,13 @@ use hyper_proxy::Proxy as HyperProxy;
///
/// ```rust
/// # fn run() -> Result<(), Box<::std::error::Error>> {
/// use reqwest::header::Basic;
///
/// let mut proxy = reqwest::Proxy::http("https://secure.example")?;
/// // proxy.set_authorization(Basic {
/// // username: "John Doe".into(),
/// // password: Some("Agent1234".into()),
/// // });
/// proxy.set_authorization(Basic {
/// username: "John Doe".into(),
/// password: Some("Agent1234".into()),
/// });
/// # Ok(())
/// # }
/// ```
@@ -111,6 +115,11 @@ impl Proxy {
Proxy::new(Intercept::Custom(fun.into()), url)
}
/// Set proxy authorization
pub fn set_authorization<S: Scheme + Any>(&mut self, scheme: S) {
self.inner.set_authorization(scheme);
}
/*
pub fn unix<P: AsRef<Path>(path: P) -> Proxy {