Crate safehttp

source ·
Expand description

A slow (but simple, safe and strict) HTTP/1.1 parser for Rust

See RFC 7230.

§Simple example

extern crate http;
extern crate safehttp;
use std::io;

let mut source = io::Cursor::new(
    b"GET /index.html HTTP/1.1\r\nHost: example.com\r\n\r\n".to_vec()
);
let config = &safehttp::Config::DEFAULT;
let request = safehttp::parse_request(&mut source, config).unwrap();

assert_eq!(request.method(), http::Method::GET);
assert_eq!(request.uri(), "/index.html");
assert_eq!(request.headers().get("host").unwrap(), "example.com");

Structs§

Enums§

  • Either an HTTP body or nothing.
  • Abstraction for parsing streamed payloads.

Functions§