uhttp_uri 0.5.1

Zero-allocation parser for HTTP URIs
Documentation
  • Coverage
  • 100%
    14 out of 14 items documented1 out of 6 items with examples
  • Size
  • Source code size: 13.9 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 2.34 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 9s Average build duration of successful builds.
  • all releases: 9s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • kchmck/uhttp_uri.rs
    1 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • kchmck

This crate provides a barebone, zero-allocation parser for HTTP URIs as they appear in a request header.

In general, components are extracted along defined delimiters, but further validation and processing (such as percent decoding, query decoding, and punycode decoding) is left to higher layers. In the pursuit of simplicity, this crate also contains no support for generic and non-http URIs such as file: and ftp:// – only the reduced syntax for http:// and https:// schemes is implemented.

Example

use uhttp_uri::{HttpUri, HttpResource, HttpScheme};

let uri = HttpUri::new("https://example.com:443/r/rarepuppers?k=v&v=k#top").unwrap();
assert_eq!(uri.scheme, HttpScheme::Https);
assert_eq!(uri.authority, "example.com:443");
assert_eq!(uri.resource.path, "/r/rarepuppers");
assert_eq!(uri.resource.query, Some("k=v&v=k"));
assert_eq!(uri.resource.fragment, Some("top"));

let res = HttpResource::new("/shittydogs?lang=en");
assert_eq!(res.path, "/shittydogs");
assert_eq!(res.query, Some("lang=en"));
assert_eq!(res.fragment, None);