add proxy authorization
This commit is contained in:
		
							
								
								
									
										17
									
								
								src/proxy.rs
									
									
									
									
									
								
							
							
						
						
									
										17
									
								
								src/proxy.rs
									
									
									
									
									
								
							| @@ -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 { | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user