Expand description
Host = uri-host [ ":" port ] (RFC 9110 section 7.2, citing RFC 3986
section 3.2.2), with real IPv4 and IPv6 validation.
§Examples
use core::net::Ipv6Addr;
use parse_net::{self as pn, Host, HostPort};
assert_eq!(pn::parse_host_port(b"[::1]:8080")?,
HostPort { host: Host::V6(Ipv6Addr::LOCALHOST), port: Some(8080), empty_port: false });
assert_eq!(pn::parse_host_port(b"Example.COM.")?.host, Host::Name(b"Example.COM."));
assert_eq!(pn::parse_host_port(b"127.1").unwrap_err().kind(), pn::ErrorKind::InvalidAddress);
assert_eq!(pn::parse_host_port(b"a.com:80@b.com").unwrap_err().kind(), pn::ErrorKind::InvalidHost);Structs§
- Host
Port - A host and an optional port.
Enums§
- Host
- A host: a registered name, an IP address, or a future IP literal.
Functions§
- parse_
host - Parses a host with no port.
- parse_
host_ port - Parses a
Hostvalue:uri-host [ ":" port ]. - parse_
uri_ host_ port - Parses
host [ ":" port ]exactly as given, for a URI authority or a request target: unlikeparse_host_port, no OWS is stripped, so any whitespace is refused.