diff --git a/actix-http/src/h1/decoder.rs b/actix-http/src/h1/decoder.rs index 492783315..49aac333c 100644 --- a/actix-http/src/h1/decoder.rs +++ b/actix-http/src/h1/decoder.rs @@ -1037,7 +1037,7 @@ mod tests { } #[test] - fn test_http_request_upgrade() { + fn test_http_request_upgrade_websocket() { let mut buf = BytesMut::from( "GET /test HTTP/1.1\r\n\ connection: upgrade\r\n\ @@ -1051,6 +1051,26 @@ mod tests { assert!(pl.is_unhandled()); } + #[test] + fn test_http_request_upgrade_h2c() { + let mut buf = BytesMut::from( + "GET /test HTTP/1.1\r\n\ + connection: upgrade, http2-settings\r\n\ + upgrade: h2c\r\n\ + http2-settings: dummy\r\n\r\n", + ); + let mut reader = MessageDecoder::::default(); + let (req, pl) = reader.decode(&mut buf).unwrap().unwrap(); + // `connection: upgrade, http2-settings` doesn't work properly.. + // see MessageType::set_headers(). + // + // The line below should be: + // assert_eq!(req.head().connection_type(), ConnectionType::Upgrade); + assert_eq!(req.head().connection_type(), ConnectionType::KeepAlive); + assert!(req.upgrade()); + assert!(!pl.is_unhandled()); + } + #[test] fn test_http_request_parser_utf8() { let mut buf = BytesMut::from(