Skip to main content

Crate use_http

Crate use_http 

Source
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§

HttpRequestLine
A parsed HTTP request line.
HttpStatusLine
A parsed HTTP status line.

Enums§

HttpVersion
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 true when the input is a recognized textual HTTP version.
is_request_target_absolute_form
Returns true when the target is in absolute-form, such as https://example.com/.
is_request_target_asterisk_form
Returns true when the target is the asterisk-form *.
is_request_target_authority_form
Returns true when the target is in authority-form, such as example.com:443.
is_request_target_origin_form
Returns true when the target is in origin-form, such as /items?limit=10.
looks_like_http_request_line
Returns true when the input looks like a valid HTTP request line.
looks_like_http_status_line
Returns true when 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.