This commit is contained in:
nora 2023-03-07 16:55:48 +01:00
parent dd3b3980bf
commit b4e7136ad9
9 changed files with 93 additions and 271 deletions

View file

@ -3,22 +3,22 @@ use std::fmt;
use std::time::Duration;
use futures_util::future::{self, Either, FutureExt as _, TryFutureExt as _};
use futures_util::future::{Either};
use super::conn;
use super::connect::{self, sealed::Connect, Alpn, Connected, Connection};
use super::pool::{self, Key as PoolKey, Pool, Poolable, Pooled, Reservation};
use super::connect::{sealed::Connect, Connected};
use super::pool::{self, Key as PoolKey, Pool, Poolable, Reservation};
#[cfg(feature = "tcp")]
use super::HttpConnector;
use crate::body::{Body, HttpBody};
use crate::common::{
exec::BoxSendFuture, lazy as hyper_lazy, sync_wrapper::SyncWrapper, task, Future, Lazy, Pin,
exec::BoxSendFuture, sync_wrapper::SyncWrapper, task, Future, Pin,
Poll,
};
use crate::rt::Executor;
use http::uri::{Port, Scheme};
use http::{Request, Response, Uri, Version};
use tracing::{debug, trace};
#[cfg_attr(docsrs, doc(cfg(any(feature = "http1", feature = "http2"))))]
pub struct Client<C, B = Body> {

View file

@ -1,5 +1,4 @@
#[cfg(all(feature = "server", any(feature = "http1", feature = "http2")))]
use crate::body::Body;
#[cfg(feature = "server")]
use crate::body::HttpBody;
#[cfg(all(feature = "http2", feature = "server"))]

View file

@ -82,7 +82,6 @@ pub(super) enum Header {
}
#[derive(Debug)]
pub(super) enum User {
#[cfg(any(feature = "http1", feature = "http2"))]
Body,
@ -95,8 +94,6 @@ pub(super) enum User {
#[cfg(any(feature = "http1", feature = "http2"))]
Service,
#[cfg(any(feature = "http1", feature = "http2"))]
#[cfg(feature = "server")]
UnexpectedHeader,
@ -134,7 +131,6 @@ pub(super) enum User {
#[derive(Debug)]
pub(super) struct TimedOut;
impl Error {
pub(crate) fn is_parse(&self) -> bool {
loop {}
}
@ -143,7 +139,6 @@ impl Error {
loop {}
}
pub(crate) fn is_parse_status(&self) -> bool {
loop {}
}

View file

@ -13,17 +13,12 @@ use std::fmt;
mod h1_reason_phrase;
#[cfg(feature = "http2")]
#[derive(Clone, Eq, PartialEq)]
pub(crate) struct Protocol {
inner: h2::ext::Protocol,
}
#[cfg(feature = "http2")]
impl Protocol {
pub(crate) const fn from_static(value: &'static str) -> Self {
loop {}
}
@ -57,33 +52,11 @@ impl fmt::Debug for Protocol {
loop {}
}
}
#[derive(Clone, Debug)]
pub(crate) struct HeaderCaseMap(HeaderMap<Bytes>);
#[cfg(feature = "http1")]
impl HeaderCaseMap {
pub(crate) fn get_all<'a>(
&'a self,
name: &HeaderName,
@ -91,11 +64,7 @@ impl HeaderCaseMap {
self.get_all_internal(name).into_iter()
}
pub(crate) fn get_all_internal<'a>(
&'a self,
name: &HeaderName,
) -> ValueIter<'_, Bytes> {
pub(crate) fn get_all_internal<'a>(&'a self, name: &HeaderName) -> ValueIter<'_, Bytes> {
loop {}
}
pub(crate) fn default() -> Self {
@ -116,14 +85,8 @@ impl HeaderCaseMap {
#[derive(Clone, Debug)]
pub(crate) struct OriginalHeaderOrder {
num_entries: HashMap<HeaderName, usize>,
entry_order: Vec<(HeaderName, usize)>,
}
#[cfg(all(feature = "http1", feature = "ffi"))]
@ -141,42 +104,6 @@ impl OriginalHeaderOrder {
loop {}
}
pub(crate) fn get_in_order(&self) -> impl Iterator<Item = &(HeaderName, usize)> {
loop {}
}

View file

@ -1,2 +1,2 @@
use std::convert::TryFrom;
use bytes::Bytes;

View file

@ -1,57 +1,4 @@
use http::header::{HeaderValue, ValueIter};
use http::HeaderMap;
#[cfg(all(feature = "http2", feature = "client"))]
use http::Method;
#[cfg(feature = "http1")]
pub(super) fn connection_keep_alive(value: &HeaderValue) -> bool {
loop {}
}
#[cfg(feature = "http1")]
pub(super) fn connection_close(value: &HeaderValue) -> bool {
loop {}
}
#[cfg(feature = "http1")]
fn connection_has(value: &HeaderValue, needle: &str) -> bool {
loop {}
}
#[cfg(all(feature = "http1", feature = "server"))]
pub(super) fn content_length_parse(value: &HeaderValue) -> Option<u64> {
loop {}
}
pub(super) fn content_length_parse_all(headers: &HeaderMap) -> Option<u64> {
loop {}
}
pub(super) fn content_length_parse_all_values(
values: ValueIter<'_, HeaderValue>,
) -> Option<u64> {
loop {}
}
fn from_digits(bytes: &[u8]) -> Option<u64> {
loop {}
}
#[cfg(all(feature = "http2", feature = "client"))]
pub(super) fn method_has_defined_payload_semantics(method: &Method) -> bool {
loop {}
}
#[cfg(feature = "http2")]
pub(super) fn set_content_length_if_missing(headers: &mut HeaderMap, len: u64) {
loop {}
}
#[cfg(feature = "http1")]
pub(super) fn transfer_encoding_is_chunked(headers: &HeaderMap) -> bool {
loop {}
}
#[cfg(feature = "http1")]
pub(super) fn is_chunked(mut encodings: ValueIter<'_, HeaderValue>) -> bool {
loop {}
}
#[cfg(feature = "http1")]
pub(super) fn is_chunked_(value: &HeaderValue) -> bool {
loop {}
}
#[cfg(feature = "http1")]
pub(super) fn add_chunked(mut entry: http::header::OccupiedEntry<'_, HeaderValue>) {
loop {}
}

View file

@ -3,15 +3,14 @@ use super::accept::Accept;
use super::conn::Http as Http_;
#[cfg(all(feature = "tcp"))]
use super::tcp::AddrIncoming;
use crate::body::{Body, HttpBody};
use crate::body::{Body};
use crate::common::exec::Exec;
use crate::common::exec::{ConnStreamExec, NewSvcExec};
use crate::common::{task, Future, Pin, Poll, Unpin};
use crate::common::exec::{NewSvcExec};
use crate::common::{task, Future, Pin, Poll};
use crate::service::{HttpService, MakeServiceRef};
use pin_project_lite::pin_project;
use std::error::Error as StdError;
#[cfg(feature = "tcp")]
use tokio::io::{AsyncRead, AsyncWrite};
pub struct Server<I, S, E = Exec> {
incoming: I,
make_service: S,
@ -91,7 +90,7 @@ where
}
pub(crate) mod new_svc {
use super::Watcher;
use crate::body::{Body, HttpBody};
use crate::body::{Body};
use crate::common::exec::ConnStreamExec;
use crate::common::{task, Future, Pin, Poll};
use crate::service::HttpService;

View file

@ -1,14 +1,14 @@
use std::fmt;
use std::io;
use std::net::{SocketAddr, TcpListener as StdTcpListener};
use std::net::SocketAddr;
use std::time::Duration;
use socket2::TcpKeepalive;
use tokio::net::TcpListener;
use tokio::time::Sleep;
use crate::common::{task, Pin, Poll};
#[allow(unreachable_pub)]
pub use self::addr_stream::AddrStream;
use super::accept::Accept;
use crate::common::{task, Pin, Poll};
use tokio::net::TcpListener;
use tokio::time::Sleep;
#[derive(Default, Debug, Clone, Copy)]
struct TcpKeepaliveConfig {
time: Option<Duration>,
@ -16,54 +16,38 @@ struct TcpKeepaliveConfig {
retries: Option<u32>,
}
impl TcpKeepaliveConfig {
#[cfg(
not(
any(
target_os = "android",
target_os = "dragonfly",
target_os = "freebsd",
target_os = "fuchsia",
target_os = "illumos",
target_os = "linux",
target_os = "netbsd",
target_vendor = "apple",
windows,
)
)
)]
#[cfg(not(any(
target_os = "android",
target_os = "dragonfly",
target_os = "freebsd",
target_os = "fuchsia",
target_os = "illumos",
target_os = "linux",
target_os = "netbsd",
target_vendor = "apple",
windows,
)))]
fn ka_with_interval(ka: TcpKeepalive, _: Duration, _: &mut bool) -> TcpKeepalive {
loop {}
}
#[cfg(
not(
any(
target_os = "android",
target_os = "dragonfly",
target_os = "freebsd",
target_os = "fuchsia",
target_os = "illumos",
target_os = "linux",
target_os = "netbsd",
target_vendor = "apple",
)
)
)]
#[cfg(not(any(
target_os = "android",
target_os = "dragonfly",
target_os = "freebsd",
target_os = "fuchsia",
target_os = "illumos",
target_os = "linux",
target_os = "netbsd",
target_vendor = "apple",
)))]
fn ka_with_retries(ka: TcpKeepalive, _: u32, _: &mut bool) -> TcpKeepalive {
loop {}
}
}
#[must_use = "streams do nothing unless polled"]
pub struct AddrIncoming {
addr: SocketAddr,
listener: TcpListener,
sleep_on_errors: bool,
tcp_keepalive_config: TcpKeepaliveConfig,
tcp_nodelay: bool,
timeout: Option<Pin<Box<Sleep>>>,
}
pub struct AddrIncoming {}
impl AddrIncoming {
pub fn bind(addr: &SocketAddr) -> crate::Result<Self> {
loop {}
}
@ -92,13 +76,13 @@ impl fmt::Debug for AddrIncoming {
}
}
mod addr_stream {
use crate::common::{task, Pin, Poll};
use std::io;
use std::net::SocketAddr;
#[cfg(unix)]
use std::os::unix::io::{AsRawFd, RawFd};
use tokio::io::{AsyncRead, AsyncWrite, ReadBuf};
use tokio::net::TcpStream;
use crate::common::{task, Pin, Poll};
pin_project_lite::pin_project! {
#[doc = " A transport returned yieled by `AddrIncoming`."] #[derive(Debug)] pub
struct AddrStream { #[pin] inner : TcpStream, pub (super) remote_addr :
@ -133,17 +117,11 @@ mod addr_stream {
loop {}
}
#[inline]
fn poll_flush(
self: Pin<&mut Self>,
_cx: &mut task::Context<'_>,
) -> Poll<io::Result<()>> {
fn poll_flush(self: Pin<&mut Self>, _cx: &mut task::Context<'_>) -> Poll<io::Result<()>> {
loop {}
}
#[inline]
fn poll_shutdown(
self: Pin<&mut Self>,
cx: &mut task::Context<'_>,
) -> Poll<io::Result<()>> {
fn poll_shutdown(self: Pin<&mut Self>, cx: &mut task::Context<'_>) -> Poll<io::Result<()>> {
loop {}
}
#[inline]

View file

@ -1,26 +1,9 @@
use std::error::Error as StdError;
use std::fmt;
use std::marker::PhantomData;
use crate::body::HttpBody;
use crate::common::{task, Future, Poll};
use crate::{Request, Response};
use std::error::Error as StdError;
use std::fmt;
use std::marker::PhantomData;
pub fn service_fn<F, R, S>(f: F) -> ServiceFn<F, R>
where
@ -35,7 +18,7 @@ pub struct ServiceFn<F, R> {
_req: PhantomData<fn(R)>,
}
impl<F, ReqBody, Ret, ResBody, E> tower_service::Service<crate::Request<ReqBody>>
for ServiceFn<F, ReqBody>
for ServiceFn<F, ReqBody>
where
F: FnMut(Request<ReqBody>) -> Ret,
ReqBody: HttpBody,
@ -46,10 +29,7 @@ where
type Response = crate::Response<ResBody>;
type Error = E;
type Future = Ret;
fn poll_ready(
&mut self,
_cx: &mut task::Context<'_>,
) -> Poll<Result<(), Self::Error>> {
fn poll_ready(&mut self, _cx: &mut task::Context<'_>) -> Poll<Result<(), Self::Error>> {
loop {}
}
fn call(&mut self, req: Request<ReqBody>) -> Self::Future {
@ -69,7 +49,4 @@ where
loop {}
}
}
impl<F, R> Copy for ServiceFn<F, R>
where
F: Copy,
{}
impl<F, R> Copy for ServiceFn<F, R> where F: Copy {}