http-protocol

Crates.iohttp-protocol
lib.rshttp-protocol
version0.2.16
sourcesrc
created_at2021-04-22 14:11:30.857992
updated_at2021-07-17 05:21:54.756492
descriptionhttp protocol
homepagehttps://github.com/WatchDG/rust-http-protocol
repositoryhttps://github.com/WatchDG/rust-http-protocol
max_upload_size
id388149
size38,198
(WatchDG)

documentation

https://docs.rs/http-protocol

README

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);
}
Commit count: 38

cargo fmt