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
pull/271/head
Daniel Abramov 2 years ago
parent 4e3e079131
commit 2171c997f5
  1. 6
      src/handshake/client.rs

@ -336,4 +336,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());
}
}

Loading…
Cancel
Save