mirror of
https://github.com/Noratrieb/icefun.git
synced 2026-01-14 12:55:02 +01:00
loop
This commit is contained in:
parent
dd3b3980bf
commit
b4e7136ad9
9 changed files with 93 additions and 271 deletions
|
|
@ -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> {
|
||||
|
|
|
|||
|
|
@ -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"))]
|
||||
|
|
|
|||
|
|
@ -16,42 +16,42 @@ struct ErrorImpl {
|
|||
pub(super) enum Kind {
|
||||
Parse(Parse),
|
||||
User(User),
|
||||
|
||||
|
||||
#[allow(unused)]
|
||||
IncompleteMessage,
|
||||
|
||||
|
||||
#[cfg(feature = "http1")]
|
||||
UnexpectedMessage,
|
||||
|
||||
|
||||
Canceled,
|
||||
|
||||
|
||||
ChannelClosed,
|
||||
|
||||
|
||||
#[cfg(any(feature = "http1", feature = "http2"))]
|
||||
Io,
|
||||
|
||||
|
||||
#[allow(unused)]
|
||||
Connect,
|
||||
|
||||
|
||||
#[cfg(all(feature = "tcp", feature = "server"))]
|
||||
Listen,
|
||||
|
||||
|
||||
#[cfg(any(feature = "http1", feature = "http2"))]
|
||||
#[cfg(feature = "server")]
|
||||
Accept,
|
||||
|
||||
|
||||
#[cfg(all(feature = "http1", feature = "server", feature = "runtime"))]
|
||||
HeaderTimeout,
|
||||
|
||||
|
||||
#[cfg(any(feature = "http1", feature = "http2", feature = "stream"))]
|
||||
Body,
|
||||
|
||||
|
||||
#[cfg(any(feature = "http1", feature = "http2"))]
|
||||
BodyWrite,
|
||||
|
||||
|
||||
#[cfg(feature = "http1")]
|
||||
Shutdown,
|
||||
|
||||
|
||||
#[cfg(feature = "http2")]
|
||||
Http2,
|
||||
}
|
||||
|
|
@ -82,100 +82,95 @@ pub(super) enum Header {
|
|||
}
|
||||
#[derive(Debug)]
|
||||
pub(super) enum User {
|
||||
|
||||
#[cfg(any(feature = "http1", feature = "http2"))]
|
||||
Body,
|
||||
|
||||
|
||||
BodyWriteAborted,
|
||||
|
||||
|
||||
#[cfg(any(feature = "http1", feature = "http2"))]
|
||||
#[cfg(feature = "server")]
|
||||
MakeService,
|
||||
|
||||
|
||||
#[cfg(any(feature = "http1", feature = "http2"))]
|
||||
Service,
|
||||
|
||||
|
||||
|
||||
|
||||
#[cfg(any(feature = "http1", feature = "http2"))]
|
||||
#[cfg(feature = "server")]
|
||||
UnexpectedHeader,
|
||||
|
||||
|
||||
#[cfg(any(feature = "http1", feature = "http2"))]
|
||||
#[cfg(feature = "client")]
|
||||
UnsupportedVersion,
|
||||
|
||||
|
||||
#[cfg(any(feature = "http1", feature = "http2"))]
|
||||
#[cfg(feature = "client")]
|
||||
UnsupportedRequestMethod,
|
||||
|
||||
|
||||
#[cfg(feature = "http1")]
|
||||
#[cfg(feature = "server")]
|
||||
UnsupportedStatusCode,
|
||||
|
||||
|
||||
#[cfg(any(feature = "http1", feature = "http2"))]
|
||||
#[cfg(feature = "client")]
|
||||
AbsoluteUriRequired,
|
||||
|
||||
|
||||
NoUpgrade,
|
||||
|
||||
|
||||
#[cfg(feature = "http1")]
|
||||
ManualUpgrade,
|
||||
|
||||
|
||||
#[cfg(feature = "server")]
|
||||
WithoutShutdownNonHttp1,
|
||||
|
||||
|
||||
#[cfg(feature = "client")]
|
||||
DispatchGone,
|
||||
|
||||
|
||||
#[cfg(feature = "ffi")]
|
||||
AbortedByCallback,
|
||||
}
|
||||
#[derive(Debug)]
|
||||
pub(super) struct TimedOut;
|
||||
impl Error {
|
||||
|
||||
pub(crate) fn is_parse(&self) -> bool {
|
||||
loop {}
|
||||
}
|
||||
|
||||
|
||||
pub(crate) fn is_parse_too_large(&self) -> bool {
|
||||
loop {}
|
||||
}
|
||||
|
||||
|
||||
|
||||
pub(crate) fn is_parse_status(&self) -> bool {
|
||||
loop {}
|
||||
}
|
||||
|
||||
|
||||
pub(crate) fn is_user(&self) -> bool {
|
||||
loop {}
|
||||
}
|
||||
|
||||
|
||||
pub(crate) fn is_canceled(&self) -> bool {
|
||||
loop {}
|
||||
}
|
||||
|
||||
|
||||
pub(crate) fn is_closed(&self) -> bool {
|
||||
loop {}
|
||||
}
|
||||
|
||||
|
||||
pub(crate) fn is_connect(&self) -> bool {
|
||||
loop {}
|
||||
}
|
||||
|
||||
|
||||
pub(crate) fn is_incomplete_message(&self) -> bool {
|
||||
loop {}
|
||||
}
|
||||
|
||||
|
||||
pub(crate) fn is_body_write_aborted(&self) -> bool {
|
||||
loop {}
|
||||
}
|
||||
|
||||
|
||||
pub(crate) fn is_timeout(&self) -> bool {
|
||||
loop {}
|
||||
}
|
||||
|
||||
|
||||
pub(crate) fn into_cause(self) -> Option<Box<dyn StdError + Send + Sync>> {
|
||||
loop {}
|
||||
}
|
||||
|
|
@ -319,7 +314,7 @@ impl Error {
|
|||
pub(super) fn new_h2(cause: ::h2::Error) -> Error {
|
||||
loop {}
|
||||
}
|
||||
|
||||
|
||||
pub(crate) fn message(&self) -> impl fmt::Display + '_ {
|
||||
self.description()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,21 +13,16 @@ 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 {}
|
||||
}
|
||||
|
||||
|
||||
pub(crate) fn as_str(&self) -> &str {
|
||||
loop {}
|
||||
}
|
||||
|
|
@ -57,45 +52,19 @@ 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,
|
||||
) -> impl Iterator<Item = impl AsRef<[u8]> + 'a> + 'a {
|
||||
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"))]
|
||||
|
|
@ -140,43 +103,7 @@ impl OriginalHeaderOrder {
|
|||
{
|
||||
loop {}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
pub(crate) fn get_in_order(&self) -> impl Iterator<Item = &(HeaderName, usize)> {
|
||||
loop {}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
use std::convert::TryFrom;
|
||||
use bytes::Bytes;
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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 {}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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,62 +16,46 @@ 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 {}
|
||||
}
|
||||
|
||||
|
||||
pub fn local_addr(&self) -> SocketAddr {
|
||||
loop {}
|
||||
}
|
||||
|
||||
|
||||
pub fn set_nodelay(&mut self, enabled: bool) -> &mut 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]
|
||||
|
|
|
|||
|
|
@ -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 {}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue