refactor(lib): resolve unused warnings from server-specific code (#2710)

This commit is contained in:
Sean McArthur
2021-11-30 10:26:20 -08:00
committed by GitHub
parent 7435cc3399
commit ce8242571f
5 changed files with 8 additions and 4 deletions

View File

@@ -71,6 +71,7 @@ pub(super) enum Parse {
#[cfg(feature = "http1")]
VersionH2,
Uri,
#[cfg_attr(not(all(feature = "http1", feature = "server")), allow(unused))]
UriTooLong,
Header(Header),
TooLarge,

View File

@@ -1,6 +1,7 @@
use std::fmt;
use std::io;
use std::marker::PhantomData;
#[cfg(all(feature = "server", feature = "runtime"))]
use std::time::Duration;
use bytes::{Buf, Bytes};

View File

@@ -3,6 +3,7 @@ use std::fmt;
use std::io::{self, IoSlice};
use std::marker::Unpin;
use std::mem::MaybeUninit;
#[cfg(all(feature = "server", feature = "runtime"))]
use std::future::Future;
#[cfg(all(feature = "server", feature = "runtime"))]
use std::time::Duration;
@@ -11,7 +12,7 @@ use std::time::Duration;
use tokio::time::Instant;
use bytes::{Buf, BufMut, Bytes, BytesMut};
use tokio::io::{AsyncRead, AsyncWrite, ReadBuf};
use tracing::{debug, warn, trace};
use tracing::{debug, trace};
use super::{Http1Transaction, ParseContext, ParsedMessage};
use crate::common::buf::BufList;
@@ -227,7 +228,7 @@ where
if Pin::new( h1_header_read_timeout_fut).poll(cx).is_ready() {
*parse_ctx.h1_header_read_timeout_running = false;
warn!("read header from client timeout");
tracing::warn!("read header from client timeout");
return Poll::Ready(Err(crate::Error::new_header_timeout()))
}
}

View File

@@ -1,5 +1,5 @@
use std::pin::Pin;
use std::time::Duration;
#[cfg(all(feature = "server", feature = "runtime"))]
use std::{pin::Pin, time::Duration};
use bytes::BytesMut;
use http::{HeaderMap, Method};

View File

@@ -25,6 +25,7 @@ use crate::proto::{BodyLength, MessageHead, RequestHead, RequestLine};
const MAX_HEADERS: usize = 100;
const AVERAGE_HEADER_SIZE: usize = 30; // totally scientific
#[cfg(feature = "server")]
const MAX_URI_LEN: usize = (u16::MAX - 1) as usize;
macro_rules! header_name {