Module cabot::response [] [src]

HTTP Response handling. The TCP response stream is converted to a Response structure.

Example

use cabot::response::ResponseBuilder;

let response = ResponseBuilder::new()
    .set_status_line("HTTP/1.1 200 Ok")
    .add_header("Content-Type: application/json")
    .set_body(&[123, 125])
    .build()
    .unwrap();

assert_eq!(response.http_version(), "HTTP/1.1");
assert_eq!(response.status_code(), 200);
assert_eq!(response.status_line(), "200 Ok");
assert_eq!(response.headers(), &["Content-Type: application/json"]);
assert_eq!(response.body_as_string().unwrap(), "{}");

Structs

Response

Represent the parsed HTTP response.

ResponseBuilder

An internal class used to build response.