diff --git a/src/http/io.rs b/src/http/io.rs index 337c60dc..dd82bc04 100644 --- a/src/http/io.rs +++ b/src/http/io.rs @@ -72,7 +72,8 @@ impl Buffered { match self.read_from_io() { Ok(0) => { trace!("parse eof"); - return Err(io::Error::new(io::ErrorKind::UnexpectedEof, "parse eof").into()); + //TODO: With Rust 1.14, this can be Error::from(ErrorKind) + return Err(io::Error::new(io::ErrorKind::UnexpectedEof, ParseEof).into()); } Ok(_) => {}, Err(e) => match e.kind() { @@ -316,6 +317,21 @@ impl WriteBuf { } } +#[derive(Debug)] +struct ParseEof; + +impl fmt::Display for ParseEof { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.write_str("parse eof") + } +} + +impl ::std::error::Error for ParseEof { + fn description(&self) -> &str { + "parse eof" + } +} + #[cfg(test)] use std::io::Read;