This commit is contained in:
nora 2023-03-07 14:18:23 +01:00
parent b4ac40748d
commit b3d4232a00
7 changed files with 0 additions and 754 deletions

View file

@ -101,8 +101,6 @@ pub struct Sender {
data_tx: BodySender, data_tx: BodySender,
trailers_tx: Option<TrailersSender>, trailers_tx: Option<TrailersSender>,
} }
const WANT_PENDING: usize = 1;
const WANT_READY: usize = 2;
impl Body { impl Body {
/// Create an empty `Body` stream. /// Create an empty `Body` stream.
/// ///
@ -268,45 +266,3 @@ impl fmt::Debug for Sender {
loop {} 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 {}
}
}

View file

@ -7,8 +7,6 @@ impl From<Option<u64>> for DecodedLength {
loop {} loop {}
} }
} }
#[cfg(any(feature = "http1", feature = "http2", test))]
const MAX_LEN: u64 = std::u64::MAX - 2;
impl DecodedLength { impl DecodedLength {
pub(crate) const CLOSE_DELIMITED: DecodedLength = DecodedLength(::std::u64::MAX); pub(crate) const CLOSE_DELIMITED: DecodedLength = DecodedLength(::std::u64::MAX);
pub(crate) const CHUNKED: DecodedLength = DecodedLength(::std::u64::MAX - 1); pub(crate) const CHUNKED: DecodedLength = DecodedLength(::std::u64::MAX - 1);
@ -58,15 +56,3 @@ impl fmt::Display for DecodedLength {
loop {} loop {}
} }
} }
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn sub_if_known() {
loop {}
}
#[test]
fn sub_if_chunked() {
loop {}
}
}

View file

@ -1,120 +1,2 @@
use std::convert::TryFrom; use std::convert::TryFrom;
use bytes::Bytes; 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::<ReasonPhrase>() {
/// 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<Self, Self::Error> {
loop {}
}
}
impl TryFrom<Vec<u8>> for ReasonPhrase {
type Error = InvalidReasonPhrase;
fn try_from(reason: Vec<u8>) -> Result<Self, Self::Error> {
loop {}
}
}
impl TryFrom<String> for ReasonPhrase {
type Error = InvalidReasonPhrase;
fn try_from(reason: String) -> Result<Self, Self::Error> {
loop {}
}
}
impl TryFrom<Bytes> for ReasonPhrase {
type Error = InvalidReasonPhrase;
fn try_from(reason: Bytes) -> Result<Self, Self::Error> {
loop {}
}
}
impl Into<Bytes> 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 {}
}
}

View file

@ -53,8 +53,6 @@ use std::marker::PhantomData;
use std::time::Duration; use std::time::Duration;
#[cfg(feature = "http2")] #[cfg(feature = "http2")]
use crate::common::io::Rewind; use crate::common::io::Rewind;
cfg_feature! { cfg_feature! {
#![any(feature = "http1", feature = "http2")] use std::error::Error as StdError; use #![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:: { std::fmt; use bytes::Bytes; use pin_project_lite::pin_project; use tokio::io:: {
@ -149,14 +147,6 @@ enum Fallback<E> {
) )
)] )]
type Fallback<E> = PhantomData<E>; type Fallback<E> = PhantomData<E>;
#[cfg(all(feature = "http1", feature = "http2"))]
impl<E> Fallback<E> {
fn to_h2(&self) -> bool {
loop {}
}
}
#[cfg(all(feature = "http1", feature = "http2"))]
impl<E> Unpin for Fallback<E> {}
/// Deconstructed parts of a `Connection`. /// Deconstructed parts of a `Connection`.
/// ///
/// This allows taking apart a `Connection` at a later time, in order to /// 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"))] #[cfg(any(feature = "http1", feature = "http2"))]
impl<E> Http<E> {
/// 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<Option<u32>>,
) -> &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<Option<u32>>,
) -> &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<Option<u32>>,
) -> &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<Option<u32>>,
) -> &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<Option<Duration>>,
) -> &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<E2>(self, exec: E2) -> Http<E2> {
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<I, S>(some_io: I, some_service: S)
/// # where
/// # I: AsyncRead + AsyncWrite + Unpin + Send + 'static,
/// # S: Service<hyper::Request<Body>, Response=hyper::Response<Body>> + Send + 'static,
/// # S::Error: Into<Box<dyn std::error::Error + Send + Sync>>,
/// # 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<S, I, Bd>(
&self,
io: I,
service: S,
) -> Connection<I, S, E>
where
S: HttpService<Body, ResBody = Bd>,
S::Error: Into<Box<dyn StdError + Send + Sync>>,
Bd: HttpBody + 'static,
Bd::Error: Into<Box<dyn StdError + Send + Sync>>,
I: AsyncRead + AsyncWrite + Unpin,
E: ConnStreamExec<S::Future, Bd>,
{
loop {}
}
}
#[cfg(any(feature = "http1", feature = "http2"))]
impl<I, B, S, E> Connection<I, S, E>
where
S: HttpService<Body, ResBody = B>,
S::Error: Into<Box<dyn StdError + Send + Sync>>,
I: AsyncRead + AsyncWrite + Unpin,
B: HttpBody + 'static,
B::Error: Into<Box<dyn StdError + Send + Sync>>,
E: ConnStreamExec<S::Future, B>,
{
/// 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<I, S> {
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<Parts<I, S>> {
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<crate::Result<()>>
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<Output = crate::Result<Parts<I, S>>>
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<I, S, E>
where
I: Send,
{
loop {}
}
}
#[cfg(any(feature = "http1", feature = "http2"))]
impl<I, B, S, E> Future for Connection<I, S, E>
where
S: HttpService<Body, ResBody = B>,
S::Error: Into<Box<dyn StdError + Send + Sync>>,
I: AsyncRead + AsyncWrite + Unpin + 'static,
B: HttpBody + 'static,
B::Error: Into<Box<dyn StdError + Send + Sync>>,
E: ConnStreamExec<S::Future, B>,
{
type Output = crate::Result<()>;
fn poll(mut self: Pin<&mut Self>, cx: &mut task::Context<'_>) -> Poll<Self::Output> {
loop {}
}
}
#[cfg(any(feature = "http1", feature = "http2"))]
impl<I, S> fmt::Debug for Connection<I, S>
where
S: HttpService<Body>,
{
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
loop {}
}
}
#[cfg(any(feature = "http1", feature = "http2"))]
impl Default for ConnectionMode { impl Default for ConnectionMode {
#[cfg(all(feature = "http1", feature = "http2"))] #[cfg(all(feature = "http1", feature = "http2"))]
fn default() -> ConnectionMode { fn default() -> ConnectionMode {
@ -623,21 +194,6 @@ impl Default for ConnectionMode {
} }
} }
#[cfg(any(feature = "http1", feature = "http2"))] #[cfg(any(feature = "http1", feature = "http2"))]
impl<T, B, S, E> Future for ProtoServer<T, B, S, E>
where
T: AsyncRead + AsyncWrite + Unpin,
S: HttpService<Body, ResBody = B>,
S::Error: Into<Box<dyn StdError + Send + Sync>>,
B: HttpBody + 'static,
B::Error: Into<Box<dyn StdError + Send + Sync>>,
E: ConnStreamExec<S::Future, B>,
{
type Output = crate::Result<proto::Dispatched>;
fn poll(self: Pin<&mut Self>, cx: &mut task::Context<'_>) -> Poll<Self::Output> {
loop {}
}
}
#[cfg(any(feature = "http1", feature = "http2"))]
mod upgrades { mod upgrades {
use super::*; use super::*;
#[must_use = "futures do nothing unless polled"] #[must_use = "futures do nothing unless polled"]

View file

@ -6,7 +6,6 @@ use std::net::{SocketAddr, TcpListener as StdTcpListener};
use std::time::Duration; use std::time::Duration;
use pin_project_lite::pin_project; use pin_project_lite::pin_project;
use tokio::io::{AsyncRead, AsyncWrite}; use tokio::io::{AsyncRead, AsyncWrite};
use super::accept::Accept; use super::accept::Accept;
#[cfg(all(feature = "tcp"))] #[cfg(all(feature = "tcp"))]
use super::tcp::AddrIncoming; use super::tcp::AddrIncoming;
@ -68,17 +67,6 @@ impl Server<AddrIncoming, ()> {
loop {} loop {}
} }
} }
#[cfg(feature = "tcp")]
#[cfg_attr(
docsrs,
doc(cfg(all(feature = "tcp", any(feature = "http1", feature = "http2"))))
)]
impl<S, E> Server<AddrIncoming, S, E> {
/// 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"))))] #[cfg_attr(docsrs, doc(cfg(any(feature = "http1", feature = "http2"))))]
impl<I, IO, IE, S, E, B> Server<I, S, E> impl<I, IO, IE, S, E, B> Server<I, S, E>
where where
@ -177,11 +165,6 @@ where
} }
} }
} }
impl<I: fmt::Debug, S: fmt::Debug> fmt::Debug for Server<I, S> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
loop {}
}
}
#[cfg_attr(docsrs, doc(cfg(any(feature = "http1", feature = "http2"))))] #[cfg_attr(docsrs, doc(cfg(any(feature = "http1", feature = "http2"))))]
impl<I, E> Builder<I, E> { impl<I, E> Builder<I, E> {
/// Start a new builder, wrapping an incoming stream and low-level options. /// Start a new builder, wrapping an incoming stream and low-level options.
@ -400,50 +383,6 @@ impl<I, E> Builder<I, E> {
loop {} loop {}
} }
} }
#[cfg(feature = "tcp")]
#[cfg_attr(
docsrs,
doc(cfg(all(feature = "tcp", any(feature = "http1", feature = "http2"))))
)]
impl<E> Builder<AddrIncoming, E> {
/// 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<Duration>) -> 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<Duration>) -> 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<u32>) -> 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<I, S: HttpService<Body>, E>: Clone { pub trait Watcher<I, S: HttpService<Body>, E>: Clone {
type Future: Future<Output = crate::Result<()>>; type Future: Future<Output = crate::Result<()>>;
fn watch(&self, conn: UpgradeableConnection<I, S, E>) -> Self::Future; fn watch(&self, conn: UpgradeableConnection<I, S, E>) -> Self::Future;
@ -467,7 +406,6 @@ where
pub(crate) mod new_svc { pub(crate) mod new_svc {
use std::error::Error as StdError; use std::error::Error as StdError;
use tokio::io::{AsyncRead, AsyncWrite}; use tokio::io::{AsyncRead, AsyncWrite};
use super::{Connecting, Watcher}; use super::{Connecting, Watcher};
use crate::body::{Body, HttpBody}; use crate::body::{Body, HttpBody};
use crate::common::exec::ConnStreamExec; use crate::common::exec::ConnStreamExec;
@ -514,17 +452,3 @@ pin_project! {
Connecting < I, F, E = Exec > { #[pin] future : F, io : Option < I >, protocol : Connecting < I, F, E = Exec > { #[pin] future : F, io : Option < I >, protocol :
Http_ < E >, } Http_ < E >, }
} }
impl<I, F, S, FE, E, B> Future for Connecting<I, F, E>
where
I: AsyncRead + AsyncWrite + Unpin,
F: Future<Output = Result<S, FE>>,
S: HttpService<Body, ResBody = B>,
B: HttpBody + 'static,
B::Error: Into<Box<dyn StdError + Send + Sync>>,
E: ConnStreamExec<S::Future, B>,
{
type Output = Result<Connection<I, S, E>, FE>;
fn poll(self: Pin<&mut Self>, cx: &mut task::Context<'_>) -> Poll<Self::Output> {
loop {}
}
}

View file

@ -1,13 +1,2 @@
use std::fmt; use std::fmt;
use crate::common::exec::Exec; 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<I, S, E = Exec> {
_marker: std::marker::PhantomData<(I, S, E)>,
}
impl<I: fmt::Debug, S: fmt::Debug> fmt::Debug for Server<I, S> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
loop {}
}
}

View file

@ -5,7 +5,6 @@ use std::time::Duration;
use socket2::TcpKeepalive; use socket2::TcpKeepalive;
use tokio::net::TcpListener; use tokio::net::TcpListener;
use tokio::time::Sleep; use tokio::time::Sleep;
use crate::common::{task, Pin, Poll}; use crate::common::{task, Pin, Poll};
#[allow(unreachable_pub)] #[allow(unreachable_pub)]
pub use self::addr_stream::AddrStream; 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 {}
}
}