diff --git a/actix-http/src/h1/client.rs b/actix-http/src/h1/client.rs index bea629c4f..bcfc18cde 100644 --- a/actix-http/src/h1/client.rs +++ b/actix-http/src/h1/client.rs @@ -1,13 +1,8 @@ -#![allow(unused_imports, unused_variables, dead_code)] -use std::io::{self, Write}; -use std::rc::Rc; +use std::io; use actix_codec::{Decoder, Encoder}; use bitflags::bitflags; -use bytes::{BufMut, Bytes, BytesMut}; -use http::header::{ - HeaderValue, CONNECTION, CONTENT_LENGTH, DATE, TRANSFER_ENCODING, UPGRADE, -}; +use bytes::{Bytes, BytesMut}; use http::{Method, Version}; use super::decoder::{PayloadDecoder, PayloadItem, PayloadType}; @@ -16,11 +11,7 @@ use super::{Message, MessageType}; use crate::body::BodySize; use crate::config::ServiceConfig; use crate::error::{ParseError, PayloadError}; -use crate::header::HeaderMap; -use crate::helpers; -use crate::message::{ - ConnectionType, Head, MessagePool, RequestHead, RequestHeadType, ResponseHead, -}; +use crate::message::{ConnectionType, RequestHeadType, ResponseHead}; bitflags! { struct Flags: u8 { @@ -30,8 +21,6 @@ bitflags! { } } -const AVERAGE_HEADER_SIZE: usize = 30; - /// HTTP/1 Codec pub struct ClientCodec { inner: ClientCodecInner, @@ -51,7 +40,6 @@ struct ClientCodecInner { // encoder part flags: Flags, - headers_size: u32, encoder: encoder::MessageEncoder, } @@ -80,7 +68,6 @@ impl ClientCodec { ctype: ConnectionType::Close, flags, - headers_size: 0, encoder: encoder::MessageEncoder::default(), }, } diff --git a/actix-http/src/h1/codec.rs b/actix-http/src/h1/codec.rs index 726d1c97f..5b75a4e56 100644 --- a/actix-http/src/h1/codec.rs +++ b/actix-http/src/h1/codec.rs @@ -1,12 +1,9 @@ -#![allow(unused_imports, unused_variables, dead_code)] -use std::io::Write; -use std::{fmt, io, net}; +use std::{fmt, io}; use actix_codec::{Decoder, Encoder}; use bitflags::bitflags; -use bytes::{BufMut, Bytes, BytesMut}; -use http::header::{HeaderValue, CONNECTION, CONTENT_LENGTH, DATE, TRANSFER_ENCODING}; -use http::{Method, StatusCode, Version}; +use bytes::BytesMut; +use http::{Method, Version}; use super::decoder::{PayloadDecoder, PayloadItem, PayloadType}; use super::{decoder, encoder}; @@ -14,8 +11,7 @@ use super::{Message, MessageType}; use crate::body::BodySize; use crate::config::ServiceConfig; use crate::error::ParseError; -use crate::helpers; -use crate::message::{ConnectionType, Head, ResponseHead}; +use crate::message::ConnectionType; use crate::request::Request; use crate::response::Response; @@ -27,8 +23,6 @@ bitflags! { } } -const AVERAGE_HEADER_SIZE: usize = 30; - /// HTTP/1 Codec pub struct Codec { config: ServiceConfig, @@ -176,7 +170,6 @@ impl Encoder for Codec { }; // encode message - let len = dst.len(); self.encoder.encode( dst, &mut res, diff --git a/actix-http/src/h1/encoder.rs b/actix-http/src/h1/encoder.rs index e474d4f81..c3426c6e0 100644 --- a/actix-http/src/h1/encoder.rs +++ b/actix-http/src/h1/encoder.rs @@ -1,25 +1,18 @@ -#![allow(unused_imports, unused_variables, dead_code)] -use std::fmt::Write as FmtWrite; use std::io::Write; use std::marker::PhantomData; use std::ptr::copy_nonoverlapping; -use std::rc::Rc; use std::slice::from_raw_parts_mut; -use std::str::FromStr; -use std::{cmp, fmt, io, mem}; +use std::{cmp, io}; -use bytes::{buf::BufMutExt, BufMut, Bytes, BytesMut}; +use bytes::{buf::BufMutExt, BufMut, BytesMut}; use crate::body::BodySize; use crate::config::ServiceConfig; -use crate::header::{map, ContentEncoding}; +use crate::header::map; use crate::helpers; -use crate::http::header::{ - HeaderValue, ACCEPT_ENCODING, CONNECTION, CONTENT_LENGTH, DATE, TRANSFER_ENCODING, -}; -use crate::http::{HeaderMap, Method, StatusCode, Version}; -use crate::message::{ConnectionType, Head, RequestHead, RequestHeadType, ResponseHead}; -use crate::request::Request; +use crate::http::header::{CONNECTION, CONTENT_LENGTH, DATE, TRANSFER_ENCODING}; +use crate::http::{HeaderMap, StatusCode, Version}; +use crate::message::{ConnectionType, RequestHeadType}; use crate::response::Response; const AVERAGE_HEADER_SIZE: usize = 30; diff --git a/actix-http/src/h2/dispatcher.rs b/actix-http/src/h2/dispatcher.rs index b827762cb..a4ec15fab 100644 --- a/actix-http/src/h2/dispatcher.rs +++ b/actix-http/src/h2/dispatcher.rs @@ -1,28 +1,23 @@ -use std::collections::VecDeque; use std::convert::TryFrom; use std::future::Future; use std::marker::PhantomData; +use std::net; use std::pin::Pin; use std::task::{Context, Poll}; -use std::{fmt, mem, net}; use actix_codec::{AsyncRead, AsyncWrite}; use actix_rt::time::{Delay, Instant}; use actix_service::Service; -use bitflags::bitflags; use bytes::{Bytes, BytesMut}; -use futures::{ready, Sink, Stream}; use h2::server::{Connection, SendResponse}; -use h2::{RecvStream, SendStream}; -use http::header::{ - HeaderValue, ACCEPT_ENCODING, CONNECTION, CONTENT_LENGTH, DATE, TRANSFER_ENCODING, -}; -use log::{debug, error, trace}; +use h2::SendStream; +use http::header::{HeaderValue, CONNECTION, CONTENT_LENGTH, DATE, TRANSFER_ENCODING}; +use log::{error, trace}; -use crate::body::{Body, BodySize, MessageBody, ResponseBody}; +use crate::body::{BodySize, MessageBody, ResponseBody}; use crate::cloneable::CloneableService; use crate::config::ServiceConfig; -use crate::error::{DispatchError, Error, ParseError, PayloadError, ResponseError}; +use crate::error::{DispatchError, Error}; use crate::helpers::DataFactory; use crate::httpmessage::HttpMessage; use crate::message::ResponseHead; diff --git a/actix-http/src/h2/mod.rs b/actix-http/src/h2/mod.rs index 21080c69a..6ba29bbcf 100644 --- a/actix-http/src/h2/mod.rs +++ b/actix-http/src/h2/mod.rs @@ -1,6 +1,4 @@ -#![allow(dead_code, unused_imports)] -use std::fmt; -use std::future::Future; +//! HTTP/2 implementation use std::pin::Pin; use std::task::{Context, Poll}; diff --git a/actix-http/src/h2/service.rs b/actix-http/src/h2/service.rs index da2499345..91d721baf 100644 --- a/actix-http/src/h2/service.rs +++ b/actix-http/src/h2/service.rs @@ -1,32 +1,28 @@ -use std::fmt::Debug; use std::future::Future; use std::marker::PhantomData; use std::pin::Pin; use std::task::{Context, Poll}; -use std::{io, net, rc}; +use std::{net, rc}; -use actix_codec::{AsyncRead, AsyncWrite, Framed}; +use actix_codec::{AsyncRead, AsyncWrite}; use actix_rt::net::TcpStream; use actix_service::{ fn_factory, fn_service, pipeline_factory, IntoServiceFactory, Service, ServiceFactory, }; use bytes::Bytes; -use futures::future::{ok, Ready}; -use futures::{ready, Stream}; -use h2::server::{self, Connection, Handshake}; -use h2::RecvStream; +use futures::future::ok; +use futures::ready; +use h2::server::{self, Handshake}; use log::error; use crate::body::MessageBody; use crate::cloneable::CloneableService; -use crate::config::{KeepAlive, ServiceConfig}; -use crate::error::{DispatchError, Error, ParseError, ResponseError}; +use crate::config::ServiceConfig; +use crate::error::{DispatchError, Error}; use crate::helpers::DataFactory; -use crate::payload::Payload; use crate::request::Request; use crate::response::Response; -use crate::Protocol; use super::dispatcher::Dispatcher; diff --git a/actix-http/src/lib.rs b/actix-http/src/lib.rs index b682e5aa5..7a47012f8 100644 --- a/actix-http/src/lib.rs +++ b/actix-http/src/lib.rs @@ -4,8 +4,7 @@ clippy::type_complexity, clippy::too_many_arguments, clippy::new_without_default, - clippy::borrow_interior_mutable_const, -// clippy::write_with_newline + clippy::borrow_interior_mutable_const )] #[macro_use]