[][src]Struct hyper::server::Http

pub struct Http<B = Chunk> { /* fields omitted */ }

A configuration of the HTTP protocol.

This structure is used to create instances of Server or to spawn off tasks which handle a connection to an HTTP server. Each instance of Http can be configured with various protocol-level options such as keepalive.

Methods

impl<B: AsRef<[u8]> + 'static> Http<B>[src]

pub fn bind_connection<S, I, Bd>(
    &self,
    handle: &Handle,
    io: I,
    remote_addr: SocketAddr,
    service: S
) where
    S: Service<Request = Request, Response = Response<Bd>, Error = Error> + 'static,
    Bd: Stream<Item = B, Error = Error> + 'static,
    I: AsyncRead + AsyncWrite + 'static, 
[src]

Deprecated since 0.11.11:

All usage of the tokio-proto crate is going away.

Use this Http instance to create a new server task which handles the connection io provided.

Deprecated

This method is deprecated. If seeking a replacement, consider Http::serve_connection.

impl<B: AsRef<[u8]> + 'static> Http<B>[src]

pub fn new() -> Http<B>[src]

Creates a new instance of the HTTP protocol, ready to spawn a server or start accepting connections.

pub fn keep_alive(&mut self, val: bool) -> &mut Self[src]

Enables or disables HTTP keep-alive.

Default is true.

pub fn max_buf_size(&mut self, max: usize) -> &mut Self[src]

Set the maximum buffer size for the connection.

pub fn pipeline(&mut self, enabled: bool) -> &mut Self[src]

Aggregates flushes to better support pipelined responses.

Experimental, may be have bugs.

Default is false.

pub fn sleep_on_errors(&mut self, enabled: bool) -> &mut Self[src]

Swallow connection accept errors. Instead of passing up IO errors when the server is under heavy load the errors will be ignored. Some connection accept errors (like "connection reset") can be ignored, some (like "too many files open") may consume 100% CPU and a timout of 10ms is used in that case.

Default is false.

pub fn bind<S, Bd>(
    &self,
    addr: &SocketAddr,
    new_service: S
) -> Result<Server<S, Bd>> where
    S: NewService<Request = Request, Response = Response<Bd>, Error = Error> + 'static,
    Bd: Stream<Item = B, Error = Error>, 
[src]

Bind the provided addr and return a server ready to handle connections.

This method will bind the addr provided with a new TCP listener ready to accept connections. Each connection will be processed with the new_service object provided as well, creating a new service per connection.

The returned Server contains one method, run, which is used to actually run the server.

pub fn serve_addr_handle<S, Bd>(
    &self,
    addr: &SocketAddr,
    handle: &Handle,
    new_service: S
) -> Result<Serve<AddrIncoming, S>> where
    S: NewService<Request = Request, Response = Response<Bd>, Error = Error>,
    Bd: Stream<Item = B, Error = Error>, 
[src]

Bind the provided addr and return a server with a shared Core.

This method allows the ability to share a Core with multiple servers.

This is method will bind the addr provided with a new TCP listener ready to accept connections. Each connection will be processed with the new_service object provided as well, creating a new service per connection.

pub fn serve_incoming<I, S, Bd>(
    &self,
    incoming: I,
    new_service: S
) -> Serve<I, S> where
    I: Stream<Error = Error>,
    I::Item: AsyncRead + AsyncWrite,
    S: NewService<Request = Request, Response = Response<Bd>, Error = Error>,
    Bd: Stream<Item = B, Error = Error>, 
[src]

Bind the provided stream of incoming IO objects with a NewService.

This method allows the ability to share a Core with multiple servers.

pub fn serve_connection<S, I, Bd>(&self, io: I, service: S) -> Connection<I, S> where
    S: Service<Request = Request, Response = Response<Bd>, Error = Error>,
    Bd: Stream<Error = Error>,
    Bd::Item: AsRef<[u8]>,
    I: AsyncRead + AsyncWrite
[src]

Bind a connection together with a Service.

This returns a Future that must be polled in order for HTTP to be driven on the connection.

Example

let http = Http::<hyper::Chunk>::new();
let conn = http.serve_connection(some_io, some_service);

let fut = conn
    .map(|_| ())
    .map_err(|e| eprintln!("server connection error: {}", e));

some_handle.spawn(fut);

Trait Implementations

impl<B> Clone for Http<B>[src]

impl<B> Debug for Http<B>[src]

impl<T, B> ServerProto<T> for Http<B> where
    T: AsyncRead + AsyncWrite + 'static,
    B: AsRef<[u8]> + 'static, 
[src]

type Request = __ProtoRequest

Request headers.

type RequestBody = Chunk

Request body chunks.

type Response = __ProtoResponse

Response headers.

type ResponseBody = B

Response body chunks.

type Error = Error

Errors, which are used both for error frames and for the service itself.

type Transport = __ProtoTransport<T, B>

The frame transport, which usually take T as a parameter.

type BindTransport = __ProtoBindTransport<T, B>

A future for initializing a transport from an I/O object. Read more

Auto Trait Implementations

impl<B> RefUnwindSafe for Http<B>

impl<B> Send for Http<B>

impl<B> Sync for Http<B>

impl<B> Unpin for Http<B>

impl<B> UnwindSafe for Http<B>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<P, T, B> BindServer<StreamingPipeline<B>, T> for P where
    B: Stream<Item = <P as ServerProto<T>>::ResponseBody, Error = <P as ServerProto<T>>::Error>,
    P: ServerProto<T>,
    T: 'static, 
[src]

type ServiceRequest = Message<<P as ServerProto<T>>::Request, Body<<P as ServerProto<T>>::RequestBody, <P as ServerProto<T>>::Error>>

The request type for the service.

type ServiceResponse = Message<<P as ServerProto<T>>::Response, B>

The response type for the service.

type ServiceError = <P as ServerProto<T>>::Error

The error type for the service.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.