Skip to content

Commit

Permalink
HeaderName::from_static requires all-lowercase HTTP2 compatible hea…
Browse files Browse the repository at this point in the history
…der names

and was passed header names with uppercase characters instead, which
made it panic.
  • Loading branch information
sdroege authored and a-miyashita committed Jul 20, 2023
1 parent 0263e0d commit 0806976
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/handshake/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@ fn generate_request(mut request: Request) -> Result<(Vec<u8>, 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();
Expand All @@ -129,7 +131,9 @@ fn generate_request(mut request: Request) -> Result<(Vec<u8>, 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();
}
Expand Down

0 comments on commit 0806976

Please sign in to comment.