Expand description
§use-http
Small HTTP primitive utilities for RustUse.
§Experimental
use-http is experimental while the use-web workspace remains below 0.3.0. Expect small API adjustments during the first release wave.
§Example
use use_http::{HttpVersion, parse_request_line};
let request = parse_request_line("GET /docs HTTP/1.1").unwrap();
assert_eq!(request.method, "GET");
assert_eq!(request.target, "/docs");
assert_eq!(request.version, HttpVersion::Http11);§Scope
- HTTP version parsing and formatting.
- Lightweight request-line and status-line parsing.
- Helpers for classifying request-target forms.
§Non-goals
- HTTP clients or servers.
- TCP or TLS handling.
- Async networking.
- Full HTTP parsers.
- Body parsing.
- HTTP/2 or HTTP/3 frame handling.
§License
Licensed under either of the following, at your option:
- Apache License, Version 2.0
- MIT license
Structs§
- Http
Request Line - A parsed HTTP request line.
- Http
Status Line - A parsed HTTP status line.
Enums§
- Http
Version - A small set of HTTP versions commonly encountered in textual protocol surfaces.
Functions§
- format_
http_ version - Formats an HTTP version token.
- is_
http_ version - Returns
truewhen the input is a recognized textual HTTP version. - is_
request_ target_ absolute_ form - Returns
truewhen the target is in absolute-form, such ashttps://example.com/. - is_
request_ target_ asterisk_ form - Returns
truewhen the target is the asterisk-form*. - is_
request_ target_ authority_ form - Returns
truewhen the target is in authority-form, such asexample.com:443. - is_
request_ target_ origin_ form - Returns
truewhen the target is in origin-form, such as/items?limit=10. - looks_
like_ http_ request_ line - Returns
truewhen the input looks like a valid HTTP request line. - looks_
like_ http_ status_ line - Returns
truewhen the input looks like a valid HTTP status line. - parse_
http_ version - Parses a textual HTTP version token.
- parse_
request_ line - Parses a request line in the form
METHOD target HTTP/x. - parse_
status_ line - Parses a status line in the form
HTTP/x 200 Reason.