+ #[tokio::test]
+ async fn read_error() {
+ let response = String::from(
+ "HTTP/1.1 500 Internal Server Error\r\n\
+ Content-Length: 10\r\n\r\ntest error\r\n");
+ let server = HttpServer::responding_with(response);
+
+ let mut client = HttpClient::connect(&server.endpoint()).unwrap();
+ match client.get::<JsonResponse>("/foo", "foo.com").await {
+ Err(e) => {
+ assert_eq!(e.get_ref().unwrap().to_string(), "Errored with status: 500 and contents: test error");
+ assert_eq!(e.kind(), std::io::ErrorKind::Other);
+ },
+ Ok(_) => panic!("Expected error"),
+ }
+ }
+