From 0806976a5eb404a1bdaa941ac076891b560a5bdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Mon, 21 Feb 2022 15:19:46 +0200 Subject: [PATCH] `HeaderName::from_static` requires all-lowercase HTTP2 compatible header names and was passed header names with uppercase characters instead, which made it panic. --- src/handshake/client.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/handshake/client.rs b/src/handshake/client.rs index 0f776a83..e1787c0c 100644 --- a/src/handshake/client.rs +++ b/src/handshake/client.rs @@ -114,7 +114,9 @@ fn generate_request(mut request: Request) -> Result<(Vec, String)> { .headers() .get(KEY_HEADERNAME) .ok_or_else(|| { - Error::Protocol(ProtocolError::InvalidHeader(HeaderName::from_static(KEY_HEADERNAME))) + Error::Protocol(ProtocolError::InvalidHeader( + HeaderName::from_bytes(KEY_HEADERNAME.as_bytes()).unwrap(), + )) })? .to_str()? .to_owned(); @@ -129,7 +131,9 @@ fn generate_request(mut request: Request) -> Result<(Vec, String)> { let headers = request.headers_mut(); for header in WEBSOCKET_HEADERS { let value = headers.remove(header).ok_or_else(|| { - Error::Protocol(ProtocolError::InvalidHeader(HeaderName::from_static(header))) + Error::Protocol(ProtocolError::InvalidHeader( + HeaderName::from_bytes(header.as_bytes()).unwrap(), + )) })?; write!(req, "{header}: {value}\r\n", header = header, value = value.to_str()?).unwrap(); }