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§
- Decoder for chunked transfer encoding.
- Parser configuration.
Enums§
- Either an HTTP body or nothing.
- Abstraction for parsing streamed payloads.
Functions§
- Parses an HTTP request.
- Parses the request line and the headers of an HTTP request.
- Parses an HTTP response.
- Serializes an HTTP request into a stream.
- Serializes a request line and headers.
- Serializes a request line and headers.
- Serializes an HTTP request into a byte array.
- Serializes an HTTP response into a stream.
- Serializes a status line and headers.
- Serializes a status line and headers.
- Serializes an HTTP response into a byte array.