fix(client): fix panics when some errors occured inside HttpMessage

BREAKING CHANGE: This changes the signature of HttpWriter.end(),
  returning a `EndError` that is similar to std::io::IntoInnerError,
  allowing HttpMessage to retrieve the broken connections and not panic.

  The breaking change isn't exposed in any usage of the `Client` API,
  but for anyone using `HttpWriter` directly, since this was technically
  a public method, that change is breaking.
This commit is contained in:
Sean McArthur
2015-08-27 15:43:22 -07:00
parent 4f672fe744
commit ef15257b73
2 changed files with 112 additions and 62 deletions

View File

@@ -226,4 +226,14 @@ mod tests {
assert_eq!(read_to_string(res).unwrap(), "1".to_owned());
}
#[test]
fn test_parse_error_closes() {
let url = Url::parse("http://hyper.rs").unwrap();
let stream = MockStream::with_input(b"\
definitely not http
");
assert!(Response::new(url, Box::new(stream)).is_err());
}
}