From dd5c1c15316c5cb38c638a7efe55b31e7ce49e8a Mon Sep 17 00:00:00 2001 From: Daniel Abramov Date: Mon, 21 Feb 2022 15:37:13 +0100 Subject: [PATCH] test: add a unit test for invalid `http::Request` This is to make sure that we don't panic anymore in such cases: https://github.com/snapview/tungstenite-rs/pull/267 --- src/handshake/client.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/handshake/client.rs b/src/handshake/client.rs index e1787c0c..add5808d 100644 --- a/src/handshake/client.rs +++ b/src/handshake/client.rs @@ -338,4 +338,10 @@ mod tests { assert_eq!(resp.status(), http::StatusCode::OK); assert_eq!(resp.headers().get("Content-Type").unwrap(), &b"text/html"[..],); } + + #[test] + fn invalid_custom_request() { + let request = http::Request::builder().method("GET").body(()).unwrap(); + assert!(generate_request(request).is_err()); + } }