Skip to content

Commit

Permalink
Implement Body::sized
Browse files Browse the repository at this point in the history
This is necessary for APIs such as BigML's, where we may need to send
extremely large request bodies, but chunked transfer encoding is not
supported.

This is a partial fix for #49.
  • Loading branch information
emk committed Feb 17, 2017
1 parent 1768981 commit 82f1877
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/body.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,17 @@ impl Body {
}
}

/*
pub fn sized(reader: (), len: u64) -> Body {
unimplemented!()
/// Create a `Body` from a `Reader` where we can predict the size in
/// advance, but where we don't want to load the data in memory. This
/// is useful if we need to ensure `Content-Length` is passed with the
/// request.
pub fn sized<R: Read + Send + 'static>(reader: R, len: u64) -> Body {
Body {
reader: Kind::Reader(Box::new(reader), Some(len)),
}
}

/*
pub fn chunked(reader: ()) -> Body {
unimplemented!()
}
Expand Down

0 comments on commit 82f1877

Please sign in to comment.