mirror of
https://github.com/fafhrd91/actix-web
synced 2025-06-25 14:49:20 +02:00
use const header values where possible
This commit is contained in:
@ -52,9 +52,11 @@ where
|
||||
let _ = match length {
|
||||
BodySize::None => None,
|
||||
|
||||
BodySize::Sized(0) => req
|
||||
.headers_mut()
|
||||
.insert(CONTENT_LENGTH, HeaderValue::from_static("0")),
|
||||
BodySize::Sized(0) => {
|
||||
#[allow(clippy::declare_interior_mutable_const)]
|
||||
const HV_ZERO: HeaderValue = HeaderValue::from_static("0");
|
||||
req.headers_mut().insert(CONTENT_LENGTH, HV_ZERO)
|
||||
}
|
||||
|
||||
BodySize::Sized(len) => {
|
||||
let mut buf = itoa::Buffer::new();
|
||||
|
@ -300,13 +300,16 @@ impl WebsocketsRequest {
|
||||
}
|
||||
|
||||
self.head.set_connection_type(ConnectionType::Upgrade);
|
||||
|
||||
#[allow(clippy::declare_interior_mutable_const)]
|
||||
const HV_WEBSOCKET: HeaderValue = HeaderValue::from_static("websocket");
|
||||
self.head.headers.insert(header::UPGRADE, HV_WEBSOCKET);
|
||||
|
||||
#[allow(clippy::declare_interior_mutable_const)]
|
||||
const HV_THIRTEEN: HeaderValue = HeaderValue::from_static("13");
|
||||
self.head
|
||||
.headers
|
||||
.insert(header::UPGRADE, HeaderValue::from_static("websocket"));
|
||||
self.head.headers.insert(
|
||||
header::SEC_WEBSOCKET_VERSION,
|
||||
HeaderValue::from_static("13"),
|
||||
);
|
||||
.insert(header::SEC_WEBSOCKET_VERSION, HV_THIRTEEN);
|
||||
|
||||
if let Some(protocols) = self.protocols.take() {
|
||||
self.head.headers.insert(
|
||||
|
Reference in New Issue
Block a user