Struct Builder

pub struct Builder<E> { /* private fields */ }

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(&mut self) -> Http1Builder<'_, E>

Http1 configuration.

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

Http2 configuration.

fn http2_only(self) -> Self

Only accepts HTTP/2

Does not do anything if used with serve_connection_with_upgrades

fn http1_only(self) -> Self

Only accepts HTTP/1

Does not do anything if used with serve_connection_with_upgrades

fn is_http1_available(&self) -> bool

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

fn is_http2_available(&self) -> bool

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

fn title_case_headers(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, 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, io: I, service: S) -> Connection<'_, I, S, E>
where
    S: Service<Request<Incoming>, Response = Response<B>>,
    S::Future: 'static,
    S::Error: Into<Box<dyn StdError + Send + Sync>>,
    B: Body + 'static,
    B::Error: Into<Box<dyn StdError + Send + Sync>>,
    I: Read + Write + Unpin + 'static,
    E: HttpServerConnExec<S::Future, B>,

Bind a connection together with a Service.

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

Trait Implementations

impl<E: Clone> Clone for Builder<E>

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

impl<E: Debug> Debug for Builder<E>

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

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

fn default() -> Self

Auto Trait Implementations

impl<E> !RefUnwindSafe for Builder<E>

impl<E> !UnwindSafe for Builder<E>

impl<E> Freeze for Builder<E> where Builder<E>: Freeze,

impl<E> Send for Builder<E> where Builder<E>: Send,

impl<E> Sync for Builder<E> where Builder<E>: Sync,

impl<E> Unpin for Builder<E> where Builder<E>: Unpin,

impl<E> UnsafeUnpin for Builder<E> where Builder<E>: UnsafeUnpin,

Blanket Implementations

impl<T> Any for Builder<E> where T: 'static + ?Sized,

fn type_id(&self) -> TypeId

impl<T> Borrow<T> for Builder<E> where T: ?Sized,

fn borrow(&self) -> &T

impl<T> BorrowMut<T> for Builder<E> where T: ?Sized,

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

impl<T> CloneToUninit for Builder<E> where T: Clone,

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

impl<T> From<T> for Builder<E>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> Instrument for Builder<E>

impl<T> ToOwned for Builder<E> where T: Clone,

type Owned = T;
fn to_owned(&self) -> T
fn clone_into(&self, target: &mut T)

impl<T> WithSubscriber for Builder<E>

impl<T, U> Into<U> for Builder<E> where U: From<T>,

fn into(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<U> for Builder<E> where U: Into<T>,

type Error = never;
fn try_from(value: U) -> Result<T, never>

impl<T, U> TryInto<U> for Builder<E> where U: TryFrom<T>,

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