From b3d4232a00465b60f6a1f54f5bd7b1e4c8201f98 Mon Sep 17 00:00:00 2001 From: nils <48135649+Nilstrieb@users.noreply.github.com> Date: Tue, 7 Mar 2023 14:18:23 +0100 Subject: [PATCH] loop --- hyper/src/body/body.rs | 44 --- hyper/src/body/length.rs | 14 - hyper/src/ext/h1_reason_phrase.rs | 118 -------- hyper/src/server/conn.rs | 444 ------------------------------ hyper/src/server/server.rs | 76 ----- hyper/src/server/server_stub.rs | 11 - hyper/src/server/tcp.rs | 47 ---- 7 files changed, 754 deletions(-) diff --git a/hyper/src/body/body.rs b/hyper/src/body/body.rs index e81a686..7e212d9 100644 --- a/hyper/src/body/body.rs +++ b/hyper/src/body/body.rs @@ -101,8 +101,6 @@ pub struct Sender { data_tx: BodySender, trailers_tx: Option, } -const WANT_PENDING: usize = 1; -const WANT_READY: usize = 2; impl Body { /// Create an empty `Body` stream. /// @@ -268,45 +266,3 @@ impl fmt::Debug for Sender { loop {} } } -#[cfg(test)] -mod tests { - use std::mem; - use std::task::Poll; - use super::{Body, DecodedLength, HttpBody, Sender, SizeHint}; - #[test] - fn test_size_of() { - loop {} - } - #[test] - fn size_hint() { - loop {} - } - #[tokio::test] - async fn channel_abort() { - loop {} - } - #[tokio::test] - async fn channel_abort_when_buffer_is_full() { - loop {} - } - #[test] - fn channel_buffers_one() { - loop {} - } - #[tokio::test] - async fn channel_empty() { - loop {} - } - #[test] - fn channel_ready() { - loop {} - } - #[test] - fn channel_wanter() { - loop {} - } - #[test] - fn channel_notices_closure() { - loop {} - } -} diff --git a/hyper/src/body/length.rs b/hyper/src/body/length.rs index 17b5274..edce3cc 100644 --- a/hyper/src/body/length.rs +++ b/hyper/src/body/length.rs @@ -7,8 +7,6 @@ impl From> for DecodedLength { loop {} } } -#[cfg(any(feature = "http1", feature = "http2", test))] -const MAX_LEN: u64 = std::u64::MAX - 2; impl DecodedLength { pub(crate) const CLOSE_DELIMITED: DecodedLength = DecodedLength(::std::u64::MAX); pub(crate) const CHUNKED: DecodedLength = DecodedLength(::std::u64::MAX - 1); @@ -58,15 +56,3 @@ impl fmt::Display for DecodedLength { loop {} } } -#[cfg(test)] -mod tests { - use super::*; - #[test] - fn sub_if_known() { - loop {} - } - #[test] - fn sub_if_chunked() { - loop {} - } -} diff --git a/hyper/src/ext/h1_reason_phrase.rs b/hyper/src/ext/h1_reason_phrase.rs index 59d469c..5e1e5a6 100644 --- a/hyper/src/ext/h1_reason_phrase.rs +++ b/hyper/src/ext/h1_reason_phrase.rs @@ -1,120 +1,2 @@ use std::convert::TryFrom; use bytes::Bytes; -/// A reason phrase in an HTTP/1 response. -/// -/// # Clients -/// -/// For clients, a `ReasonPhrase` will be present in the extensions of the `http::Response` returned -/// for a request if the reason phrase is different from the canonical reason phrase for the -/// response's status code. For example, if a server returns `HTTP/1.1 200 Awesome`, the -/// `ReasonPhrase` will be present and contain `Awesome`, but if a server returns `HTTP/1.1 200 OK`, -/// the response will not contain a `ReasonPhrase`. -/// -/// ```no_run -/// # #[cfg(all(feature = "tcp", feature = "client", feature = "http1"))] -/// # async fn fake_fetch() -> hyper::Result<()> { -/// use hyper::{Client, Uri}; -/// use hyper::ext::ReasonPhrase; -/// -/// let res = Client::new().get(Uri::from_static("http://example.com/non_canonical_reason")).await?; -/// -/// // Print out the non-canonical reason phrase, if it has one... -/// if let Some(reason) = res.extensions().get::() { -/// println!("non-canonical reason: {}", std::str::from_utf8(reason.as_bytes()).unwrap()); -/// } -/// # Ok(()) -/// # } -/// ``` -/// -/// # Servers -/// -/// When a `ReasonPhrase` is present in the extensions of the `http::Response` written by a server, -/// its contents will be written in place of the canonical reason phrase when responding via HTTP/1. -#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] -pub(crate) struct ReasonPhrase(Bytes); -impl ReasonPhrase {} -impl TryFrom<&[u8]> for ReasonPhrase { - type Error = InvalidReasonPhrase; - fn try_from(reason: &[u8]) -> Result { - loop {} - } -} -impl TryFrom> for ReasonPhrase { - type Error = InvalidReasonPhrase; - fn try_from(reason: Vec) -> Result { - loop {} - } -} -impl TryFrom for ReasonPhrase { - type Error = InvalidReasonPhrase; - fn try_from(reason: String) -> Result { - loop {} - } -} -impl TryFrom for ReasonPhrase { - type Error = InvalidReasonPhrase; - fn try_from(reason: Bytes) -> Result { - loop {} - } -} -impl Into for ReasonPhrase { - fn into(self) -> Bytes { - loop {} - } -} -impl AsRef<[u8]> for ReasonPhrase { - fn as_ref(&self) -> &[u8] { - loop {} - } -} -/// Error indicating an invalid byte when constructing a `ReasonPhrase`. -/// -/// See [the spec][spec] for details on allowed bytes. -/// -/// [spec]: https://httpwg.org/http-core/draft-ietf-httpbis-messaging-latest.html#rfc.section.4.p.7 -#[derive(Debug)] -pub(crate) struct InvalidReasonPhrase { - bad_byte: u8, -} -impl std::fmt::Display for InvalidReasonPhrase { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - loop {} - } -} -impl std::error::Error for InvalidReasonPhrase {} -#[cfg(test)] -mod tests { - use super::*; - #[test] - fn basic_valid() { - loop {} - } - #[test] - fn empty_valid() { - loop {} - } - #[test] - fn obs_text_valid() { - loop {} - } - const NEWLINE_PHRASE: &'static [u8] = b"hyp\ner"; - #[test] - #[should_panic] - fn newline_invalid_panic() { - loop {} - } - #[test] - fn newline_invalid_err() { - loop {} - } - const CR_PHRASE: &'static [u8] = b"hyp\rer"; - #[test] - #[should_panic] - fn cr_invalid_panic() { - loop {} - } - #[test] - fn cr_invalid_err() { - loop {} - } -} diff --git a/hyper/src/server/conn.rs b/hyper/src/server/conn.rs index d85fb1e..c7093ba 100644 --- a/hyper/src/server/conn.rs +++ b/hyper/src/server/conn.rs @@ -53,8 +53,6 @@ use std::marker::PhantomData; use std::time::Duration; #[cfg(feature = "http2")] use crate::common::io::Rewind; - - cfg_feature! { #![any(feature = "http1", feature = "http2")] use std::error::Error as StdError; use std::fmt; use bytes::Bytes; use pin_project_lite::pin_project; use tokio::io:: { @@ -149,14 +147,6 @@ enum Fallback { ) )] type Fallback = PhantomData; -#[cfg(all(feature = "http1", feature = "http2"))] -impl Fallback { - fn to_h2(&self) -> bool { - loop {} - } -} -#[cfg(all(feature = "http1", feature = "http2"))] -impl Unpin for Fallback {} /// Deconstructed parts of a `Connection`. /// /// This allows taking apart a `Connection` at a later time, in order to @@ -189,425 +179,6 @@ impl Http { } } #[cfg(any(feature = "http1", feature = "http2"))] -impl Http { - /// Sets whether HTTP1 is required. - /// - /// Default is false - #[cfg(feature = "http1")] - #[cfg_attr(docsrs, doc(cfg(feature = "http1")))] - pub(crate) fn http1_only(&mut self, val: bool) -> &mut Self { - loop {} - } - /// Set whether HTTP/1 connections should support half-closures. - /// - /// Clients can chose to shutdown their write-side while waiting - /// for the server to respond. Setting this to `true` will - /// prevent closing the connection immediately if `read` - /// detects an EOF in the middle of a request. - /// - /// Default is `false`. - #[cfg(feature = "http1")] - #[cfg_attr(docsrs, doc(cfg(feature = "http1")))] - pub(crate) fn http1_half_close(&mut self, val: bool) -> &mut Self { - loop {} - } - /// Enables or disables HTTP/1 keep-alive. - /// - /// Default is true. - #[cfg(feature = "http1")] - #[cfg_attr(docsrs, doc(cfg(feature = "http1")))] - pub(crate) fn http1_keep_alive(&mut self, val: bool) -> &mut Self { - loop {} - } - /// Set whether HTTP/1 connections will write header names as title case at - /// the socket level. - /// - /// Note that this setting does not affect HTTP/2. - /// - /// Default is false. - #[cfg(feature = "http1")] - #[cfg_attr(docsrs, doc(cfg(feature = "http1")))] - pub(crate) fn http1_title_case_headers(&mut self, enabled: bool) -> &mut Self { - loop {} - } - /// Set whether to support preserving original header cases. - /// - /// Currently, this will record the original cases received, and store them - /// in a private extension on the `Request`. It will also look for and use - /// such an extension in any provided `Response`. - /// - /// Since the relevant extension is still private, there is no way to - /// interact with the original cases. The only effect this can have now is - /// to forward the cases in a proxy-like fashion. - /// - /// Note that this setting does not affect HTTP/2. - /// - /// Default is false. - #[cfg(feature = "http1")] - #[cfg_attr(docsrs, doc(cfg(feature = "http1")))] - pub(crate) fn http1_preserve_header_case(&mut self, enabled: bool) -> &mut Self { - loop {} - } - /// Set a timeout for reading client request headers. If a client does not - /// transmit the entire header within this time, the connection is closed. - /// - /// Default is None. - #[cfg(all(feature = "http1", feature = "runtime"))] - #[cfg_attr(docsrs, doc(cfg(all(feature = "http1", feature = "runtime"))))] - pub(crate) fn http1_header_read_timeout( - &mut self, - read_timeout: Duration, - ) -> &mut Self { - loop {} - } - /// Set whether HTTP/1 connections should try to use vectored writes, - /// or always flatten into a single buffer. - /// - /// Note that setting this to false may mean more copies of body data, - /// but may also improve performance when an IO transport doesn't - /// support vectored writes well, such as most TLS implementations. - /// - /// Setting this to true will force hyper to use queued strategy - /// which may eliminate unnecessary cloning on some TLS backends - /// - /// Default is `auto`. In this mode hyper will try to guess which - /// mode to use - #[inline] - #[cfg(feature = "http1")] - #[cfg_attr(docsrs, doc(cfg(feature = "http1")))] - pub(crate) fn http1_writev(&mut self, val: bool) -> &mut Self { - loop {} - } - /// Sets whether HTTP2 is required. - /// - /// Default is false - #[cfg(feature = "http2")] - #[cfg_attr(docsrs, doc(cfg(feature = "http2")))] - pub(crate) fn http2_only(&mut self, val: bool) -> &mut Self { - loop {} - } - /// Sets the [`SETTINGS_INITIAL_WINDOW_SIZE`][spec] option for HTTP2 - /// stream-level flow control. - /// - /// Passing `None` will do nothing. - /// - /// If not set, hyper will use a default. - /// - /// [spec]: https://http2.github.io/http2-spec/#SETTINGS_INITIAL_WINDOW_SIZE - #[cfg(feature = "http2")] - #[cfg_attr(docsrs, doc(cfg(feature = "http2")))] - pub(crate) fn http2_initial_stream_window_size( - &mut self, - sz: impl Into>, - ) -> &mut Self { - loop {} - } - /// Sets the max connection-level flow control for HTTP2. - /// - /// Passing `None` will do nothing. - /// - /// If not set, hyper will use a default. - #[cfg(feature = "http2")] - #[cfg_attr(docsrs, doc(cfg(feature = "http2")))] - pub(crate) fn http2_initial_connection_window_size( - &mut self, - sz: impl Into>, - ) -> &mut Self { - loop {} - } - /// Sets whether to use an adaptive flow control. - /// - /// Enabling this will override the limits set in - /// `http2_initial_stream_window_size` and - /// `http2_initial_connection_window_size`. - #[cfg(feature = "http2")] - #[cfg_attr(docsrs, doc(cfg(feature = "http2")))] - pub(crate) fn http2_adaptive_window(&mut self, enabled: bool) -> &mut Self { - loop {} - } - /// Sets the maximum frame size to use for HTTP2. - /// - /// Passing `None` will do nothing. - /// - /// If not set, hyper will use a default. - #[cfg(feature = "http2")] - #[cfg_attr(docsrs, doc(cfg(feature = "http2")))] - pub(crate) fn http2_max_frame_size( - &mut self, - sz: impl Into>, - ) -> &mut Self { - loop {} - } - /// Sets the [`SETTINGS_MAX_CONCURRENT_STREAMS`][spec] option for HTTP2 - /// connections. - /// - /// Default is no limit (`std::u32::MAX`). Passing `None` will do nothing. - /// - /// [spec]: https://http2.github.io/http2-spec/#SETTINGS_MAX_CONCURRENT_STREAMS - #[cfg(feature = "http2")] - #[cfg_attr(docsrs, doc(cfg(feature = "http2")))] - pub(crate) fn http2_max_concurrent_streams( - &mut self, - max: impl Into>, - ) -> &mut Self { - loop {} - } - /// Sets an interval for HTTP2 Ping frames should be sent to keep a - /// connection alive. - /// - /// Pass `None` to disable HTTP2 keep-alive. - /// - /// Default is currently disabled. - /// - /// # Cargo Feature - /// - /// Requires the `runtime` cargo feature to be enabled. - #[cfg(feature = "runtime")] - #[cfg(feature = "http2")] - #[cfg_attr(docsrs, doc(cfg(feature = "http2")))] - pub(crate) fn http2_keep_alive_interval( - &mut self, - interval: impl Into>, - ) -> &mut Self { - loop {} - } - /// Sets a timeout for receiving an acknowledgement of the keep-alive ping. - /// - /// If the ping is not acknowledged within the timeout, the connection will - /// be closed. Does nothing if `http2_keep_alive_interval` is disabled. - /// - /// Default is 20 seconds. - /// - /// # Cargo Feature - /// - /// Requires the `runtime` cargo feature to be enabled. - #[cfg(feature = "runtime")] - #[cfg(feature = "http2")] - #[cfg_attr(docsrs, doc(cfg(feature = "http2")))] - pub(crate) fn http2_keep_alive_timeout(&mut self, timeout: Duration) -> &mut Self { - loop {} - } - /// Set the maximum write buffer size for each HTTP/2 stream. - /// - /// Default is currently ~400KB, but may change. - /// - /// # Panics - /// - /// The value must be no larger than `u32::MAX`. - #[cfg(feature = "http2")] - #[cfg_attr(docsrs, doc(cfg(feature = "http2")))] - pub(crate) fn http2_max_send_buf_size(&mut self, max: usize) -> &mut Self { - loop {} - } - /// Enables the [extended CONNECT protocol]. - /// - /// [extended CONNECT protocol]: https://datatracker.ietf.org/doc/html/rfc8441#section-4 - #[cfg(feature = "http2")] - pub(crate) fn http2_enable_connect_protocol(&mut self) -> &mut Self { - loop {} - } - /// Sets the max size of received header frames. - /// - /// Default is currently ~16MB, but may change. - #[cfg(feature = "http2")] - #[cfg_attr(docsrs, doc(cfg(feature = "http2")))] - pub(crate) fn http2_max_header_list_size(&mut self, max: u32) -> &mut Self { - loop {} - } - /// Set the maximum buffer size for the connection. - /// - /// Default is ~400kb. - /// - /// # Panics - /// - /// The minimum value allowed is 8192. This method panics if the passed `max` is less than the minimum. - #[cfg(feature = "http1")] - #[cfg_attr(docsrs, doc(cfg(feature = "http1")))] - pub(crate) fn max_buf_size(&mut self, max: usize) -> &mut Self { - loop {} - } - /// Aggregates flushes to better support pipelined responses. - /// - /// Experimental, may have bugs. - /// - /// Default is false. - pub(crate) fn pipeline_flush(&mut self, enabled: bool) -> &mut Self { - loop {} - } - /// Set the executor used to spawn background tasks. - /// - /// Default uses implicit default (like `tokio::spawn`). - pub(crate) fn with_executor(self, exec: E2) -> Http { - loop {} - } - /// Bind a connection together with a [`Service`](crate::service::Service). - /// - /// This returns a Future that must be polled in order for HTTP to be - /// driven on the connection. - /// - /// # Example - /// - /// ``` - /// # use hyper::{Body, Request, Response}; - /// # use hyper::service::Service; - /// # use hyper::server::conn::Http; - /// # use tokio::io::{AsyncRead, AsyncWrite}; - /// # async fn run(some_io: I, some_service: S) - /// # where - /// # I: AsyncRead + AsyncWrite + Unpin + Send + 'static, - /// # S: Service, Response=hyper::Response> + Send + 'static, - /// # S::Error: Into>, - /// # S::Future: Send, - /// # { - /// let http = Http::new(); - /// let conn = http.serve_connection(some_io, some_service); - /// - /// if let Err(e) = conn.await { - /// eprintln!("server connection error: {}", e); - /// } - /// # } - /// # fn main() {} - /// ``` - pub(crate) fn serve_connection( - &self, - io: I, - service: S, - ) -> Connection - where - S: HttpService, - S::Error: Into>, - Bd: HttpBody + 'static, - Bd::Error: Into>, - I: AsyncRead + AsyncWrite + Unpin, - E: ConnStreamExec, - { - loop {} - } -} -#[cfg(any(feature = "http1", feature = "http2"))] -impl Connection -where - S: HttpService, - S::Error: Into>, - I: AsyncRead + AsyncWrite + Unpin, - B: HttpBody + 'static, - B::Error: Into>, - E: ConnStreamExec, -{ - /// Start a graceful shutdown process for this connection. - /// - /// This `Connection` should continue to be polled until shutdown - /// can finish. - /// - /// # Note - /// - /// This should only be called while the `Connection` future is still - /// pending. If called after `Connection::poll` has resolved, this does - /// nothing. - pub(crate) fn graceful_shutdown(mut self: Pin<&mut Self>) { - loop {} - } - /// Return the inner IO object, and additional information. - /// - /// If the IO object has been "rewound" the io will not contain those bytes rewound. - /// This should only be called after `poll_without_shutdown` signals - /// that the connection is "done". Otherwise, it may not have finished - /// flushing all necessary HTTP bytes. - /// - /// # Panics - /// This method will panic if this connection is using an h2 protocol. - pub(crate) fn into_parts(self) -> Parts { - loop {} - } - /// Return the inner IO object, and additional information, if available. - /// - /// This method will return a `None` if this connection is using an h2 protocol. - pub(crate) fn try_into_parts(self) -> Option> { - loop {} - } - /// Poll the connection for completion, but without calling `shutdown` - /// on the underlying IO. - /// - /// This is useful to allow running a connection while doing an HTTP - /// upgrade. Once the upgrade is completed, the connection would be "done", - /// but it is not desired to actually shutdown the IO object. Instead you - /// would take it back using `into_parts`. - pub(crate) fn poll_without_shutdown( - &mut self, - cx: &mut task::Context<'_>, - ) -> Poll> - where - S: Unpin, - S::Future: Unpin, - B: Unpin, - { - loop {} - } - /// Prevent shutdown of the underlying IO object at the end of service the request, - /// instead run `into_parts`. This is a convenience wrapper over `poll_without_shutdown`. - /// - /// # Error - /// - /// This errors if the underlying connection protocol is not HTTP/1. - pub(crate) fn without_shutdown( - self, - ) -> impl Future>> - where - S: Unpin, - S::Future: Unpin, - B: Unpin, - { - let mut conn = Some(self); - futures_util::future::poll_fn(move |cx| { - ready!(conn.as_mut().unwrap().poll_without_shutdown(cx))?; - Poll::Ready( - conn - .take() - .unwrap() - .try_into_parts() - .ok_or_else(crate::Error::new_without_shutdown_not_h1), - ) - }) - } - #[cfg(all(feature = "http1", feature = "http2"))] - fn upgrade_h2(&mut self) { - loop {} - } - /// Enable this connection to support higher-level HTTP upgrades. - /// - /// See [the `upgrade` module](crate::upgrade) for more. - pub(crate) fn with_upgrades(self) -> UpgradeableConnection - where - I: Send, - { - loop {} - } -} -#[cfg(any(feature = "http1", feature = "http2"))] -impl Future for Connection -where - S: HttpService, - S::Error: Into>, - I: AsyncRead + AsyncWrite + Unpin + 'static, - B: HttpBody + 'static, - B::Error: Into>, - E: ConnStreamExec, -{ - type Output = crate::Result<()>; - fn poll(mut self: Pin<&mut Self>, cx: &mut task::Context<'_>) -> Poll { - loop {} - } -} -#[cfg(any(feature = "http1", feature = "http2"))] -impl fmt::Debug for Connection -where - S: HttpService, -{ - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - loop {} - } -} -#[cfg(any(feature = "http1", feature = "http2"))] impl Default for ConnectionMode { #[cfg(all(feature = "http1", feature = "http2"))] fn default() -> ConnectionMode { @@ -623,21 +194,6 @@ impl Default for ConnectionMode { } } #[cfg(any(feature = "http1", feature = "http2"))] -impl Future for ProtoServer -where - T: AsyncRead + AsyncWrite + Unpin, - S: HttpService, - S::Error: Into>, - B: HttpBody + 'static, - B::Error: Into>, - E: ConnStreamExec, -{ - type Output = crate::Result; - fn poll(self: Pin<&mut Self>, cx: &mut task::Context<'_>) -> Poll { - loop {} - } -} -#[cfg(any(feature = "http1", feature = "http2"))] mod upgrades { use super::*; #[must_use = "futures do nothing unless polled"] diff --git a/hyper/src/server/server.rs b/hyper/src/server/server.rs index 2ba2a1c..e0d58ec 100644 --- a/hyper/src/server/server.rs +++ b/hyper/src/server/server.rs @@ -6,7 +6,6 @@ use std::net::{SocketAddr, TcpListener as StdTcpListener}; use std::time::Duration; use pin_project_lite::pin_project; use tokio::io::{AsyncRead, AsyncWrite}; - use super::accept::Accept; #[cfg(all(feature = "tcp"))] use super::tcp::AddrIncoming; @@ -68,17 +67,6 @@ impl Server { loop {} } } -#[cfg(feature = "tcp")] -#[cfg_attr( - docsrs, - doc(cfg(all(feature = "tcp", any(feature = "http1", feature = "http2")))) -)] -impl Server { - /// Returns the local address that this server is bound to. - pub(crate) fn local_addr(&self) -> SocketAddr { - loop {} - } -} #[cfg_attr(docsrs, doc(cfg(any(feature = "http1", feature = "http2"))))] impl Server where @@ -177,11 +165,6 @@ where } } } -impl fmt::Debug for Server { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - loop {} - } -} #[cfg_attr(docsrs, doc(cfg(any(feature = "http1", feature = "http2"))))] impl Builder { /// Start a new builder, wrapping an incoming stream and low-level options. @@ -400,50 +383,6 @@ impl Builder { loop {} } } -#[cfg(feature = "tcp")] -#[cfg_attr( - docsrs, - doc(cfg(all(feature = "tcp", any(feature = "http1", feature = "http2")))) -)] -impl Builder { - /// Set the duration to remain idle before sending TCP keepalive probes. - /// - /// If `None` is specified, keepalive is disabled. - pub(crate) fn tcp_keepalive(mut self, keepalive: Option) -> Self { - loop {} - } - /// Set the duration between two successive TCP keepalive retransmissions, - /// if acknowledgement to the previous keepalive transmission is not received. - pub(crate) fn tcp_keepalive_interval(mut self, interval: Option) -> Self { - loop {} - } - /// Set the number of retransmissions to be carried out before declaring that remote end is not available. - pub(crate) fn tcp_keepalive_retries(mut self, retries: Option) -> Self { - loop {} - } - /// Set the value of `TCP_NODELAY` option for accepted connections. - pub(crate) fn tcp_nodelay(mut self, enabled: bool) -> Self { - loop {} - } - /// Set whether to sleep on accept errors. - /// - /// A possible scenario is that the process has hit the max open files - /// allowed, and so trying to accept a new connection will fail with - /// EMFILE. In some cases, it's preferable to just wait for some time, if - /// the application will likely close some files (or connections), and try - /// to accept the connection again. If this option is true, the error will - /// be logged at the error level, since it is still a big deal, and then - /// the listener will sleep for 1 second. - /// - /// In other cases, hitting the max open files should be treat similarly - /// to being out-of-memory, and simply error (and shutdown). Setting this - /// option to false will allow that. - /// - /// For more details see [`AddrIncoming::set_sleep_on_errors`] - pub(crate) fn tcp_sleep_on_accept_errors(mut self, val: bool) -> Self { - loop {} - } -} pub trait Watcher, E>: Clone { type Future: Future>; fn watch(&self, conn: UpgradeableConnection) -> Self::Future; @@ -467,7 +406,6 @@ where pub(crate) mod new_svc { use std::error::Error as StdError; use tokio::io::{AsyncRead, AsyncWrite}; - use super::{Connecting, Watcher}; use crate::body::{Body, HttpBody}; use crate::common::exec::ConnStreamExec; @@ -514,17 +452,3 @@ pin_project! { Connecting < I, F, E = Exec > { #[pin] future : F, io : Option < I >, protocol : Http_ < E >, } } -impl Future for Connecting -where - I: AsyncRead + AsyncWrite + Unpin, - F: Future>, - S: HttpService, - B: HttpBody + 'static, - B::Error: Into>, - E: ConnStreamExec, -{ - type Output = Result, FE>; - fn poll(self: Pin<&mut Self>, cx: &mut task::Context<'_>) -> Poll { - loop {} - } -} diff --git a/hyper/src/server/server_stub.rs b/hyper/src/server/server_stub.rs index 8c432be..5887955 100644 --- a/hyper/src/server/server_stub.rs +++ b/hyper/src/server/server_stub.rs @@ -1,13 +1,2 @@ use std::fmt; use crate::common::exec::Exec; -/// A listening HTTP server that accepts connections in both HTTP1 and HTTP2 by default. -/// -/// Needs at least one of the `http1` and `http2` features to be activated to actually be useful. -pub(crate) struct Server { - _marker: std::marker::PhantomData<(I, S, E)>, -} -impl fmt::Debug for Server { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - loop {} - } -} diff --git a/hyper/src/server/tcp.rs b/hyper/src/server/tcp.rs index 0e9e9af..6331b40 100644 --- a/hyper/src/server/tcp.rs +++ b/hyper/src/server/tcp.rs @@ -5,7 +5,6 @@ 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; @@ -294,49 +293,3 @@ mod addr_stream { } } } -#[cfg(test)] -mod tests { - use std::time::Duration; - use crate::server::tcp::TcpKeepaliveConfig; - #[test] - fn no_tcp_keepalive_config() { - loop {} - } - #[test] - fn tcp_keepalive_time_config() { - loop {} - } - #[cfg( - 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, - ) - )] - #[test] - fn tcp_keepalive_interval_config() { - loop {} - } - #[cfg( - 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", - ) - )] - #[test] - fn tcp_keepalive_retries_config() { - loop {} - } -}