Skip to content

struct

Response

pub struct Response {
    pub status: u16,
    pub headers: Vec<(String, String)>,
    pub body: Vec<u8>,
}

An HTTP response: its status, headers and body.

Fields

status

pub status: u16

The status code.

headers

pub headers: Vec<(String, String)>

Headers as (name, value) pairs.

body

pub body: Vec<u8>

The body.

Methods

text

pub fn text(status: u16, body: &str) -> Response

A plain-text response with status and body.

to_bytes

pub fn to_bytes(&self, include_body: bool) -> Vec<u8>

Serialise; include_body is false for HEAD requests.

Trait implementations