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

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

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.

Fields

version: HttpVersion

The HTTP version of this response.

Implementations

The status of this response.

The headers of this response.

Construct a Response from its constituent parts.

Deconstruct this Response into its constituent parts.

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

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.

Example

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();
    res.write_all(body).unwrap();
}

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

Get a mutable reference to the status.

Get a mutable reference to the Headers.

Flushes all writing of a response to the client.

Trait Implementations

Formats the value using the given formatter. Read more

Executes the destructor for this type. Read more

Write a buffer into this writer, returning how many bytes were written. Read more

Flush this output stream, ensuring that all intermediately buffered contents reach their destination. Read more

Like write, except that it writes from a slice of buffers. Read more

🔬 This is a nightly-only experimental API. (can_vector)

Determines if this Writer has an efficient write_vectored implementation. Read more

Attempts to write an entire buffer into this writer. Read more

🔬 This is a nightly-only experimental API. (write_all_vectored)

Attempts to write multiple buffers into this writer. Read more

Writes a formatted string into this writer, returning any error encountered. Read more

Creates a “by reference” adapter for this instance of Write. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

Converts self into a collection.

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Get the TypeId of this object.

Writes an unsigned 8 bit integer to the underlying writer. Read more

Writes a signed 8 bit integer to the underlying writer. Read more

Writes an unsigned 16 bit integer to the underlying writer. Read more

Writes a signed 16 bit integer to the underlying writer. Read more

Writes an unsigned 24 bit integer to the underlying writer. Read more

Writes a signed 24 bit integer to the underlying writer. Read more

Writes an unsigned 32 bit integer to the underlying writer. Read more

Writes a signed 32 bit integer to the underlying writer. Read more

Writes an unsigned 48 bit integer to the underlying writer. Read more

Writes a signed 48 bit integer to the underlying writer. Read more

Writes an unsigned 64 bit integer to the underlying writer. Read more

Writes a signed 64 bit integer to the underlying writer. Read more

Writes an unsigned 128 bit integer to the underlying writer.

Writes a signed 128 bit integer to the underlying writer.

Writes an unsigned n-bytes integer to the underlying writer. Read more

Writes a signed n-bytes integer to the underlying writer. Read more

Writes an unsigned n-bytes integer to the underlying writer. Read more

Writes a signed n-bytes integer to the underlying writer. Read more

Writes a IEEE754 single-precision (4 bytes) floating point number to the underlying writer. Read more

Writes a IEEE754 double-precision (8 bytes) floating point number to the underlying writer. Read more