Merge pull request #267 from sdroege/header-name-from-static-panic

`HeaderName::from_static` requires all-lowercase HTTP2
pull/271/head
Daniel Abramov 3 years ago committed by GitHub
commit 4e3e079131
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      src/handshake/client.rs

@ -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();
@ -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", value = value.to_str()?).unwrap();
}

Loading…
Cancel
Save