Fix some bugs!

This commit is contained in:
Omid Rad 2021-07-12 19:01:44 +02:00
parent 7eca42b6e3
commit ecabeb552f
1 changed files with 7 additions and 9 deletions

View File

@ -174,21 +174,20 @@ where
let next_uri = build_next_uri(&res, &prev_uri)?; let next_uri = build_next_uri(&res, &prev_uri)?;
// take ownership of states that could be reused // take ownership of states that could be reused
let body = body.take();
let addr = addr.take(); let addr = addr.take();
let connector = connector.take(); let connector = connector.take();
// reset method // reset method
let method = if is_redirect { let method = if is_redirect {
let method = method.take().unwrap(); method.take().unwrap()
match method { } else {
match method.take().unwrap() {
Method::GET | Method::HEAD => method, Method::GET | Method::HEAD => method,
_ => Method::GET, _ => Method::GET,
} }
} else {
method.take().unwrap()
}; };
let mut body = body.take();
let body_new = if is_redirect { let body_new = if is_redirect {
// try to reuse body // try to reuse body
match body { match body {
@ -197,6 +196,7 @@ where
_ => Body::Empty, _ => Body::Empty,
} }
} else { } else {
body = None;
// remove body // remove body
Body::None Body::None
}; };
@ -227,8 +227,7 @@ where
uri: Some(next_uri), uri: Some(next_uri),
method: Some(method), method: Some(method),
headers: Some(headers), headers: Some(headers),
// body is dropped on 301,302,303 body,
body: None,
addr, addr,
connector, connector,
}); });
@ -273,9 +272,8 @@ fn remove_sensitive_headers(headers: &mut header::HeaderMap, prev_uri: &Uri, nex
|| next_uri.port() != prev_uri.port() || next_uri.port() != prev_uri.port()
|| next_uri.scheme() != prev_uri.scheme() || next_uri.scheme() != prev_uri.scheme()
{ {
headers.remove(header::AUTHORIZATION);
headers.remove(header::WWW_AUTHENTICATE);
headers.remove(header::COOKIE); headers.remove(header::COOKIE);
headers.remove(header::AUTHORIZATION);
headers.remove(header::PROXY_AUTHORIZATION); headers.remove(header::PROXY_AUTHORIZATION);
} }
} }