feat(http): allow specifying custom body streams

This commit is contained in:
Sean McArthur
2017-02-16 12:39:50 -08:00
parent 2266d869ca
commit 1b1311a7d3
11 changed files with 384 additions and 276 deletions

View File

@@ -133,6 +133,23 @@ pub trait Http1Transaction {
type ParseResult<T> = ::Result<Option<(MessageHead<T>, usize)>>;
struct DebugTruncate<'a>(&'a [u8]);
impl<'a> fmt::Debug for DebugTruncate<'a> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let bytes = self.0;
if bytes.len() > 32 {
try!(f.write_str("["));
for byte in &bytes[..32] {
try!(write!(f, "{:?}, ", byte));
}
write!(f, "... {}]", bytes.len())
} else {
fmt::Debug::fmt(bytes, f)
}
}
}
#[test]
fn test_should_keep_alive() {
let mut headers = Headers::new();