17 releases

0.2.16 Jul 17, 2021
0.2.15 Jul 17, 2021
0.2.14 May 29, 2021
0.2.13 Apr 30, 2021
0.1.16 Apr 24, 2021

#94 in #http-response

Download history 137/week @ 2024-07-29 2/week @ 2024-09-23 19/week @ 2024-09-30

78 downloads per month

MIT/Apache

30KB
880 lines

http-protocol

Headers

extern crate http_protocol;

use http_protocol::header::Header;
use http_protocol::Headers;

fn main() {
    let mut headers = Headers::new();
    headers.insert(Header::Connection, &b"close"[..]);
    println!("{:?}", headers);
}

Response

extern crate http_protocol;

use http_protocol::header::Header;
use http_protocol::{Body, Headers, HttpVersion, Response, StatusCode};

fn main() {
    let mut headers = Headers::new();
    headers.insert(Header::Connection, &b"close"[..]);

    let mut response_builder = Response::builder();

    response_builder
        .http_version(HttpVersion::Http11)
        .status_code(StatusCode::S200)
        .headers(headers)
        .body(Body::empty());

    let response = response_builder.build().unwrap();

    println!("{:?}", response);
}

Dependencies

~2.5–8MB
~60K SLoC