Struct Builder

struct Builder<E> { ... }

Http1 or Http2 connection builder.

Implementations

impl<E> Builder<E>

fn new(executor: E) -> Self

Create a new auto connection builder.

executor parameter should be a type that implements Executor trait.

Example

use hyper_util::{
    rt::TokioExecutor,
    server::conn::auto,
};

auto::Builder::new(TokioExecutor::new());
fn http1(self: &mut Self) -> Http1Builder<'_, E>

Http1 configuration.

fn http2(self: &mut Self) -> Http2Builder<'_, E>

Http2 configuration.

fn http2_only(self: Self) -> Self

Only accepts HTTP/2

Does not do anything if used with serve_connection_with_upgrades

fn http1_only(self: Self) -> Self

Only accepts HTTP/1

Does not do anything if used with serve_connection_with_upgrades

fn is_http1_available(self: &Self) -> bool

Returns true if this builder can serve an HTTP/1.1-based connection.

fn is_http2_available(self: &Self) -> bool

Returns true if this builder can serve an HTTP/2-based connection.

fn title_case_headers(self: Self, enabled: bool) -> Self

Set whether HTTP/1 connections will write header names as title case at the socket level.

This setting only affects HTTP/1 connections. HTTP/2 connections are not affected by this setting.

Default is false.

Example

use hyper_util::{
    rt::TokioExecutor,
    server::conn::auto,
};

auto::Builder::new(TokioExecutor::new())
    .title_case_headers(true);
fn preserve_header_case(self: Self, enabled: bool) -> Self

Set whether HTTP/1 connections will preserve the original case of header names.

This setting only affects HTTP/1 connections. HTTP/2 connections are not affected by this setting.

Default is false.

Example

use hyper_util::{
    rt::TokioExecutor,
    server::conn::auto,
};

auto::Builder::new(TokioExecutor::new())
    .preserve_header_case(true);
fn serve_connection<I, S, B>(self: &Self, io: I, service: S) -> Connection<'_, I, S, E>
where
    S: Service<Request<Incoming>, Response = Response<B>>,
    <S as >::Future: 'static,
    <S as >::Error: Into<Box<dyn StdError + Send + Sync>>,
    B: Body + 'static,
    <B as >::Error: Into<Box<dyn StdError + Send + Sync>>,
    I: Read + Write + Unpin + 'static,
    E: HttpServerConnExec<<S as >::Future, B>

Bind a connection together with a Service.

fn serve_connection_with_upgrades<I, S, B>(self: &Self, io: I, service: S) -> UpgradeableConnection<'_, I, S, E>
where
    S: Service<Request<Incoming>, Response = Response<B>>,
    <S as >::Future: 'static,
    <S as >::Error: Into<Box<dyn StdError + Send + Sync>>,
    B: Body + 'static,
    <B as >::Error: Into<Box<dyn StdError + Send + Sync>>,
    I: Read + Write + Unpin + Send + 'static,
    E: HttpServerConnExec<<S as >::Future, B>

Bind a connection together with a Service, with the ability to handle HTTP upgrades. This requires that the IO object implements Send.

Note that if you ever want to use hyper::upgrade::Upgraded::downcast with this crate, you'll need to use hyper_util::server::conn::auto::upgrade::downcast instead. See the documentation of the latter to understand why.

impl<E> Freeze for Builder<E>

impl<E> RefUnwindSafe for Builder<E>

impl<E> Send for Builder<E>

impl<E> Sync for Builder<E>

impl<E> Unpin for Builder<E>

impl<E> UnsafeUnpin for Builder<E>

impl<E> UnwindSafe for Builder<E>

impl<E: $crate::clone::Clone> Clone for Builder<E>

fn clone(self: &Self) -> Builder<E>

impl<E: $crate::fmt::Debug> Debug for Builder<E>

fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result

impl<E: Default> Default for Builder<E>

fn default() -> Self

impl<T> Any for Builder<E>

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for Builder<E>

fn borrow(self: &Self) -> &T

impl<T> BorrowMut for Builder<E>

fn borrow_mut(self: &mut Self) -> &mut T

impl<T> CloneToUninit for Builder<E>

unsafe fn clone_to_uninit(self: &Self, dest: *mut u8)

impl<T> From for Builder<E>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> Instrument for Builder<E>

impl<T> ToOwned for Builder<E>

fn to_owned(self: &Self) -> T
fn clone_into(self: &Self, target: &mut T)

impl<T> WithSubscriber for Builder<E>

impl<T, U> Into for Builder<E>

fn into(self: Self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom for Builder<E>

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

impl<T, U> TryInto for Builder<E>

fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>