Move header name validity checks to compile time (#661)

This commit is contained in:
Jonas Platte 2021-12-27 18:25:47 +01:00 committed by GitHub
parent 7df611319e
commit a3e19465ac
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -215,13 +215,15 @@ impl WebSocketUpgrade {
callback(socket).await;
});
#[allow(clippy::declare_interior_mutable_const)]
const UPGRADE: HeaderValue = HeaderValue::from_static("upgrade");
#[allow(clippy::declare_interior_mutable_const)]
const WEBSOCKET: HeaderValue = HeaderValue::from_static("websocket");
let mut builder = Response::builder()
.status(StatusCode::SWITCHING_PROTOCOLS)
.header(
header::CONNECTION,
HeaderValue::from_str("upgrade").unwrap(),
)
.header(header::UPGRADE, HeaderValue::from_str("websocket").unwrap())
.header(header::CONNECTION, UPGRADE)
.header(header::UPGRADE, WEBSOCKET)
.header(
header::SEC_WEBSOCKET_ACCEPT,
sign(self.sec_websocket_key.as_bytes()),