Skip to content

Commit

Permalink
add a note to about redirects
Browse files Browse the repository at this point in the history
  • Loading branch information
seanmonstar committed Nov 29, 2016
1 parent 3544e48 commit 3632f2e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
11 changes: 11 additions & 0 deletions src/body.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,17 @@ pub struct Body {

impl Body {
/// Instantiate a `Body` from a reader.
///
/// # Note
///
/// While allowing for many types to be used, these bodies do not have
/// a way to reset to the beginning and be reused. This means that when
/// encountering a 307 or 308 status code, instead of repeating the
/// request at the new location, the `Response` will be returned with
/// the redirect status code set.
///
/// A `Body` constructed from a set of bytes, like `String` or `Vec<u8>`,
/// are stored differently and can be reused.
pub fn new<R: Read + 'static>(reader: R) -> Body {
Body {
reader: Kind::Reader(Box::new(reader), None),
Expand Down
7 changes: 2 additions & 5 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,11 +214,8 @@ impl<'a> RequestBuilder<'a> {
},
StatusCode::TemporaryRedirect |
StatusCode::PermanentRedirect => {
if let Some(ref body) = body {
body::can_reset(body)
} else {
true
}
body.map(body::can_reset)
.unwrap_or(true)
},
_ => false,
};
Expand Down

0 comments on commit 3632f2e

Please sign in to comment.