dont try to redirect if post body cannot be reset

This commit is contained in:
Sean McArthur
2016-11-28 11:36:42 -08:00
parent a54447c1d9
commit 3544e48e8e
3 changed files with 138 additions and 40 deletions

View File

@@ -115,3 +115,10 @@ pub fn as_hyper_body<'a>(body: &'a mut Body) -> ::hyper::client::Body<'a> {
}
}
}
pub fn can_reset(body: &Body) -> bool {
match body.reader {
Kind::Bytes(_) => true,
Kind::Reader(..) => false,
}
}

View File

@@ -213,7 +213,13 @@ impl<'a> RequestBuilder<'a> {
true
},
StatusCode::TemporaryRedirect |
StatusCode::PermanentRedirect => true,
StatusCode::PermanentRedirect => {
if let Some(ref body) = body {
body::can_reset(body)
} else {
true
}
},
_ => false,
};