[][src]Struct rocket::http::hyper::Response

pub struct Response<'a, W = Fresh> where
    W: Any
{ pub version: HttpVersion, // some fields omitted }

The outgoing half for a Tcp connection, created by a Server and given to a Handler.

The default StatusCode for a Response is 200 OK.

There is a Drop implementation for Response that will automatically write the head and flush the body, if the handler has not already done so, so that the server doesn't accidentally leave dangling requests.


version: HttpVersion

The HTTP version of this response.


impl<'a, W> Response<'a, W> where
    W: Any

pub fn status(&self) -> StatusCode[src]

The status of this response.

pub fn headers(&self) -> &Headers[src]

The headers of this response.

pub fn construct(
    version: HttpVersion,
    body: HttpWriter<&'a mut (dyn Write + 'a)>,
    status: StatusCode,
    headers: &'a mut Headers
) -> Response<'a, Fresh>

Construct a Response from its constituent parts.

pub fn deconstruct(
) -> (HttpVersion, HttpWriter<&'a mut (dyn Write + 'a)>, StatusCode, &'a mut Headers)

Deconstruct this Response into its constituent parts.

impl<'a> Response<'a, Fresh>[src]

pub fn new(
    stream: &'a mut (dyn Write + 'a),
    headers: &'a mut Headers
) -> Response<'a, Fresh>

Creates a new Response that can be used to write to a network stream.

pub fn send(self, body: &[u8]) -> Result<(), Error>[src]

Writes the body and ends the response.

This is a shortcut method for when you have a response with a fixed size, and would only need a single write call normally.


fn handler(res: Response) {
    res.send(b"Hello World!").unwrap();

The above is the same, but shorter, than the longer:

use std::io::Write;
use hyper::header::ContentLength;
fn handler(mut res: Response) {
    let body = b"Hello World!";
    res.headers_mut().set(ContentLength(body.len() as u64));
    let mut res = res.start().unwrap();

pub fn start(self) -> Result<Response<'a, Streaming>, Error>[src]

Consume this Response, writing the Headers and Status and creating a Response

pub fn status_mut(&mut self) -> &mut StatusCode[src]

Get a mutable reference to the status.

pub fn headers_mut(&mut self) -> &mut Headers[src]

Get a mutable reference to the Headers.

impl<'a> Response<'a, Streaming>[src]

pub fn end(self) -> Result<(), Error>[src]

Flushes all writing of a response to the client.

Trait Implementations

impl<'a, W> Debug for Response<'a, W> where
    W: Any + Debug

impl<'a, T> Drop for Response<'a, T> where
    T: Any

impl<'a> Write for Response<'a, Streaming>[src]

Auto Trait Implementations

impl<'a, W = Fresh> !RefUnwindSafe for Response<'a, W>

impl<'a, W = Fresh> !Send for Response<'a, W>

impl<'a, W = Fresh> !Sync for Response<'a, W>

impl<'a, W> Unpin for Response<'a, W> where
    W: Unpin

impl<'a, W = Fresh> !UnwindSafe for Response<'a, W>

Blanket Implementations

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

impl<T, I> AsResult<T, I> for T where
    I: Input, 

impl<T> Borrow<T> for T where
    T: ?Sized

impl<T> BorrowMut<T> for T where
    T: ?Sized

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

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

impl<T> IntoCollection<T> for T

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 

type Error = Infallible

The type returned in the event of a conversion error.

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

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

The type returned in the event of a conversion error.

impl<T> Typeable for T where
    T: Any

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 

impl<W> WriteBytesExt for W where
    W: Write + ?Sized