1
0
mirror of https://github.com/fafhrd91/actix-web synced 2025-06-25 22:49:21 +02:00

Various refactorings (#2281)

Co-authored-by: Rob Ede <robjtede@icloud.com>
This commit is contained in:
Igor Aleksanov
2021-06-26 18:33:43 +04:00
committed by GitHub
parent 5eba95b731
commit 262c6bc828
30 changed files with 98 additions and 121 deletions

View File

@ -85,7 +85,7 @@ impl Connector<()> {
use bytes::{BufMut, BytesMut};
let mut alpn = BytesMut::with_capacity(20);
for proto in protocols.iter() {
for proto in &protocols {
alpn.put_u8(proto.len() as u8);
alpn.put(proto.as_slice());
}
@ -290,8 +290,7 @@ where
let h2 = sock
.ssl()
.selected_alpn_protocol()
.map(|protos| protos.windows(2).any(|w| w == H2))
.unwrap_or(false);
.map_or(false, |protos| protos.windows(2).any(|w| w == H2));
if h2 {
(Box::new(sock), Protocol::Http2)
} else {
@ -325,8 +324,7 @@ where
.get_ref()
.1
.get_alpn_protocol()
.map(|protos| protos.windows(2).any(|w| w == H2))
.unwrap_or(false);
.map_or(false, |protos| protos.windows(2).any(|w| w == H2));
if h2 {
(Box::new(sock), Protocol::Http2)
} else {