Filters sensitive headers when redirecting to a Location of different host than of the Referrer

Removes Cookie, Authorization and WWW-Authenticate cookies.

Resolves #10
This commit is contained in:
Steve Robinson
2017-05-11 18:27:40 +05:30
committed by Sean McArthur
parent 5a078cd1be
commit 21a28dffd1
2 changed files with 40 additions and 4 deletions

View File

@@ -16,7 +16,7 @@ use serde_json;
use serde_urlencoded;
use ::body::{self, Body};
use ::redirect::{self, RedirectPolicy, check_redirect};
use ::redirect::{self, RedirectPolicy, check_redirect, remove_sensitive_headers};
use ::response::Response;
static DEFAULT_USER_AGENT: &'static str = concat!(env!("CARGO_PKG_NAME"), "/", env!("CARGO_PKG_VERSION"));
@@ -167,7 +167,6 @@ fn new_hyper_client() -> ::Result<::hyper::Client> {
))
}
/// A builder to construct the properties of a `Request`.
pub struct RequestBuilder {
client: Arc<ClientRef>,
@@ -343,6 +342,7 @@ impl RequestBuilder {
}
urls.push(url);
let action = check_redirect(&client.redirect_policy.lock().unwrap(), &loc, &urls);
match action {
redirect::Action::Follow => loc,
redirect::Action::Stop => {
@@ -364,9 +364,8 @@ impl RequestBuilder {
}
};
headers = remove_sensitive_headers(headers, &url, &urls);
debug!("redirecting to {:?} '{}'", method, url);
//TODO: removeSensitiveHeaders(&mut headers, &url);
} else {
return Ok(::response::new(res, client.auto_ungzip.load(Ordering::Relaxed)))
}