Crate uhttp_uri [] [src]

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.


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

let uri = HttpUri::new("").unwrap();
assert_eq!(uri.scheme, HttpScheme::Https);
assert_eq!(uri.authority, "");
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);



Components in an HTTP URI resource.


Components in an HTTP Request Line URI.



Schemes for HTTP requests.