Skip to content

Commit c32ee64

Browse files
hipstermojoFishrock123
authored andcommitted
Update base_url with each redirect of a full URL
1 parent 16a9ab9 commit c32ee64

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/middleware/redirect/mod.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ impl Middleware for Redirect {
9191
// and try sending it until we get some status back that is not a
9292
// redirect.
9393

94-
let base_url = req.url().clone();
94+
let mut base_url = req.url().clone();
9595

9696
while redirect_count < self.attempts {
9797
redirect_count += 1;
@@ -101,7 +101,10 @@ impl Middleware for Redirect {
101101
if let Some(location) = res.header(headers::LOCATION) {
102102
let http_req: &mut http::Request = req.as_mut();
103103
*http_req.url_mut() = match Url::parse(location.last().as_str()) {
104-
Ok(valid_url) => valid_url,
104+
Ok(valid_url) => {
105+
base_url = valid_url;
106+
base_url.clone()
107+
}
105108
Err(e) => match e {
106109
http::url::ParseError::RelativeUrlWithoutBase => {
107110
base_url.join(location.last().as_str())?

0 commit comments

Comments
 (0)