Struct chilli::wrappers::Response [] [src]

pub struct Response {
    pub status_code: u16,
    pub headers: Headers,
    pub body: Option<Box<BodyWrite>>,
}

Response type. It is just one container with a couple of parameters (headers, body, status code etc).

Fields

The HTTP Status code number

Methods

impl Response
[src]

[src]

Create a Response. By default, the status code is 200 and content type is "text/html; charset=UTF-8". Remember to set content length if necessary. Mostly you should just get a response that is converted from other types, which set the content length automatically. For example:

This example is not tested
// Content length is set automatically
let response = Response::from("Hello");

[src]

Create an empty response without body.

[src]

Get status name.

[src]

Returns the response content type if available.

[src]

Set response content type. If the mimetype passed is a mimetype starting with text/ or something that needs a charset, the charset(UTF-8) parameter is appended to it.

[src]

Returns the response content length if available.

[src]

Set content length.

Sets cookie.

Trait Implementations

impl Debug for Response
[src]

[src]

Formats the value using the given formatter. Read more

impl From<Vec<u8>> for Response
[src]

[src]

Convert to response body. The content length is set automatically.

impl<'a> From<&'a [u8]> for Response
[src]

[src]

Convert to response body. The content length is set automatically.

impl<'a> From<&'a str> for Response
[src]

[src]

Convert to response body. The content length is set automatically.

impl From<String> for Response
[src]

[src]

Convert a new string to response body. The content length is set automatically.

impl From<File> for Response
[src]

[src]

Convert to response body. The content length is set automatically if file size is available from metadata.

Auto Trait Implementations

impl Send for Response

impl !Sync for Response