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§
- Chunk
Reader - Decoder for chunked transfer encoding.
- Config
- Parser configuration.
Enums§
- Body
- Either an HTTP body or nothing.
- Body
Reader - Abstraction for parsing streamed payloads.
- Error
- Errors that can be raised during HTTP parsing.
Functions§
- parse_
request - Parses an HTTP request.
- parse_
request_ head - Parses the request line and the headers of an HTTP request.
- parse_
response - Parses an HTTP response.
- unparse_
request - Serializes an HTTP request into a stream.
- unparse_
request_ head - Serializes a request line and headers.
- unparse_
request_ head_ parts - Serializes a request line and headers.
- unparse_
request_ sync - Serializes an HTTP request into a byte array.
- unparse_
response - Serializes an HTTP response into a stream.
- unparse_
response_ head - Serializes a status line and headers.
- unparse_
response_ head_ parts - Serializes a status line and headers.
- unparse_
response_ sync - Serializes an HTTP response into a byte array.