htpp

Crates.iohtpp
lib.rshtpp
version0.2.2
sourcesrc
created_at2024-10-17 19:21:39.513069
updated_at2024-10-23 18:04:40.872735
descriptionA simple, fast, and secure http parser. It adheres strictly to the http specification, which is intentional as to be efficient and prevent possible http related attacks. It only supports http 1.1 but support for http 2.0 is planned
homepage
repositoryhttps://github.com/Albassel/htpp
max_upload_size
id1413541
size20,306
Basel (Albassel)

documentation

README

Htpp

A fast and simple HTTP 1.1 parser written in Rust

Usage

To parse an HTTP request:

let req = b"GET /index.html HTTP/1.1\r\nAccept: */*\r\n\r\n";
let parsed = htpp::Request::parse(req).unwrap();
assert!(parsed.method() == htpp::Method::Get);
assert!(parsed.path() == "/index.html");
assert!(parsed.headers().len() == 1);
assert!(parsed.headers()[0].name == "Accept");
assert!(parsed.headers()[0].val == b"*/*");

To parse an HTTP response:

let res = b"HTTP/1.1 200 OK\r\nAccept: */*\r\n\r\n";
let parsed = htpp::Response::parse(res).unwrap();
assert!(parsed.status() == 200);
assert!(parsed.reason() == "OK");
assert!(parsed.headers().len() == 1);
assert!(parsed.headers()[0].name == "Accept");
assert!(parsed.headers()[0].val == b"*/*");

Contribution

Feel free to make a pull request if you think you can improve the code

Commit count: 11

cargo fmt