diff --git a/actix-http/CHANGES.md b/actix-http/CHANGES.md index a2d26d66e..a748bc43f 100644 --- a/actix-http/CHANGES.md +++ b/actix-http/CHANGES.md @@ -13,6 +13,8 @@ - Deadline methods in `ServiceConfig` now return `std::time::Instant`s instead of Tokio's wrapper type. [#2611] - Rename `h1::Codec::{keepalive => keep_alive}`. [#2611] - Rename `h1::Codec::{keepalive_enabled => keep_alive_enabled}`. [#2611] +- Rename `h1::ClientCodec::{keepalive => keep_alive}`. [#2611] +- Rename `h1::ClientPayloadCodec::{keepalive => keep_alive}`. [#2611] - `ServiceConfig::keep_alive` now returns a `KeepAlive`. [#2611] ### Fixed diff --git a/actix-http/src/h1/client.rs b/actix-http/src/h1/client.rs index fdb8e184c..4e0ae8f48 100644 --- a/actix-http/src/h1/client.rs +++ b/actix-http/src/h1/client.rs @@ -1,4 +1,4 @@ -use std::io; +use std::{fmt, io}; use actix_codec::{Decoder, Encoder}; use bitflags::bitflags; @@ -17,9 +17,9 @@ use crate::{ bitflags! { struct Flags: u8 { - const HEAD = 0b0000_0001; - const KEEPALIVE_ENABLED = 0b0000_1000; - const STREAM = 0b0001_0000; + const HEAD = 0b0000_0001; + const KEEP_ALIVE_ENABLED = 0b0000_1000; + const STREAM = 0b0001_0000; } } @@ -51,13 +51,21 @@ impl Default for ClientCodec { } } +impl fmt::Debug for ClientCodec { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("h1::ClientCodec") + .field("flags", &self.inner.flags) + .finish_non_exhaustive() + } +} + impl ClientCodec { /// Create HTTP/1 codec. /// /// `keepalive_enabled` how response `connection` header get generated. pub fn new(config: ServiceConfig) -> Self { let flags = if config.keep_alive().enabled() { - Flags::KEEPALIVE_ENABLED + Flags::KEEP_ALIVE_ENABLED } else { Flags::empty() }; @@ -82,7 +90,7 @@ impl ClientCodec { } /// Check if last response is keep-alive - pub fn keepalive(&self) -> bool { + pub fn keep_alive(&self) -> bool { self.inner.conn_type == ConnectionType::KeepAlive } @@ -105,7 +113,7 @@ impl ClientCodec { impl ClientPayloadCodec { /// Check if last response is keep-alive - pub fn keepalive(&self) -> bool { + pub fn keep_alive(&self) -> bool { self.inner.conn_type == ConnectionType::KeepAlive } @@ -195,7 +203,7 @@ impl Encoder> for ClientCodec { // connection status inner.conn_type = match head.as_ref().connection_type() { ConnectionType::KeepAlive => { - if inner.flags.contains(Flags::KEEPALIVE_ENABLED) { + if inner.flags.contains(Flags::KEEP_ALIVE_ENABLED) { ConnectionType::KeepAlive } else { ConnectionType::Close diff --git a/actix-http/src/h1/codec.rs b/actix-http/src/h1/codec.rs index f1ef9a54e..df74bcc42 100644 --- a/actix-http/src/h1/codec.rs +++ b/actix-http/src/h1/codec.rs @@ -42,7 +42,9 @@ impl Default for Codec { impl fmt::Debug for Codec { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.debug_struct("h1::Codec").finish_non_exhaustive() + f.debug_struct("h1::Codec") + .field("flags", &self.flags) + .finish_non_exhaustive() } } diff --git a/actix-http/src/h2/dispatcher.rs b/actix-http/src/h2/dispatcher.rs index 7e222d61b..7a11f9b33 100644 --- a/actix-http/src/h2/dispatcher.rs +++ b/actix-http/src/h2/dispatcher.rs @@ -60,7 +60,7 @@ where let ping_pong = config.keep_alive().duration().map(|dur| H2PingPong { timer: timer .map(|mut timer| { - // reuse timer slot if it was used for handshake + // reuse timer slot if it was initialized for handshake timer.as_mut().reset((config.now() + dur).into()); timer })