committed by
Sean McArthur
parent
9e70497781
commit
a54447c1d9
@@ -198,24 +198,32 @@ impl<'a> RequestBuilder<'a> {
|
|||||||
|
|
||||||
try!(req.send())
|
try!(req.send())
|
||||||
};
|
};
|
||||||
body.take();
|
|
||||||
|
|
||||||
match res.status {
|
let should_redirect = match res.status {
|
||||||
StatusCode::MovedPermanently |
|
StatusCode::MovedPermanently |
|
||||||
StatusCode::Found |
|
StatusCode::Found |
|
||||||
StatusCode::SeeOther => {
|
StatusCode::SeeOther => {
|
||||||
|
body = None;
|
||||||
|
match method {
|
||||||
|
Method::Get | Method::Head => {},
|
||||||
|
_ => {
|
||||||
|
method = Method::Get;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
true
|
||||||
|
},
|
||||||
|
StatusCode::TemporaryRedirect |
|
||||||
|
StatusCode::PermanentRedirect => true,
|
||||||
|
_ => false,
|
||||||
|
};
|
||||||
|
|
||||||
|
if should_redirect {
|
||||||
//TODO: turn this into self.redirect_policy.check()
|
//TODO: turn this into self.redirect_policy.check()
|
||||||
if redirect_count > 10 {
|
if redirect_count > 10 {
|
||||||
return Err(::Error::TooManyRedirects);
|
return Err(::Error::TooManyRedirects);
|
||||||
}
|
}
|
||||||
redirect_count += 1;
|
redirect_count += 1;
|
||||||
|
|
||||||
method = match method {
|
|
||||||
Method::Post | Method::Put => Method::Get,
|
|
||||||
m => m
|
|
||||||
};
|
|
||||||
|
|
||||||
headers.set(Referer(url.to_string()));
|
headers.set(Referer(url.to_string()));
|
||||||
|
|
||||||
let loc = {
|
let loc = {
|
||||||
@@ -239,12 +247,10 @@ impl<'a> RequestBuilder<'a> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
debug!("redirecting to '{}'", url);
|
debug!("redirecting to {:?} '{}'", method, url);
|
||||||
|
|
||||||
//TODO: removeSensitiveHeaders(&mut headers, &url);
|
//TODO: removeSensitiveHeaders(&mut headers, &url);
|
||||||
|
} else {
|
||||||
},
|
|
||||||
_ => {
|
|
||||||
return Ok(Response {
|
return Ok(Response {
|
||||||
inner: res
|
inner: res
|
||||||
});
|
});
|
||||||
@@ -252,7 +258,6 @@ impl<'a> RequestBuilder<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/// A Response to a submitted `Request`.
|
/// A Response to a submitted `Request`.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
|||||||
Reference in New Issue
Block a user