cargo fmt (#604)

Run rustfmt and setup CI to check for it.
This commit is contained in:
danieleades
2019-08-29 17:52:39 +01:00
committed by Sean McArthur
parent 81e0f1ff2a
commit cf8944a0f0
41 changed files with 1399 additions and 1378 deletions

View File

@@ -1,13 +1,6 @@
use std::fmt;
use crate::header::{
HeaderMap,
AUTHORIZATION,
COOKIE,
PROXY_AUTHORIZATION,
WWW_AUTHENTICATE,
};
use crate::header::{HeaderMap, AUTHORIZATION, COOKIE, PROXY_AUTHORIZATION, WWW_AUTHENTICATE};
use hyper::StatusCode;
use crate::Url;
@@ -141,19 +134,13 @@ impl RedirectPolicy {
}
}
pub(crate) fn check(
&self,
status: StatusCode,
next: &Url,
previous: &[Url],
) -> Action {
self
.redirect(RedirectAttempt {
status,
next,
previous,
})
.inner
pub(crate) fn check(&self, status: StatusCode, next: &Url, previous: &[Url]) -> Action {
self.redirect(RedirectAttempt {
status,
next,
previous,
})
.inner
}
}
@@ -239,11 +226,10 @@ pub(crate) enum Action {
TooManyRedirects,
}
pub(crate) fn remove_sensitive_headers(headers: &mut HeaderMap, next: &Url, previous: &[Url]) {
if let Some(previous) = previous.last() {
let cross_host = next.host_str() != previous.host_str() ||
next.port_or_known_default() != previous.port_or_known_default();
let cross_host = next.host_str() != previous.host_str()
|| next.port_or_known_default() != previous.port_or_known_default();
if cross_host {
headers.remove(AUTHORIZATION);
headers.remove(COOKIE);
@@ -304,21 +290,15 @@ fn test_redirect_policy_custom() {
});
let next = Url::parse("http://bar/baz").unwrap();
assert_eq!(
policy.check(StatusCode::FOUND, &next, &[]),
Action::Follow
);
assert_eq!(policy.check(StatusCode::FOUND, &next, &[]), Action::Follow);
let next = Url::parse("http://foo/baz").unwrap();
assert_eq!(
policy.check(StatusCode::FOUND, &next, &[]),
Action::Stop
);
assert_eq!(policy.check(StatusCode::FOUND, &next, &[]), Action::Stop);
}
#[test]
fn test_remove_sensitive_headers() {
use hyper::header::{ACCEPT, AUTHORIZATION, COOKIE, HeaderValue};
use hyper::header::{HeaderValue, ACCEPT, AUTHORIZATION, COOKIE};
let mut headers = HeaderMap::new();
headers.insert(ACCEPT, HeaderValue::from_static("*/*"));